Where modeling judgment enters
Trellis authors models for operations outside the mechanical extraction and reviews their meaning against Rust. Each item explains the choice, its evidence, and the review result.
24 hand-modeled rust operations · 17 specification vocabulary and authored definitions · 8 source adaptations · 1 platform and environment premises
Hand-modeled Rust operations (24)
core::clone::impls::{impl core::clone::Clone for f64}::clone
Inspect related source (1)
- clone · core/src/clone.rs:698 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::clone::impls::{impl core::clone::Clone for f64}::clone |
|---|---|
| Recorded source | /rustc/library/core/src/clone.rs |
| Lines | 698:20–698:43 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: F64 → Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64Clone]
def ModelF64Clone : F64 -> Result F64 :=
-- BODY
Binary64ModelDefault.clone
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
*self; see reference/model-evidence/binary64-boundary.txt.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64Clone · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:a83c979cf50f5a1824716814904d563b188c776568e8a0cead39a83f09ff9c8f |
| Preservation current fingerprint | preservation-v1:a83c979cf50f5a1824716814904d563b188c776568e8a0cead39a83f09ff9c8f |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","lean_semantic_closure":"068fedc14b4d117f34e0a8caa8b7a66c56c5ff8f94b5c41fed41524fc71c431a","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","lean_semantic_closure":"068fedc14b4d117f34e0a8caa8b7a66c56c5ff8f94b5c41fed41524fc71c431a","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "2bc7ba02f9157ce0f744d0ea8618ff396c2d06538f536a0ef2dcd48a71a60aec",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:a83c979cf50f5a1824716814904d563b188c776568e8a0cead39a83f09ff9c8f"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64Clone.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::MANTISSA_DIGITS
Inspect related source (1)
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::MANTISSA_DIGITS |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 412:4–412:34 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Result Std.U32Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64MantissaDigits]
def ModelF64MantissaDigits : Result Std.U32 :=
-- BODY
Binary64ModelDefault.mantissaDigits
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
f64::MANTISSA_DIGITS declaration is 53; see reference/model-evidence/binary64-boundary.txt.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64MantissaDigits · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:5d70d7473b65864ac8a66bb8fcadcbfbc12e667c8688d53d87179113f89db01e |
| Preservation current fingerprint | preservation-v1:5d70d7473b65864ac8a66bb8fcadcbfbc12e667c8688d53d87179113f89db01e |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","lean_semantic_closure":"02593c098e85d6df521ae27a662f7e0cccae25cbd2b0b466e6e70737ec6a8a9a","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","lean_semantic_closure":"02593c098e85d6df521ae27a662f7e0cccae25cbd2b0b466e6e70737ec6a8a9a","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "37c0ab8b95f865993f720fd8787fe227dfab113e98185d637339f5e18beab9e2",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:5d70d7473b65864ac8a66bb8fcadcbfbc12e667c8688d53d87179113f89db01e"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64MantissaDigits.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::NAN
Inspect related source (1)
- NAN · core/src/num/f64.rs:509 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::NAN |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 509:4–509:22 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64Nan]
def ModelF64Nan : Result F64 :=
-- BODY
Binary64ModelDefault.nan
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
f64::NAN on the frozen target and toolchain.Proof
7ff8000000000000; see reference/model-evidence/binary64-boundary.txt.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64Nan · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:fed0883daf940cb641e19eaa8348164fa705617108b66c88e1abd4d5fc313c8d |
| Preservation current fingerprint | preservation-v1:fed0883daf940cb641e19eaa8348164fa705617108b66c88e1abd4d5fc313c8d |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","lean_semantic_closure":"b62ab7da14ebbf932a286022eba8b264942a2ef611d3b03e9f9f9bc3ff5b78c2","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","lean_semantic_closure":"b62ab7da14ebbf932a286022eba8b264942a2ef611d3b03e9f9f9bc3ff5b78c2","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "bf0e16946cdec93eca952e517ef5a7abccd4e5709bc9cb19677a59cb1ec9ebf5",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:fed0883daf940cb641e19eaa8348164fa705617108b66c88e1abd4d5fc313c8d"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64Nan.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::INFINITY
Inspect related source (1)
- INFINITY · core/src/num/f64.rs:512 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::INFINITY |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 512:4–512:27 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64Infinity]
def ModelF64Infinity : Result F64 :=
-- BODY
Binary64ModelDefault.infinity
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
7ff0000000000000, as recorded in reference/model-evidence/binary64-boundary.txt.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64Infinity · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:446560460cf0e7576d1b7bb2177da6e8516e29cb48b66ad09fad25b7f36d8152 |
| Preservation current fingerprint | preservation-v1:446560460cf0e7576d1b7bb2177da6e8516e29cb48b66ad09fad25b7f36d8152 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","lean_semantic_closure":"b9b8f49119dd7b86fe5a771433b4036b8e0edd4621ccccf7c0ae72b448df25b9","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","lean_semantic_closure":"b9b8f49119dd7b86fe5a771433b4036b8e0edd4621ccccf7c0ae72b448df25b9","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "dd846103376fe7ac0bb1f8bf9835cff781b4c107fba96e6332f038d833f2f010",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:446560460cf0e7576d1b7bb2177da6e8516e29cb48b66ad09fad25b7f36d8152"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64Infinity.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::NEG_INFINITY
Inspect related source (1)
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::NEG_INFINITY |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 515:4–515:31 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64NegInfinity]
def ModelF64NegInfinity : Result F64 :=
-- BODY
Binary64ModelDefault.negInfinity
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
fff0000000000000, as recorded in reference/model-evidence/binary64-boundary.txt.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64NegInfinity · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:b0d899cbe01b0d483afbf6207fe2664d84f8d6fe25cc17380febdb391f37caf5 |
| Preservation current fingerprint | preservation-v1:b0d899cbe01b0d483afbf6207fe2664d84f8d6fe25cc17380febdb391f37caf5 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","lean_semantic_closure":"c03e4ef7cdd0f3c15ff594c3a1919b5554f66e2681a60d45ffbb5badff1d2b79","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","lean_semantic_closure":"c03e4ef7cdd0f3c15ff594c3a1919b5554f66e2681a60d45ffbb5badff1d2b79","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "41bfa98f9f55c767f23eb50be2cc099ffb92b4d98ea92ab4bbba1699015475b3",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:b0d899cbe01b0d483afbf6207fe2664d84f8d6fe25cc17380febdb391f37caf5"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64NegInfinity.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::EXPONENT_MASK
Inspect related source (1)
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::EXPONENT_MASK |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 615:4–615:32 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Result Std.U64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64ExponentMask]
def ModelF64ExponentMask : Result Std.U64 :=
-- BODY
Binary64ModelDefault.exponentMask
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
7ff0000000000000, exactly the frozen Rust constant recorded in reference/model-evidence/binary64-boundary.txt.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64ExponentMask · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:3fd2a47c5b5665d882207dfae424448633c3b7724f13f49daa0a8e74577667d3 |
| Preservation current fingerprint | preservation-v1:3fd2a47c5b5665d882207dfae424448633c3b7724f13f49daa0a8e74577667d3 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","lean_semantic_closure":"80c73ea0665302cd5c54c07197df969e3333a5d483f73afd0aafca4293e0d917","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","lean_semantic_closure":"80c73ea0665302cd5c54c07197df969e3333a5d483f73afd0aafca4293e0d917","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "2d441f1150799750e7e55e3484f3ea7100d308f77cf25ffa15c20638cfd186e4",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:3fd2a47c5b5665d882207dfae424448633c3b7724f13f49daa0a8e74577667d3"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64ExponentMask.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::MANTISSA_MASK
Inspect related source (1)
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::MANTISSA_MASK |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 637:4–637:32 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Result Std.U64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64MantissaMask]
def ModelF64MantissaMask : Result Std.U64 :=
-- BODY
Binary64ModelDefault.mantissaMask
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
000fffffffffffff, exactly the frozen Rust constant recorded in reference/model-evidence/binary64-boundary.txt.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64MantissaMask · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:17147001dec11398df2e80c90acc9f131e755c52abf3fa5e72c72605ebe31e63 |
| Preservation current fingerprint | preservation-v1:17147001dec11398df2e80c90acc9f131e755c52abf3fa5e72c72605ebe31e63 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","lean_semantic_closure":"68309612925deed927586c9d2e8f6907ffe089d19691618016820c589a9285b8","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","lean_semantic_closure":"68309612925deed927586c9d2e8f6907ffe089d19691618016820c589a9285b8","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "6e885240f49b0456734d0c53b9237e21fbfb8290f54f30f50dd792aaf70ce133",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:17147001dec11398df2e80c90acc9f131e755c52abf3fa5e72c72605ebe31e63"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64MantissaMask.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::classify
Inspect related source (1)
- classify · core/src/num/f64.rs:782 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::classify |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 782:4–782:45 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: F64 → Result core.num.FpCategoryLean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64Classify]
def ModelF64Classify : F64 -> Result core.num.FpCategory :=
-- BODY
Binary64ModelDefault.classify
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64Classify · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:ba3567c59e47afc5066241034b3b10d6ea5d15f349aa34889691e3d788a277ec |
| Preservation current fingerprint | preservation-v1:ba3567c59e47afc5066241034b3b10d6ea5d15f349aa34889691e3d788a277ec |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","lean_semantic_closure":"b5f937ef31cfdf4ab4e26f96d8646a8c9f2e9e43ec2d22ee04bdaf4760adc1bf","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","lean_semantic_closure":"b5f937ef31cfdf4ab4e26f96d8646a8c9f2e9e43ec2d22ee04bdaf4760adc1bf","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "1dec4f6b71dc6ac692be861296b9d67d3a67be0db84a10a467b13710e114782b",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:ba3567c59e47afc5066241034b3b10d6ea5d15f349aa34889691e3d788a277ec"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64Classify.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::f64::{f64}::to_bits
Inspect related source (1)
- to_bits · core/src/num/f64.rs:1223 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::to_bits |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 1223:4–1223:37 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: F64 → Result Std.U64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64ToBits]
def ModelF64ToBits : F64 -> Result Std.U64 :=
-- BODY
Binary64ModelDefault.toBits
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64ToBits · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/float-carriers.txt
Primary evidence for the F64 raw-word carrier
Scope
-----
This record supports only the representation claim that the source f64
specialization and the authored F64 carrier have the same set of 64-bit
encodings. It does not supply arithmetic or classification semantics.
All commands below were run from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0001/dec2flt-r0001
Tool and input identities
-------------------------
Command:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
Raw result:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Command:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean --version
Raw result:
Lean (version 4.30.0-rc2, x86_64-unknown-linux-gnu, commit 3dc1a088b6d2d8eafe25a7cd7ec7b58d731bd7cc, Release)
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw result:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
git -C /home/leanagent/pv_spike/tools/aeneas status --short
Raw result: empty (the pinned Aeneas checkout was clean).
Command:
sha256sum upstream/traits.rs modeling-input/manifest.json \
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs \
/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
Raw result:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
The manifest's effective_tools entry selects the rustc and Lean paths above,
and its effective_tools.lean_paths begins with the displayed Aeneas checkout.
Frozen f64 specialization
-------------------------
Command:
nl -ba upstream/traits.rs | sed -n '264,295p'
Raw result:
264 impl Float for f64 {
265 type Int = u64;
266
267 const INFINITY: Self = Self::INFINITY;
268 const NEG_INFINITY: Self = Self::NEG_INFINITY;
269 const NAN: Self = Self::NAN;
270 const NEG_NAN: Self = -Self::NAN;
271
272 const BITS: u32 = 64;
273 const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
274 const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
275 const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
276
277 const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
278 const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
279 const SMALLEST_POWER_OF_TEN: i32 = -342;
280
281 fn to_bits(self) -> Self::Int {
282 self.to_bits()
283 }
284
285 fn classify(self) -> FpCategory {
286 self.classify()
287 }
288 }
289
290 impl FloatExt for f64 {
291 #[inline]
292 fn from_u64_bits(v: u64) -> Self {
293 f64::from_bits(v)
294 }
295 }
Thus the exact specialization boundary uses u64 in both directions: its
observation calls f64::to_bits, and its constructor calls f64::from_bits with
the complete u64, without a mask or numeric cast.
Pinned Rust exact-bit operations
--------------------------------
The source path was obtained with this command:
printf '%s/lib/rustlib/src/rust/library/core/src/num/f64.rs\n' \
"$(/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print sysroot)"
Raw result:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
Command (with F equal to that raw result):
nl -ba "$F" | sed -n '1201,1273p'
Raw result:
1201 /// Raw transmutation to `u64`.
1202 ///
1203 /// This is currently identical to `transmute::<f64, u64>(self)` on all platforms.
1204 ///
1205 /// See [`from_bits`](Self::from_bits) for some discussion of the
1206 /// portability of this operation (there are almost no issues).
1207 ///
1208 /// Note that this function is distinct from `as` casting, which attempts to
1209 /// preserve the *numeric* value, and not the bitwise value.
1210 ///
1211 /// # Examples
1212 ///
1213 /// ```
1214 /// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
1215 /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
1216 /// ```
1217 #[must_use = "this returns the result of the operation, \
1218 without modifying the original"]
1219 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1220 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1221 #[allow(unnecessary_transmutes)]
1222 #[inline]
1223 pub const fn to_bits(self) -> u64 {
1224 // SAFETY: `u64` is a plain old datatype so we can always transmute to it.
1225 unsafe { mem::transmute(self) }
1226 }
1227
1228 /// Raw transmutation from `u64`.
1229 ///
1230 /// This is currently identical to `transmute::<u64, f64>(v)` on all platforms.
1231 /// It turns out this is incredibly portable, for two reasons:
1232 ///
1233 /// * Floats and Ints have the same endianness on all supported platforms.
1234 /// * IEEE 754 very precisely specifies the bit layout of floats.
1235 ///
1236 /// However there is one caveat: prior to the 2008 version of IEEE 754, how
1237 /// to interpret the NaN signaling bit wasn't actually specified. Most platforms
1238 /// (notably x86 and ARM) picked the interpretation that was ultimately
1239 /// standardized in 2008, but some didn't (notably MIPS). As a result, all
1240 /// signaling NaNs on MIPS are quiet NaNs on x86, and vice-versa.
1241 ///
1242 /// Rather than trying to preserve signaling-ness cross-platform, this
1243 /// implementation favors preserving the exact bits. This means that
1244 /// any payloads encoded in NaNs will be preserved even if the result of
1245 /// this method is sent over the network from an x86 machine to a MIPS one.
1246 ///
1247 /// If the results of this method are only manipulated by the same
1248 /// architecture that produced them, then there is no portability concern.
1249 ///
1250 /// If the input isn't NaN, then there is no portability concern.
1251 ///
1252 /// If you don't care about signaling-ness (very likely), then there is no
1253 /// portability concern.
1254 ///
1255 /// Note that this function is distinct from `as` casting, which attempts to
1256 /// preserve the *numeric* value, and not the bitwise value.
1257 ///
1258 /// # Examples
1259 ///
1260 /// ```
1261 /// let v = f64::from_bits(0x4029000000000000);
1262 /// assert_eq!(v, 12.5);
1263 /// ```
1264 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1265 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1266 #[must_use]
1267 #[inline]
1268 #[allow(unnecessary_transmutes)]
1269 pub const fn from_bits(v: u64) -> Self {
1270 // It turns out the safety issues with sNaN were overblown! Hooray!
1271 // SAFETY: `u64` is a plain old datatype so we can always transmute from it.
1272 unsafe { mem::transmute(v) }
1273 }
These are opposite same-size transmutations, and the source explicitly chooses
exact bit preservation for NaNs, including their payloads.
Pinned Aeneas 64-bit carrier
----------------------------
Command:
nl -ba /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean \
| sed -n '27,34p;45,53p;65,69p;650,656p;1089,1094p'
Raw result:
27 /-- Kinds of unsigned integers -/
28 inductive UScalarTy where
29 | Usize
30 | U8
31 | U16
32 | U32
33 | U64
34 | U128
45 @[implicit_reducible]
46 def UScalarTy.numBits (ty : UScalarTy) : Nat :=
47 match ty with
48 | Usize => System.Platform.numBits
49 | U8 => 8
50 | U16 => 16
51 | U32 => 32
52 | U64 => 64
53 | U128 => 128
65 /-- Unsigned integer -/
66 structure UScalar (ty : UScalarTy) where
67 /- The internal representation is a bit-vector -/
68 bv : BitVec ty.numBits
69 deriving Repr, BEq, DecidableEq
650 /-! The scalar types. -/
651 abbrev Usize := UScalar .Usize
652 abbrev U8 := UScalar .U8
653 abbrev U16 := UScalar .U16
654 abbrev U32 := UScalar .U32
655 abbrev U64 := UScalar .U64
656 abbrev U128 := UScalar .U128
1089 abbrev U8.bv (x : U8) : BitVec 8 := UScalar.bv x
1090 abbrev U16.bv (x : U16) : BitVec 16 := UScalar.bv x
1091 abbrev U32.bv (x : U32) : BitVec 32 := UScalar.bv x
1092 abbrev U64.bv (x : U64) : BitVec 64 := UScalar.bv x
1093 abbrev U128.bv (x : U128) : BitVec 128 := UScalar.bv x
1094 abbrev Usize.bv (x : Usize) : BitVec System.Platform.numBits := UScalar.bv x
Consequently Std.U64 is a one-field structure whose field ranges over every
BitVec 64. There is neither a validity predicate nor a quotient that could
remove, merge, or add raw words.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:7e79efc2ae1d1e8bc1f73ce809576ee3909a9157b9eac21f3a38421795c062d3 |
| Preservation current fingerprint | preservation-v1:7e79efc2ae1d1e8bc1f73ce809576ee3909a9157b9eac21f3a38421795c062d3 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","lean_semantic_closure":"77d5d712dffbb54050b6077fdb30f70d9015f2aef826a25bcbee1c352227465c","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","lean_semantic_closure":"77d5d712dffbb54050b6077fdb30f70d9015f2aef826a25bcbee1c352227465c","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "858781e2002fa2fe04b13ddd6c3130c292ff25b921d38c7eecec07e9c3111e9b",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:7e79efc2ae1d1e8bc1f73ce809576ee3909a9157b9eac21f3a38421795c062d3"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}Captured evidence identities
[
{
"path": "reference/model-evidence/float-carriers.txt",
"sha256": "4367b150c75a979015e2a6063d4080d3f0a1681c640421692ff9ac8c139632e5",
"cited_by": [
"Tablet/ModelF64ToBits.tex",
"Tablet/model-support.json"
]
}
]core::f64::{f64}::from_bits
Inspect related source (1)
- from_bits · core/src/num/f64.rs:1269 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::f64::{f64}::from_bits |
|---|---|
| Recorded source | /rustc/library/core/src/num/f64.rs |
| Lines | 1269:4–1269:42 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Std.U64 → Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64FromBits]
def ModelF64FromBits : Std.U64 -> Result F64 :=
-- BODY
Binary64ModelDefault.fromBits
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64FromBits · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/float-carriers.txt
Primary evidence for the F64 raw-word carrier
Scope
-----
This record supports only the representation claim that the source f64
specialization and the authored F64 carrier have the same set of 64-bit
encodings. It does not supply arithmetic or classification semantics.
All commands below were run from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0001/dec2flt-r0001
Tool and input identities
-------------------------
Command:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
Raw result:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Command:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean --version
Raw result:
Lean (version 4.30.0-rc2, x86_64-unknown-linux-gnu, commit 3dc1a088b6d2d8eafe25a7cd7ec7b58d731bd7cc, Release)
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw result:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
git -C /home/leanagent/pv_spike/tools/aeneas status --short
Raw result: empty (the pinned Aeneas checkout was clean).
Command:
sha256sum upstream/traits.rs modeling-input/manifest.json \
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs \
/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
Raw result:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
The manifest's effective_tools entry selects the rustc and Lean paths above,
and its effective_tools.lean_paths begins with the displayed Aeneas checkout.
Frozen f64 specialization
-------------------------
Command:
nl -ba upstream/traits.rs | sed -n '264,295p'
Raw result:
264 impl Float for f64 {
265 type Int = u64;
266
267 const INFINITY: Self = Self::INFINITY;
268 const NEG_INFINITY: Self = Self::NEG_INFINITY;
269 const NAN: Self = Self::NAN;
270 const NEG_NAN: Self = -Self::NAN;
271
272 const BITS: u32 = 64;
273 const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
274 const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
275 const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
276
277 const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
278 const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
279 const SMALLEST_POWER_OF_TEN: i32 = -342;
280
281 fn to_bits(self) -> Self::Int {
282 self.to_bits()
283 }
284
285 fn classify(self) -> FpCategory {
286 self.classify()
287 }
288 }
289
290 impl FloatExt for f64 {
291 #[inline]
292 fn from_u64_bits(v: u64) -> Self {
293 f64::from_bits(v)
294 }
295 }
Thus the exact specialization boundary uses u64 in both directions: its
observation calls f64::to_bits, and its constructor calls f64::from_bits with
the complete u64, without a mask or numeric cast.
Pinned Rust exact-bit operations
--------------------------------
The source path was obtained with this command:
printf '%s/lib/rustlib/src/rust/library/core/src/num/f64.rs\n' \
"$(/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print sysroot)"
Raw result:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
Command (with F equal to that raw result):
nl -ba "$F" | sed -n '1201,1273p'
Raw result:
1201 /// Raw transmutation to `u64`.
1202 ///
1203 /// This is currently identical to `transmute::<f64, u64>(self)` on all platforms.
1204 ///
1205 /// See [`from_bits`](Self::from_bits) for some discussion of the
1206 /// portability of this operation (there are almost no issues).
1207 ///
1208 /// Note that this function is distinct from `as` casting, which attempts to
1209 /// preserve the *numeric* value, and not the bitwise value.
1210 ///
1211 /// # Examples
1212 ///
1213 /// ```
1214 /// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
1215 /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
1216 /// ```
1217 #[must_use = "this returns the result of the operation, \
1218 without modifying the original"]
1219 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1220 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1221 #[allow(unnecessary_transmutes)]
1222 #[inline]
1223 pub const fn to_bits(self) -> u64 {
1224 // SAFETY: `u64` is a plain old datatype so we can always transmute to it.
1225 unsafe { mem::transmute(self) }
1226 }
1227
1228 /// Raw transmutation from `u64`.
1229 ///
1230 /// This is currently identical to `transmute::<u64, f64>(v)` on all platforms.
1231 /// It turns out this is incredibly portable, for two reasons:
1232 ///
1233 /// * Floats and Ints have the same endianness on all supported platforms.
1234 /// * IEEE 754 very precisely specifies the bit layout of floats.
1235 ///
1236 /// However there is one caveat: prior to the 2008 version of IEEE 754, how
1237 /// to interpret the NaN signaling bit wasn't actually specified. Most platforms
1238 /// (notably x86 and ARM) picked the interpretation that was ultimately
1239 /// standardized in 2008, but some didn't (notably MIPS). As a result, all
1240 /// signaling NaNs on MIPS are quiet NaNs on x86, and vice-versa.
1241 ///
1242 /// Rather than trying to preserve signaling-ness cross-platform, this
1243 /// implementation favors preserving the exact bits. This means that
1244 /// any payloads encoded in NaNs will be preserved even if the result of
1245 /// this method is sent over the network from an x86 machine to a MIPS one.
1246 ///
1247 /// If the results of this method are only manipulated by the same
1248 /// architecture that produced them, then there is no portability concern.
1249 ///
1250 /// If the input isn't NaN, then there is no portability concern.
1251 ///
1252 /// If you don't care about signaling-ness (very likely), then there is no
1253 /// portability concern.
1254 ///
1255 /// Note that this function is distinct from `as` casting, which attempts to
1256 /// preserve the *numeric* value, and not the bitwise value.
1257 ///
1258 /// # Examples
1259 ///
1260 /// ```
1261 /// let v = f64::from_bits(0x4029000000000000);
1262 /// assert_eq!(v, 12.5);
1263 /// ```
1264 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1265 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1266 #[must_use]
1267 #[inline]
1268 #[allow(unnecessary_transmutes)]
1269 pub const fn from_bits(v: u64) -> Self {
1270 // It turns out the safety issues with sNaN were overblown! Hooray!
1271 // SAFETY: `u64` is a plain old datatype so we can always transmute from it.
1272 unsafe { mem::transmute(v) }
1273 }
These are opposite same-size transmutations, and the source explicitly chooses
exact bit preservation for NaNs, including their payloads.
Pinned Aeneas 64-bit carrier
----------------------------
Command:
nl -ba /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean \
| sed -n '27,34p;45,53p;65,69p;650,656p;1089,1094p'
Raw result:
27 /-- Kinds of unsigned integers -/
28 inductive UScalarTy where
29 | Usize
30 | U8
31 | U16
32 | U32
33 | U64
34 | U128
45 @[implicit_reducible]
46 def UScalarTy.numBits (ty : UScalarTy) : Nat :=
47 match ty with
48 | Usize => System.Platform.numBits
49 | U8 => 8
50 | U16 => 16
51 | U32 => 32
52 | U64 => 64
53 | U128 => 128
65 /-- Unsigned integer -/
66 structure UScalar (ty : UScalarTy) where
67 /- The internal representation is a bit-vector -/
68 bv : BitVec ty.numBits
69 deriving Repr, BEq, DecidableEq
650 /-! The scalar types. -/
651 abbrev Usize := UScalar .Usize
652 abbrev U8 := UScalar .U8
653 abbrev U16 := UScalar .U16
654 abbrev U32 := UScalar .U32
655 abbrev U64 := UScalar .U64
656 abbrev U128 := UScalar .U128
1089 abbrev U8.bv (x : U8) : BitVec 8 := UScalar.bv x
1090 abbrev U16.bv (x : U16) : BitVec 16 := UScalar.bv x
1091 abbrev U32.bv (x : U32) : BitVec 32 := UScalar.bv x
1092 abbrev U64.bv (x : U64) : BitVec 64 := UScalar.bv x
1093 abbrev U128.bv (x : U128) : BitVec 128 := UScalar.bv x
1094 abbrev Usize.bv (x : Usize) : BitVec System.Platform.numBits := UScalar.bv x
Consequently Std.U64 is a one-field structure whose field ranges over every
BitVec 64. There is neither a validity predicate nor a quotient that could
remove, merge, or add raw words.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:c57aac0a4355730e8311eee7769436cd92d95476b704354c11f95eda2abf74ea |
| Preservation current fingerprint | preservation-v1:c57aac0a4355730e8311eee7769436cd92d95476b704354c11f95eda2abf74ea |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","lean_semantic_closure":"d3db342befc2f6bd15d0a8d594e7fde493bf2599e8fad4dbd81174d5bdb93c85","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","lean_semantic_closure":"d3db342befc2f6bd15d0a8d594e7fde493bf2599e8fad4dbd81174d5bdb93c85","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "828f6c1697476b5c388b39cb246e901f2bfccbe28f5d4d0cb3e6a9ec8d707090",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:c57aac0a4355730e8311eee7769436cd92d95476b704354c11f95eda2abf74ea"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}Captured evidence identities
[
{
"path": "reference/model-evidence/float-carriers.txt",
"sha256": "4367b150c75a979015e2a6063d4080d3f0a1681c640421692ff9ac8c139632e5",
"cited_by": [
"Tablet/ModelF64FromBits.tex",
"Tablet/model-support.json"
]
}
]core::num::{u8}::is_ascii_digit
Inspect related source (1)
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::num::{u8}::is_ascii_digit |
|---|---|
| Recorded source | /rustc/library/core/src/num/mod.rs |
| Lines | 958:4–958:46 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Std.U8 → Result BoolLean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelU8IsAsciiDigit]
def ModelU8IsAsciiDigit (x : Std.U8) : Result Bool :=
-- BODY
ok (decide (48 <= x.val ∧ x.val <= 57))
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelU8IsAsciiDigit · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:6c50ea54b79baddec0ad7a144571549a2f2ab19b5a9ab5812fb5ee9610f989a8 |
| Preservation current fingerprint | preservation-v1:6c50ea54b79baddec0ad7a144571549a2f2ab19b5a9ab5812fb5ee9610f989a8 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","lean_semantic_closure":"2d851ed7d360abeae832a796cbb23db27ed267a307678d5ac068e41c140e4001","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","lean_semantic_closure":"2d851ed7d360abeae832a796cbb23db27ed267a307678d5ac068e41c140e4001","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "5b061faf12f8b4b20ff86741fa82514570a5d44789e3793f238a3f9e6721f357",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:6c50ea54b79baddec0ad7a144571549a2f2ab19b5a9ab5812fb5ee9610f989a8"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 → Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b",
"node": "ModelU8IsAsciiDigit",
"declaration": "dec2flt_model.ModelU8IsAsciiDigit"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelU8IsAsciiDigit.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul
Inspect related source (1)
- mul · core/src/ops/arith.rs:350 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul |
|---|---|
| Recorded source | /rustc/library/core/src/ops/arith.rs |
| Lines | 350:12–350:41 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: F64 → F64 → Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64Mul]
def ModelF64Mul : F64 -> F64 -> Result F64 :=
-- BODY
Binary64ModelDefault.mul
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
biased_fp_to_float, whose source body only casts the
biased exponent, shifts it, ORs it with the mantissa, and calls
from_u64_bits; it never invokes binary64 multiplication, as recorded
in reference/model-evidence/binary64-boundary.txt. This binding
therefore cannot affect the claimed assembled word.Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
compute_float. Its source body performs integer
table arithmetic and returns a raw BiasedFp; the exact source excerpt
in reference/model-evidence/binary64-boundary.txt records that it
contains no primitive float multiplication. This binding therefore cannot
change either deferral or the returned raw pair.Requirement: native correct or defer
can_use_fast_path guards in
reference/model-evidence/binary64-boundary.txt give
\mathit{mantissa}\leq2^{53} and 0\leq\mathit{exponent}\leq22. In the
disguised arm, checked_mul must succeed and the resulting mantissa is
explicitly checked to be at most 2^{53} before multiplication by table entry
22. Applying Binary64NativeCallDomain gives finite non-NaN
operands in both arms, so the exact finite-operand multiplication clause above
agrees with the source on every executed binary64 multiplication; the
negative-exponent ordinary arm divides instead.Requirement: number helper acceptance
parse_number. Its recorded source body only
accepts a complete Decimal returned by
parse_partial_number; it has no float type parameter and executes no
float operation, including multiplication
(reference/model-evidence/binary64-boundary.txt).Requirement: number helper accumulated value
Decimal record returned by
parse_number. The recorded source boundary shows that this helper
has no float type parameter or float operation, so no binary64 multiplication
can affect the record or its represented interval
(reference/model-evidence/binary64-boundary.txt).Requirement: number helper record bounds
parse_number returns its
Decimal record. As its exact source body in
reference/model-evidence/binary64-boundary.txt shows, it invokes
no float conversion or arithmetic, hence no binary64 multiplication can
affect the record's sign or mantissa bound.Requirement: number helper rejection
parse_number: the helper
returns None unless parse_partial_number consumed the
entire slice. The recorded body has no float type parameter or float
operation, so this multiplication binding is not reached
(reference/model-evidence/binary64-boundary.txt).Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
None and the
dispatcher takes the special-helper branch. The source excerpt in
reference/model-evidence/binary64-boundary.txt shows that this
branch selects the infinity constant and conditionally negates it; it never
calls try_fast_path or binary64 multiplication.Requirement: parser invalid rejection
parse_number and then
parse_inf_nan both return None, after which the dispatcher
returns the parsing error. The former has no float operation and the latter
only selects a special constant and conditionally negates on success, as
recorded in reference/model-evidence/binary64-boundary.txt; this
branch never reaches try_fast_path or binary64 multiplication.Requirement: parser nan acceptance
None and the dispatcher
takes the special-helper branch. That branch selects the NaN constant and
conditionally negates it, as recorded in
reference/model-evidence/binary64-boundary.txt; it does not call
try_fast_path or binary64 multiplication, and no raw-word identity for an
arithmetic NaN is asserted.Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Assembled trace. The source dispatcher
records such a trace only after try_fast_path returned
None; an executed float multiplication belongs to a successful
ordinary or disguised native arm and returns directly as Some.
Thus no execution relevant to the selected-pair exponent observation executes
binary64 multiplication, as the dispatcher excerpt in
reference/model-evidence/binary64-boundary.txt records.Requirement: parser selected magnitude sign
Assembled route, reached after the native shortcut returned
None. Every executed float multiplication is in an ordinary or
disguised native arm that returns its value directly rather than selecting or
assembling a raw pair. Consequently this binding cannot affect the selected
pair or its clear sign bit
(reference/model-evidence/binary64-boundary.txt).Requirement: parser signed zero
Requirement: parser totality
checked_mul succeeded and the
resulting mantissa passed the 2^{53} bound, and it uses table index 22.
Applying Binary64NativeCallDomain gives finite non-NaN operands in
both arms, so the exact finite-operand multiplication clause above supplies
the same normal source result. Every other dispatcher branch makes no float
multiplication call, so the binding introduces no panic or divergence on any
source input.Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
parse_long_mantissa. Its recorded source body uses
decimal-sequence shifts and integer rounding and returns a raw
BiasedFp; it contains no primitive float multiplication or other
float arithmetic (reference/model-evidence/binary64-boundary.txt).
Thus this binding cannot affect its returned pair.Requirement: special helper infinity
parse_inf_nan. For an infinity keyword its exact
source path selects the infinity constant and conditionally applies negation;
it contains no binary64 multiplication call, as recorded in
reference/model-evidence/binary64-boundary.txt.Requirement: special helper nan
parse_inf_nan. For a NaN keyword its exact source
path selects the NaN constant and conditionally applies negation; it contains
no binary64 multiplication call, as recorded in
reference/model-evidence/binary64-boundary.txt. This application
asserts only the NaN category, not equality of any arithmetic NaN raw word.Requirement: special helper rejection
parse_inf_nan; an unrecognized keyword takes its
None branch before any special constant or negation is returned. The
recorded source body contains no binary64 multiplication on either success or
rejection
(reference/model-evidence/binary64-boundary.txt).Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64Mul · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:334541e742265ad320e118bbdb6f5807e8c38a5905ddd957543fef739f19d397 |
| Preservation current fingerprint | preservation-v1:334541e742265ad320e118bbdb6f5807e8c38a5905ddd957543fef739f19d397 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","lean_semantic_closure":"43510aafab4941ffb14dcb373fd5a4b71249109e37c9a94e16c17435345ca3da","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","lean_semantic_closure":"43510aafab4941ffb14dcb373fd5a4b71249109e37c9a94e16c17435345ca3da","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "ca0fff5203adeda352918514d316e98bcf78eaae455530614bb4fa2e8f8ff166",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f",
"Binary64NativeCallDomain": "5b06c401ea7b8fe802a4cae40bcf11c5e438e342f3284a9e27ea421e01cb3642"
},
"combined_sound_fp": "preservation-v1:334541e742265ad320e118bbdb6f5807e8c38a5905ddd957543fef739f19d397"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64Mul.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div
Inspect related source (1)
- div · core/src/ops/arith.rs:515 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div |
|---|---|
| Recorded source | /rustc/library/core/src/ops/arith.rs |
| Lines | 515:12–515:41 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: F64 → F64 → Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64Div]
def ModelF64Div : F64 -> F64 -> Result F64 :=
-- BODY
Binary64ModelDefault.div
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
try_fast_path arm. Thus, in every execution of a pursued source
subject, either that expression is not reached and no binary64 division result
is replaced, or it is reached after the can_use_fast_path guards.
In the latter case those guards give
\mathit{mantissa}\leq 2^{53} and
-22\leq\mathit{exponent}<0, so the negated power-table index is in
1,\ldots,22. Applying Binary64NativeCallDomain to these derived
bounds shows that conversion of the mantissa returns a finite, non-NaN
numerator and that the selected table entry returns a finite, non-NaN,
positive, nonzero divisor. The exact finite-operand, nonzero-divisor clause of
Binary64ModelDefault therefore makes ModelF64Div return
exactly the source binary64 quotient, including its sign and rounded raw word.
Consequently, on every source execution, replacing the bound division has the
following local effect only: an executed division returns the same value and
the subsequent execution is unchanged, while an execution with no division
call is unaffected.Authored arguments for individual requirements
Requirement: assembly correspondence
biased_fp_to_float, whose source body only casts the
biased exponent, shifts it, ORs it with the mantissa, and calls
from_u64_bits; it never invokes binary64 division, as recorded in
reference/model-evidence/binary64-boundary.txt. This binding
therefore cannot affect the claimed assembled word.Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
compute_float. Its source body performs integer
table arithmetic and returns a raw BiasedFp; the exact source excerpt
in reference/model-evidence/binary64-boundary.txt records that it
contains no primitive float division. This binding therefore cannot change
either deferral or the returned raw pair.Requirement: native correct or defer
try_fast_path execution, the common exhaustive split
applies: if the source makes no binary64 division call this binding is
irrelevant, and if it makes the call ModelF64Div returns exactly the
executed source quotient. Hence this local replacement preserves the actual
None or Some result without assuming that the positive
correctness-or-defer conclusion holds.Requirement: number helper acceptance
parse_number. Its recorded source body only
accepts a complete Decimal returned by
parse_partial_number; it has no float type parameter and executes no
float operation, including division
(reference/model-evidence/binary64-boundary.txt).Requirement: number helper accumulated value
Decimal record returned by
parse_number. The recorded source boundary shows that this helper
has no float type parameter or float operation, so no binary64 division can
affect the record or its represented interval
(reference/model-evidence/binary64-boundary.txt).Requirement: number helper record bounds
parse_number returns its
Decimal record. As its exact source body in
reference/model-evidence/binary64-boundary.txt shows, it invokes
no float conversion or arithmetic, hence no binary64 division can affect the
record's sign or mantissa bound.Requirement: number helper rejection
parse_number: the helper
returns None unless parse_partial_number consumed the
entire slice. The recorded body has no float type parameter or float
operation, so this division binding is not reached
(reference/model-evidence/binary64-boundary.txt).Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
parse_number or parse_partial_number routes that input,
the common local-replacement fact applies. If no division is reached the
execution is unaffected; if one is reached it returns exactly its source
value. Thus the binding preserves the actual returned result and sign without
assuming the positive infinity conclusion.Requirement: parser invalid rejection
parse_number or parse_partial_number routing
fact, the common local-replacement fact applies. An execution with no division
is unaffected, and any division that is reached returns exactly its source
value. Hence this binding preserves the actual result or error without
assuming the positive rejection conclusion.Requirement: parser nan acceptance
parse_number or parse_partial_number routes that input,
the common local-replacement fact applies. An execution with no division is
unaffected, and any executed division returns exactly its source value. This
preserves the actual result and its category without assuming acceptance or
the positive NaN conclusion.Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
parse_long_mantissa. Its recorded source body uses
decimal-sequence shifts and integer rounding and returns a raw
BiasedFp; it contains no primitive float division or other float
arithmetic (reference/model-evidence/binary64-boundary.txt).
Thus this binding cannot affect its returned pair.Requirement: special helper infinity
parse_inf_nan. For an infinity keyword its exact
source path selects the infinity constant and conditionally applies negation;
it contains no division call, as recorded in
reference/model-evidence/binary64-boundary.txt.Requirement: special helper nan
parse_inf_nan. For a NaN keyword its exact source
path selects the NaN constant and conditionally applies negation; it contains
no division call, as recorded in
reference/model-evidence/binary64-boundary.txt. This application
asserts only the NaN category, not equality of any arithmetic NaN raw word.Requirement: special helper rejection
parse_inf_nan; an unrecognized keyword takes its
None branch before any special constant or negation is returned. The
recorded source body contains no binary64 division on either success or
rejection
(reference/model-evidence/binary64-boundary.txt).Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64Div · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:a7948b315706679e20a8e98c056475a0484c7b1130ed97b3f34c1591f0571593 |
| Preservation current fingerprint | preservation-v1:a7948b315706679e20a8e98c056475a0484c7b1130ed97b3f34c1591f0571593 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","lean_semantic_closure":"ea40a149047fde89ae7bb6a18d3dde67b92ee2c77845abb7c0be8722ee33bf31","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","lean_semantic_closure":"ea40a149047fde89ae7bb6a18d3dde67b92ee2c77845abb7c0be8722ee33bf31","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "b21a40029193edd45fe2a63d9c0c5e7cbff30b551ef8e5f30cbe2e42d7e1a60e",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f",
"Binary64NativeCallDomain": "5b06c401ea7b8fe802a4cae40bcf11c5e438e342f3284a9e27ea421e01cb3642"
},
"combined_sound_fp": "preservation-v1:a7948b315706679e20a8e98c056475a0484c7b1130ed97b3f34c1591f0571593"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64Div.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
Inspect related source (1)
- neg · core/src/ops/arith.rs:719 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg |
|---|---|
| Recorded source | /rustc/library/core/src/ops/arith.rs |
| Lines | 719:12–719:30 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: F64 → Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64Neg]
def ModelF64Neg : F64 -> Result F64 :=
-- BODY
Binary64ModelDefault.neg
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Neg implementation for
f64, and that implementation's method is exactly
fn neg(self) { -self }. The frozen extraction identifies
F64.Insts.CoreOpsArithNegF64.neg with this exact Rust method, and the
support manifest binds that external to this definition. These source,
extraction, and binding identities, with their hashes, are recorded in
reference/model-evidence/binary64-negation.txt, whose old
extraction hashes and experiments remain predecessor evidence. The checked
current declaration, signature, Rust symbol, binding, full relevant call
inventory, and unchanged tool/library/configuration identities are in
reference/model-evidence/P89_T2_current-applicability.txt.- preserves every other bit,
including every NaN payload bit. The same evidence record retains a
same-rustc, same-target symbolic probe whose input is an arbitrary
u64 word and whose body applies that concrete trait method to
f64::from_bits(w) before to_bits. Its optimized assembly
loads 0x8000000000000000 and returns its xor with the symbolic input,
with no branch or input restriction. The source is directly retained at
reference/model-evidence/binary64-negation-probe.rs; its current
same-toolchain reproduction, commands, exit statuses, and raw assembly are in
reference/model-evidence/P89_T2_current-applicability.txt.
The arbitrary word arrives in rdi, the mask is loaded into
rax, xorq combines them, and retq returns the
word. This establishes an actual sign flip, not merely permitted sign
variation under the non-sign-bit guarantee. Hence the result is
w\mathbin{\mathsf{xor}}2^{63} for all 2^{64} words, including every
signaling and quiet NaN payload. The definition is the neg field of
Binary64ModelDefault, which returns exactly that xor word in
ok; therefore it agrees extensionally with the extracted source
operation on the entire modeled carrier.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64Neg · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T2_current-applicability.txt
Current applicability of reused binary64 and U64 preservation evidence
Task 11 / worker request 118; checked in the current private checkout.
All commands below ran in this assignment; EXIT records the command status.
Rust commands use LD_LIBRARY_PATH=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib
and RUSTUP_TOOLCHAIN=nightly-2026-06-01.
The managed Lean commands are recorded separately, not invoked by this script.
Reuse and scope
===============
Read-only predecessor: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002
The historical 45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
generated.lean hash belongs to that predecessor, never the current extraction.
The old primary evidence retains its original commands, raw identities and results.
Current checks below establish applicability; prior worker task 9 was rejected,
accepted=false, and its self-report is neither publication nor certification.
Only preservation sections of the six listed owners and ten reserved evidence paths
are submitted. No ordinary statement, Lean computation, GOAL pair, source, extraction,
provenance, Preamble, binding, dispatcher owner or existing config delta is edited.
No new node, route, under-model premise, GOAL decline or polarity change is proposed.
The new 2^59 exponent fold, final-point repair and A/B GOAL domains are not old semantics.
Unchanged primitive meanings are reused, not old parser correctness or old counterexamples.
{
"task_execution": {
"binding": {
"allowed_tasks": [
"ordinary",
"lean_closure"
],
"lightweight": false,
"max_timeout_seconds": 14400,
"model": "gpt-6.1-sol",
"provider": "codex",
"reasoning_effort": "xhigh",
"timeout_seconds": 14400
},
"compiler": "managed",
"profile": "sol-xhigh",
"task_id": 11,
"task_kind": "ordinary"
},
"acceptance_logic_identity": "trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91",
"parallel_scope": {
"exclusive": true,
"helper_prefixes": [
"P116_T1_"
],
"nodes": [
"Binary64ModelDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"shared_writes": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
]
}
}
Current file, compiler, configuration and library identities
============================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum GOAL.md generated.lean Tablet/model-support.json modeling-input/manifest.json modeling-input/extraction.json modeling-input/tool-identities.json modeling-input/SETUP.md modeling-input/revision-from.json crate/Cargo.toml crate/rust-toolchain.toml lean-toolchain lakefile.lean lake-manifest.json trellis.config.json reference/model-evidence/binary64-boundary.txt crate/dec2flt/common.rs crate/dec2flt/decimal.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/fpu.rs crate/dec2flt/lemire.rs crate/dec2flt/mod.rs crate/dec2flt/parse.rs crate/dec2flt/slow.rs crate/dec2flt/table.rs crate/lib.rs crate/num/imp/mod.rs crate/num/mod.rs crate/traits.rs upstream/dec2flt/common.rs upstream/dec2flt/decimal.rs upstream/dec2flt/decimal_seq.rs upstream/dec2flt/fpu.rs upstream/dec2flt/lemire.rs upstream/dec2flt/mod.rs upstream/dec2flt/parse.rs upstream/dec2flt/slow.rs upstream/dec2flt/table.rs upstream/traits.rs reference/model-evidence/binary64-probe.rs reference/model-evidence/binary64-negation-probe.rs reference/model-evidence/u64-shl-probe.rs reference/model-evidence/u64-shr-probe.rs Tablet/Binary64ModelDefault.lean Tablet/ModelF64Neg.lean Tablet/ModelU64BitAnd.lean Tablet/ModelU64BitOr.lean Tablet/ModelU64Shl.lean Tablet/ModelU64Shr.lean
EXIT: 0
STDOUT:
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
1a7d2eea7888b7bdb0421ed6bb96c5ee1e80afe8e788438cd30725f2120a2aea modeling-input/revision-from.json
10584b73664d42dc85fb009bb0783a616520c2cc05f3b0f8c64e5d5cb32e2905 crate/Cargo.toml
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
8dab550b59cec828a4ba436bc25ce9ad66547bdd7f55899b8cbf7e4f65389518 lakefile.lean
a5f9756cd42129193c0285127cddb734224e9c69686fc2de56de2c9d48ed0695 lake-manifest.json
d8fceb13f84ecbf5bf6e9fd7ecdcb061569cfabdb0079243e2eb1609d012ac02 trellis.config.json
749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e reference/model-evidence/binary64-boundary.txt
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b crate/lib.rs
df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1 crate/num/imp/mod.rs
d84067991b142196281bc0968d32634bdcdb9a3a41c2ce2fd3c344d0f61504af crate/num/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e reference/model-evidence/binary64-probe.rs
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8 reference/model-evidence/u64-shl-probe.rs
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee reference/model-evidence/u64-shr-probe.rs
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3 Tablet/Binary64ModelDefault.lean
9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2 Tablet/ModelF64Neg.lean
3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179 Tablet/ModelU64BitAnd.lean
aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f Tablet/ModelU64BitOr.lean
af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad Tablet/ModelU64Shl.lean
54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b Tablet/ModelU64Shr.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo /home/leanagent/pv_spike/tools/charon/bin/charon /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
EXIT: 0
STDOUT:
54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade /home/leanagent/pv_spike/tools/charon/bin/charon
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
STDERR:
(empty)
All installed tool hashes equal the current tool-identities.json pins.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
EXIT: 0
STDOUT:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print cfg --target x86_64-unknown-linux-gnu
EXIT: 0
STDOUT:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat crate/Cargo.toml modeling-input/extraction.json
EXIT: 0
STDOUT:
# Standalone extraction package for the supplied `core::num::dec2flt` slice.
# The package metadata and profiles select the configured environment; source
# correspondence and extraction adaptations are recorded in ../SETUP.md and
# local preservation comments.
[package]
name = "dec2flt-model"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
path = "lib.rs"
[features]
default = []
optimize_for_size = []
[profile.dev]
overflow-checks = true
[profile.release]
overflow-checks = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(target_has_reliable_f16)"] }
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
STDERR:
(empty)
Current effective tools:
{
"aeneas": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"cargo": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"charon": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"env": {
"LD_LIBRARY_PATH": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib",
"RUSTUP_TOOLCHAIN": "nightly-2026-06-01"
},
"lean": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"lean_paths": [
"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean"
],
"readonly": [
"/home/leanagent/pv_spike/tools",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages"
],
"timeouts": {
"aeneas": 3600,
"cargo": 600,
"charon": 600,
"lean": 3600
}
}
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
EXIT: 0
STDOUT:
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
EXIT: 0
STDOUT:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
100644 blob f8582928fe49a0ce75e143b46bb0a8826d7fddae backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
100644 blob d3eb5022efc22d1d6c3ac055965f612c7f2fbca9 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
100644 blob f7bc57109569cdd0fb0c3323021c73673dcfcd33 backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
100644 blob e5733a774268c8dee71bd4ba402240d151bb8cb8 backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
Predecessor pair and probe reuse checks
=======================================
Tablet/Binary64ModelDefault.lean: predecessor_sha256=03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3; whole Lean byte-identical.
Tablet/Binary64ModelDefault.tex: predecessor_sha256=57c6e9ed282cf2dd718f822c6a31255040c71b5c7531488f3951d9c4d4d8b822; ordinary NL definition byte-identical.
Tablet/ModelF64Neg.lean: predecessor_sha256=9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2; whole Lean byte-identical.
Tablet/ModelF64Neg.tex: predecessor_sha256=9d2811046df611e45e2637da57241bace75c3de5822e03126de5f1fc9faeb859; ordinary NL definition byte-identical.
Tablet/ModelU64BitAnd.lean: predecessor_sha256=3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179; whole Lean byte-identical.
Tablet/ModelU64BitAnd.tex: predecessor_sha256=db8a1445918e94fd1c11f92f1c5f218f165aec945ac2ebdeda3cc1675165f8fe; ordinary NL definition byte-identical.
Tablet/ModelU64BitOr.lean: predecessor_sha256=aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f; whole Lean byte-identical.
Tablet/ModelU64BitOr.tex: predecessor_sha256=fbbb37c3cfa81c5811869baf46671d93a6c457042f0a5bbb78ba32c26607dbe2; ordinary NL definition byte-identical.
Tablet/ModelU64Shl.lean: predecessor_sha256=af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad; whole Lean byte-identical.
Tablet/ModelU64Shl.tex: predecessor_sha256=725582880c20b16d00487e01aceb0552a39263616563280cee0d49635984beab; ordinary NL definition byte-identical.
Tablet/ModelU64Shr.lean: predecessor_sha256=54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b; whole Lean byte-identical.
Tablet/ModelU64Shr.tex: predecessor_sha256=3def4409d97d8316d4d77dc2fe01c4142219859ea9596b835ac40f83c3a18784; ordinary NL definition byte-identical.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-negation-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-negation-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shl-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shr-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
Current raw declarations and exact support bindings
===================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py inspect-native .
EXIT: 0
STDOUT:
{
"full_index": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json",
"declaration_count": 24,
"declarations": [
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 \u2192 Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 \u2192 Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 \u2192 Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 \u2192 Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 \u2192 Std.U64 \u2192 Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02"
}
],
"declarations_omitted": 9
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
EXIT: 0
STDOUT:
fbe3b76ef8fbb588841979e071c52eee0fc850472ac55da6f2ca2033e4a34cf4 /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
STDERR:
(empty)
RAW DECLARATION:
/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:
Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43
Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]
Visibility: public -/
@[rust_fun "core::clone::impls::{core::clone::Clone<f64>}::clone"]
axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dfbdb508142706b4c716f701e52a26d63d764f088dacfa461dd81c6df0b9bf0d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_DIGITS]
Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34
Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_DIGITS"]
axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 19dc0621c0c5c7d2a24f090dd7870ffa858de15fc4e1cc7bf57f16d64816c9bc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NAN]
Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22
Name pattern: [core::f64::{f64}::NAN]
Visibility: public -/
@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 75cd3ccca5992f42ef5afa9287573410d249d40f9bcc3120fae72389b2e2419d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27
Name pattern: [core::f64::{f64}::INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::INFINITY"]
axiom core.f64.F64.INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 9a5fb08a6bae926bafdba709d6da6aaad52b8f41c7dbf3e4b2a28b2bc0542716
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NEG_INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31
Name pattern: [core::f64::{f64}::NEG_INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::NEG_INFINITY"]
axiom core.f64.F64.NEG_INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f5d6435579e1da8caecfc1a3b0039a0ce4e250e7dc55c4c69f3edbdd2a5a10f6
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::EXPONENT_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32
Name pattern: [core::f64::{f64}::EXPONENT_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::EXPONENT_MASK"]
axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dcd87a62501dc8e76079204a4b43546a4750077e1f425f01dcd58c96bf31a865
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32
Name pattern: [core::f64::{f64}::MANTISSA_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_MASK"]
axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): cf1585ae2e94a7bf5bb6b5ff37a06a0677b7e8d81420c1e0ca7ee29eca8cfd4c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::classify]:
Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45
Name pattern: [core::f64::{f64}::classify]
Visibility: public -/
@[rust_fun "core::f64::{f64}::classify"]
axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
IDENTITY AND BINDING:
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 7cf497c5bfc31455d5490d5da75914d7eaf9e522aa2eccd14fe9935502b5127c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::to_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37
Name pattern: [core::f64::{f64}::to_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::to_bits"]
axiom core.f64.F64.to_bits : F64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b35203125fea8ba89df874b609344bbe8ad61a61fcb946a184a72c729a1e3364
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::from_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42
Name pattern: [core::f64::{f64}::from_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::from_bits"]
axiom core.f64.F64.from_bits : Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f819b0951f4f63943abf8d4787a2f9489ffd1137fa91529e0771a303bc8fcb94
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41
Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul"]
axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 4adead3b54aa85bfb81b7122b0e942b2c6f3d232d548d8361a2a2ca067be1e7f
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41
Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div"]
axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 62ca24414fa18ef9709d7c5703429d7262f27d017abc975ffb532ae284ba054a
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 945f30e7dbb62802e6ba5bb9d9445e100528b2a52d3b0b6a3a0629c939ff9860
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b66bd94c28f512804622c3717705dbe7ef5a3ced5beaac7435704d053038c36e
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 68909ba4060a48df31ea54bcf0510b089709a3a644c9c1b0770780a98d31f4cc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 5c0105f2c7ce3d255f053e0ccbefa65f73f65de1462832217571cf8cd4963e47
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f100256a450680392496fb74934592e9e2822a1648320153e27c1c0d100ff482
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5
Visibility: public -/
axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
: Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 0bb769d884e3d54d7aa94163fdf4c8fc589050ed84f4fa0d11f694cf599cdb8f
All four identity fields and full raw declaration equal predecessor; current binding matches.
Complete relevant call and wiring inventories
=============================================
This deliberately includes record wiring and scalar lowerings, not just direct external calls.
The four U64 external trait fields wire into Int; generic scalar notation in generated.lean
also lowers directly to the installed operations with the same full-domain meanings.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n 'F64\.Insts\.(CoreClone|CoreOpsArith)|core\.f64\.F64\.|U64\.Insts\.CoreOpsBit|coreops(bit|arith)|\.from_u64|\.pow10_fast_path|FloatInst\.(INFINITY|NEG_INFINITY|NAN|NEG_NAN|SIG_|EXP_|INFINITE_POWER)|&&&|\|\|\||<<<|>>>' generated.lean
EXIT: 0
STDOUT:
25:axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
31:def F64.Insts.CoreCloneClone : core.clone.Clone F64 := {
32: clone := F64.Insts.CoreCloneClone.clone
40: cloneInst := F64.Insts.CoreCloneClone
48:axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
54:@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
61:axiom core.f64.F64.INFINITY : Result F64
68:axiom core.f64.F64.NEG_INFINITY : Result F64
75:axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
82:axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
101:axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
108:axiom core.f64.F64.to_bits : F64 → Result Std.U64
115:axiom core.f64.F64.from_bits : Std.U64 → Result F64
138:axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
144:def F64.Insts.CoreOpsArithMulF64F64 : core.ops.arith.Mul F64 F64 F64 := {
145: mul := F64.Insts.CoreOpsArithMulF64F64.mul
162:axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
168:def F64.Insts.CoreOpsArithDivF64F64 : core.ops.arith.Div F64 F64 F64 := {
169: div := F64.Insts.CoreOpsArithDivF64F64.div
185:axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
191:def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
192: neg := F64.Insts.CoreOpsArithNegF64.neg
200:axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
207:def U64.Insts.CoreOpsBitBitAndU64U64 : core.ops.bit.BitAnd Std.U64 Std.U64
209: bitand := U64.Insts.CoreOpsBitBitAndU64U64.bitand
226:axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
233:def U64.Insts.CoreOpsBitBitOrU64U64 : core.ops.bit.BitOr Std.U64 Std.U64
235: bitor := U64.Insts.CoreOpsBitBitOrU64U64.bitor
252:axiom U64.Insts.CoreOpsBitShlU32U64.shl
259:def U64.Insts.CoreOpsBitShlU32U64 : core.ops.bit.Shl Std.U64 Std.U32 Std.U64
261: shl := U64.Insts.CoreOpsBitShlU32U64.shl
278:axiom U64.Insts.CoreOpsBitShrU32U64.shr
285:def U64.Insts.CoreOpsBitShrU32U64 : core.ops.bit.Shr Std.U64 Std.U32 Std.U64
287: shr := U64.Insts.CoreOpsBitShrU32U64.shr
393: let i ← lift (a ||| b)
394: let i1 ← lift (i &&& 9259542123273814144#u64)
635: coreopsbitShrSelfU32SelfInst : core.ops.bit.Shr Self Std.U32 Self
636: coreopsbitShlSelfU32SelfInst : core.ops.bit.Shl Self Std.U32 Self
637: coreopsbitBitAndInst : core.ops.bit.BitAnd Self Self Self
638: coreopsbitBitOrInst : core.ops.bit.BitOr Self Self Self
664: coreopsarithDivInst : core.ops.arith.Div Self Self Self
665: coreopsarithNegInst : core.ops.arith.Neg Self Self
666: coreopsarithMulInst : core.ops.arith.Mul Self Self Self
726: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
727: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
728: (coreopsarithNegInst : core.ops.arith.Neg F F)
739: let value ← LemireInst.from_u64 self.mantissa
746: let t ← LemireInst.pow10_fast_path i2
747: coreopsarithDivInst.div value t
751: let t ← LemireInst.pow10_fast_path i1
752: coreopsarithMulInst.mul value t
754: then let t ← coreopsarithNegInst.neg value1
769: let t ← LemireInst.from_u64 val
771: let t1 ← LemireInst.pow10_fast_path i4
772: let value ← coreopsarithMulInst.mul t t1
774: then let t2 ← coreopsarithNegInst.neg value
1018: let i5 ← lift (1#u8 &&& i4)
1219: let shift1 ← lift (shift &&& 63#usize)
1228: let i1 ← x_a >>> 11#i32
1230: let i2 ← lift (2047#u16 &&& x_a)
1232: let i3 ← lift (2047#u16 &&& x_b)
1264: let i2 ← i1 <<< shift
1370: let i ← n >>> shift
1400: let i ← n >>> shift
1451: let i1 ← n >>> shift
1453: let i2 ← lift (n &&& mask)
1490: let i ← n >>> shift
1492: let i1 ← lift (n &&& mask)
1544: let i4 ← 1#u64 <<< shift
1704: let i3 ← 1#i64 <<< 59#i32
2971: let i3 ← r >>> 64#i32
2990: then 18446744073709551615#u64 >>> precision
3000: let i4 ← lift (first_hi &&& mask)
3016: let i2 ← i1 >>> 16#i32
3028: let i ← traitsFloatInst.INFINITE_POWER
3045: let w1 ← w <<< lz
3046: let i5 ← traitsFloatInst.SIG_BITS
3058: let i8 ← hi >>> 63#i32
3064: let mantissa ← hi >>> i12
3070: let i18 ← traitsFloatInst.EXP_MIN
3081: let mantissa1 ← mantissa >>> i22
3082: let i23 ← lift (mantissa1 &&& 1#u64)
3084: let mantissa3 ← mantissa2 >>> 1#i32
3085: let i24 ← 1#u64 <<< i5
3102: let i24 ← lift (mantissa &&& 3#u64)
3108: let i28 ← mantissa <<< i27
3111: ok (mantissa &&& i29)
3117: let i20 ← lift (mantissa1 &&& 1#u64)
3119: let mantissa3 ← mantissa2 >>> 1#i32
3120: let i21 ← 2#u64 <<< i5
3125: let mantissa5 ← 1#u64 <<< i5
3129: let i22 ← 1#u64 <<< i5
3131: let mantissa5 ← lift (mantissa4 &&& i23)
3137: let i8 ← hi >>> 63#i32
3143: let mantissa ← hi >>> i12
3149: let i18 ← traitsFloatInst.EXP_MIN
3160: let mantissa1 ← mantissa >>> i22
3161: let i23 ← lift (mantissa1 &&& 1#u64)
3163: let mantissa3 ← mantissa2 >>> 1#i32
3164: let i24 ← 1#u64 <<< i5
3181: let i24 ← lift (mantissa &&& 3#u64)
3187: let i28 ← mantissa <<< i27
3190: ok (mantissa &&& i29)
3196: let i20 ← lift (mantissa1 &&& 1#u64)
3198: let mantissa3 ← mantissa2 >>> 1#i32
3199: let i21 ← 2#u64 <<< i5
3204: let mantissa5 ← 1#u64 <<< i5
3208: let i22 ← 1#u64 <<< i5
3210: let mantissa5 ← lift (mantissa4 &&& i23)
3232: let i ← LemireInst.traitsFloatExtInst.FloatInst.SIG_TOTAL_BITS
3233: 1#u64 <<< i
3240: let bits ← core.f64.F64.to_bits self
3241: let i ← bits >>> 63#i32
3245: let i1 ← core.f64.F64.EXPONENT_MASK
3246: let i2 ← lift (bits &&& i1)
3247: let i3 ← i2 >>> 52#i32
3253: let i4 ← core.f64.F64.MANTISSA_MASK
3254: let i5 ← lift (bits &&& i4)
3255: i5 <<< 1#i32
3258: let i4 ← core.f64.F64.MANTISSA_MASK
3259: let i5 ← lift (bits &&& i4)
3260: let i6 ← 1#u64 <<< 52#i32
3261: ok (i5 ||| i6)
3269:def F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3271: core.f64.F64.from_bits v
3278: core.f64.F64.classify self
3285: core.f64.F64.to_bits self
3324: core.f64.F64.MANTISSA_MASK
3331: core.f64.F64.EXPONENT_MASK
3339: core.f64.F64.MANTISSA_DIGITS
3352: core.f64.F64.from_bits 18444492273895866368#u64
3359: core.f64.F64.NAN
3366: core.f64.F64.NEG_INFINITY
3373: core.f64.F64.INFINITY
3381: let i ← FloatInst.EXP_BIAS
3392: let i ← FloatInst.EXP_SAT
3393: i >>> 1#i32
3402: let i ← FloatInst.EXP_SAT
3411: let i ← FloatInst.EXP_BITS
3412: let i1 ← 1#u32 <<< i
3422: let i1 ← FloatInst.SIG_BITS
3432: let i ← FloatInst.SIG_TOTAL_BITS
3471: coreopsbitShrSelfU32SelfInst := U64.Insts.CoreOpsBitShrU32U64
3472: coreopsbitShlSelfU32SelfInst := U64.Insts.CoreOpsBitShlU32U64
3473: coreopsbitBitAndInst := U64.Insts.CoreOpsBitBitAndU64U64
3474: coreopsbitBitOrInst := U64.Insts.CoreOpsBitBitOrU64U64
3512: coreopsarithDivInst := F64.Insts.CoreOpsArithDivF64F64
3513: coreopsarithNegInst := F64.Insts.CoreOpsArithNegF64
3514: coreopsarithMulInst := F64.Insts.CoreOpsArithMulF64F64
3529: from_u64_bits := F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3537:axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3543:def F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3545: let i ← lift (exponent &&& 31#usize)
3547: | 0 => core.f64.F64.from_bits 4607182418800017408#u64
3548: | 1 => core.f64.F64.from_bits 4621819117588971520#u64
3549: | 2 => core.f64.F64.from_bits 4636737291354636288#u64
3550: | 3 => core.f64.F64.from_bits 4652007308841189376#u64
3551: | 4 => core.f64.F64.from_bits 4666723172467343360#u64
3552: | 5 => core.f64.F64.from_bits 4681608360884174848#u64
3553: | 6 => core.f64.F64.from_bits 4696837146684686336#u64
3554: | 7 => core.f64.F64.from_bits 4711630319722168320#u64
3555: | 8 => core.f64.F64.from_bits 4726483295884279808#u64
3556: | 9 => core.f64.F64.from_bits 4741671816366391296#u64
3557: | 10 => core.f64.F64.from_bits 4756540486875873280#u64
3558: | 11 => core.f64.F64.from_bits 4771362005757984768#u64
3559: | 12 => core.f64.F64.from_bits 4786511204640096256#u64
3560: | 13 => core.f64.F64.from_bits 4801453603149578240#u64
3561: | 14 => core.f64.F64.from_bits 4816244402031689728#u64
3562: | 15 => core.f64.F64.from_bits 4831355200913801216#u64
3563: | 16 => core.f64.F64.from_bits 4846369599423283200#u64
3564: | 17 => core.f64.F64.from_bits 4861130398305394688#u64
3565: | 18 => core.f64.F64.from_bits 4876203697187506176#u64
3566: | 19 => core.f64.F64.from_bits 4891288408196988160#u64
3567: | 20 => core.f64.F64.from_bits 4906019910204099648#u64
3568: | 21 => core.f64.F64.from_bits 4921056587992461136#u64
3569: | 22 => core.f64.F64.from_bits 4936209963552724370#u64
3570: | _ => core.f64.F64.from_bits 0#u64
3606: F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3607: from_u64 := F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3643: let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
3644: let i2 ← i <<< i1
3645: let word ← lift (x.m ||| i2)
3646: traitsFloatExtInst.from_u64_bits word
3903: let i ← traitsFloatInst.EXP_MIN
3939: let i ← traitsFloatInst.INFINITE_POWER
3971: let i5 ← traitsFloatInst.EXP_MIN
3977: let i8 ← traitsFloatInst.SIG_BITS
3984: let i12 ← 1#u64 <<< i11
3999: let i16 ← 1#u64 <<< i8
4004: let i17 ← 1#u64 <<< i8
4006: let mantissa2 ← lift (mantissa1 &&& i18)
4011: let i14 ← 1#u64 <<< i8
4016: let i15 ← 1#u64 <<< i8
4018: let mantissa1 ← lift (mantissa &&& i16)
4035: let register1 ← lift (register &&& 16131858542891098079#u64)
4039: let float ← traitsFloatInst.INFINITY
4041: then let t ← traitsFloatInst.coreopsarithNegInst.neg float
4056: let i5 ← c <<< 16#i32
4057: let i6 ← b <<< 8#i32
4058: let i7 ← lift (i5 ||| i6)
4059: let register ← lift (i7 ||| a)
4060: let register1 ← lift (register &&& 16131858542891098079#u64)
4063: let float ← traitsFloatInst.INFINITY
4066: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4071: let float ← traitsFloatInst.NAN
4074: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4237: let i1 ← v1 >>> 8#i32
4239: let i2 ← lift (v2 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4243: let i3 ← v2 >>> 16#i32
4244: let i4 ← lift (i3 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4249: let i6 ← i5 >>> 32#i32
4561: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4562: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4563: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4611: coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
4656: let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
4657: let i2 ← i <<< i1
4658: let assembled_word ← lift (selected_pair.m ||| i2)
4664: let result ← coreopsarithNegInst.neg assembly_result
4731: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4732: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4733: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4737: num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
4738: coreopsarithMulInst coreopsarithNegInst s
STDERR:
(empty)
Rust inventory is a complete operation-syntax superset, including generic and scalar forms;
trait bounds, comments and non-U64 integer operations are included, not silently omitted.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n '<<|>>|[&|]|Neg::neg|Div::div|Mul::mul|from_u64|pow10_fast_path|SIG_BITS|SIG_TOTAL_BITS|F::NAN|F::INFINITY|Some\(-float\)' crate/traits.rs crate/dec2flt
EXIT: 0
STDOUT:
crate/traits.rs:95: const SIG_TOTAL_BITS: u32;
crate/traits.rs:101: const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
crate/traits.rs:104: const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
crate/traits.rs:110: const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
crate/traits.rs:116: const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
crate/traits.rs:137: /// (in the 32-bit case). In both cases,the power of five(5^|q|)
crate/traits.rs:172: fn from_u64_bits(v: u64) -> Self;
crate/traits.rs:177: /// exponent will be `-(EXP_BIAS + SIG_BITS)`, which is the minimum subnormal power. For
crate/traits.rs:178: /// infinity or NaN, the exponent will be `EXP_SAT - EXP_BIAS - SIG_BITS`.
crate/traits.rs:204: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:229: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:230: Self::from_bits((v & 0xFFFF) as u16)
crate/traits.rs:238: let sign = if bits >> 15 == 0 { 1 } else { -1 };
crate/traits.rs:239: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
crate/traits.rs:241: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:243: (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
crate/traits.rs:264: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:288: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:289: f32::from_bits((v & 0xFFFFFFFF) as u32)
crate/traits.rs:297: let sign = if bits >> 31 == 0 { 1 } else { -1 };
crate/traits.rs:298: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
crate/traits.rs:300: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:302: (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
crate/traits.rs:320: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:341: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:350: let sign = if bits >> 63 == 0 { 1 } else { -1 };
crate/traits.rs:351: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
crate/traits.rs:353: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:355: (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
crate/dec2flt/common.rs:10: fn read_u64(&self) -> u64;
crate/dec2flt/common.rs:13: fn write_u64(&mut self, value: u64);
crate/dec2flt/common.rs:16: fn offset_from(&self, other: &Self) -> isize;
crate/dec2flt/common.rs:22: fn read_u64(&self) -> u64 {
crate/dec2flt/common.rs:24: tmp.copy_from_slice(&self[..8]);
crate/dec2flt/common.rs:29: fn write_u64(&mut self, value: u64) {
crate/dec2flt/common.rs:30: self[..8].copy_from_slice(&value.to_le_bytes())
crate/dec2flt/common.rs:34: fn offset_from(&self, other: &Self) -> isize {
crate/dec2flt/common.rs:47: (a | b) & 0x8080_8080_8080_8080 == 0
crate/dec2flt/mod.rs:116: /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:120: /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:124: /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
crate/dec2flt/mod.rs:127: /// Maximum mantissa for the fast-path (`1 << 53` for f64).
crate/dec2flt/mod.rs:128: const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
crate/dec2flt/mod.rs:131: fn pow10_fast_path(exponent: usize) -> Self;
crate/dec2flt/mod.rs:137: fn from_u64(v: u64) -> Self;
crate/dec2flt/mod.rs:147: // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
crate/dec2flt/mod.rs:153: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:157: match exponent & 7 {
crate/dec2flt/mod.rs:172: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:183: // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
crate/dec2flt/mod.rs:187: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:190: match exponent & 15 {
crate/dec2flt/mod.rs:211: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:218: // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
crate/dec2flt/mod.rs:222: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:226: match exponent & 31 {
crate/dec2flt/mod.rs:263: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:284: word |= (x.p_biased as u64) << F::SIG_BITS;
crate/dec2flt/mod.rs:285: F::from_u64_bits(word)
crate/dec2flt/mod.rs:299: SignOnly { body: &'a [u8], negative: bool },
crate/dec2flt/mod.rs:302: body: &'a [u8],
crate/dec2flt/mod.rs:309: body: &'a [u8],
crate/dec2flt/mod.rs:317: body: &'a [u8],
crate/dec2flt/mod.rs:330: pub body: &'a [u8],
crate/dec2flt/mod.rs:362: s: &'a str,
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
crate/dec2flt/mod.rs:369: if c == b'-' || c == b'+' {
crate/dec2flt/mod.rs:370: body = &body[1..];
crate/dec2flt/mod.rs:431: // occur exactly when `many_digits && fp.p_biased >= 0`.
crate/dec2flt/mod.rs:432: let second_compute_guard = num.many_digits && fp.p_biased >= 0;
crate/dec2flt/mod.rs:468: let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
crate/dec2flt/mod.rs:472: core::ops::Neg::neg(assembly_result)
crate/dec2flt/mod.rs:514: s: &str,
crate/dec2flt/fpu.rs:31: /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
crate/dec2flt/fpu.rs:32: /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
crate/dec2flt/fpu.rs:33: /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
crate/dec2flt/fpu.rs:52: in(reg) &cw,
crate/dec2flt/fpu.rs:76: in(reg) &mut cw,
crate/dec2flt/fpu.rs:83: set_cw((cw & 0xFCFF) | cw_precision);
crate/dec2flt/fpu.rs:89: fn drop(&mut self) {
crate/dec2flt/decimal.rs:42: fn can_use_fast_path<F: Lemire>(&self) -> bool {
crate/dec2flt/decimal.rs:44: && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
crate/dec2flt/decimal.rs:45: && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
crate/dec2flt/decimal.rs:46: && !self.many_digits
crate/dec2flt/decimal.rs:65: &self,
crate/dec2flt/decimal.rs:84: let value = F::from_u64(self.mantissa);
crate/dec2flt/decimal.rs:88: core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
crate/dec2flt/decimal.rs:90: core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
crate/dec2flt/decimal.rs:99: core::ops::Mul::mul(
crate/dec2flt/decimal.rs:100: F::from_u64(mantissa),
crate/dec2flt/decimal.rs:101: F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
crate/dec2flt/decimal.rs:106: Some(core::ops::Neg::neg(value))
crate/dec2flt/decimal_seq.rs:74: pub(super) fn try_add_digit(&mut self, digit: u8) {
crate/dec2flt/decimal_seq.rs:83: pub fn trim(&mut self) {
crate/dec2flt/decimal_seq.rs:92: while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
crate/dec2flt/decimal_seq.rs:97: pub(super) fn round(&self) -> u64 {
crate/dec2flt/decimal_seq.rs:98: if self.num_digits == 0 || self.decimal_point < 0 {
crate/dec2flt/decimal_seq.rs:118: if self.digits[dp] == 5 && dp + 1 == self.num_digits {
crate/dec2flt/decimal_seq.rs:119: round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
crate/dec2flt/decimal_seq.rs:130: pub(super) fn left_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:142: n += (self.digits[read_index] as u64) << shift;
crate/dec2flt/decimal_seq.rs:176: pub(super) fn right_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:181: while (n >> shift) == 0 && !all_zero {
crate/dec2flt/decimal_seq.rs:191: while (n >> shift) == 0 {
crate/dec2flt/decimal_seq.rs:209: let mask = (1_u64 << shift) - 1;
crate/dec2flt/decimal_seq.rs:211: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:212: n = (10 * (n & mask)) + self.digits[read_index] as u64;
crate/dec2flt/decimal_seq.rs:218: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:219: n = 10 * (n & mask);
crate/dec2flt/decimal_seq.rs:236:fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
crate/dec2flt/decimal_seq.rs:240: while i != 0 && scanning {
crate/dec2flt/decimal_seq.rs:242: if c == b'0' || c == b'.' {
crate/dec2flt/decimal_seq.rs:254:// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
crate/dec2flt/decimal_seq.rs:257:fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
crate/dec2flt/decimal_seq.rs:259: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/decimal_seq.rs:264: &s[count..]
crate/dec2flt/decimal_seq.rs:288:pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
crate/dec2flt/decimal_seq.rs:296: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:297: s = &s[1..];
crate/dec2flt/decimal_seq.rs:300: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:302: if !s.is_empty() && s[0] == b'.' {
crate/dec2flt/decimal_seq.rs:303: s = &s[1..];
crate/dec2flt/decimal_seq.rs:309: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:310: s = &s[1..];
crate/dec2flt/decimal_seq.rs:313: while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
crate/dec2flt/decimal_seq.rs:320: s = &s[8..];
crate/dec2flt/decimal_seq.rs:322: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:350: if ch == b'e' || ch == b'E' {
crate/dec2flt/decimal_seq.rs:362: let mut exponent_suffix = &s[1..];
crate/dec2flt/decimal_seq.rs:363: explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
crate/dec2flt/decimal_seq.rs:375:fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
crate/dec2flt/decimal_seq.rs:433: shift &= 63;
crate/dec2flt/decimal_seq.rs:436: let num_new_digits = (x_a >> 11) as _;
crate/dec2flt/decimal_seq.rs:437: let pow5_a = (0x7FF & x_a) as usize;
crate/dec2flt/decimal_seq.rs:438: let pow5_b = (0x7FF & x_b) as usize;
crate/dec2flt/decimal_seq.rs:439: let pow5 = &TABLE_POW5[pow5_a..];
crate/dec2flt/decimal_seq.rs:441: for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
crate/dec2flt/lemire.rs:32: if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
crate/dec2flt/lemire.rs:39: w <<= lz;
crate/dec2flt/lemire.rs:40: let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
crate/dec2flt/lemire.rs:57: let inside_safe_exponent = (q >= -27) && (q <= 55);
crate/dec2flt/lemire.rs:62: let upperbit = (hi >> 63) as i32;
crate/dec2flt/lemire.rs:63: let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
crate/dec2flt/lemire.rs:71: mantissa >>= -power2 + 1;
crate/dec2flt/lemire.rs:72: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:73: mantissa >>= 1;
crate/dec2flt/lemire.rs:74: power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
crate/dec2flt/lemire.rs:89: && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:90: && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:91: && mantissa & 0b11 == 0b01
crate/dec2flt/lemire.rs:92: && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
crate/dec2flt/lemire.rs:95: mantissa &= !1_u64;
crate/dec2flt/lemire.rs:98: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:99: mantissa >>= 1;
crate/dec2flt/lemire.rs:100: if mantissa >= (2_u64 << F::SIG_BITS) {
crate/dec2flt/lemire.rs:104: mantissa = 1_u64 << F::SIG_BITS;
crate/dec2flt/lemire.rs:108: mantissa &= !(1_u64 << F::SIG_BITS);
crate/dec2flt/lemire.rs:122: (q.wrapping_mul(152_170 + 65536) >> 16) + 63
crate/dec2flt/lemire.rs:128: (r as u64, (r >> 64) as u64)
crate/dec2flt/lemire.rs:140: 0xFFFF_FFFF_FFFF_FFFF_u64 >> precision
crate/dec2flt/lemire.rs:155: if first_hi & mask == mask {
crate/dec2flt/slow.rs:27:pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
crate/dec2flt/slow.rs:33: let get_shift = |n| {
crate/dec2flt/slow.rs:43: if d.num_digits == 0 || d.decimal_point < -324 {
crate/dec2flt/slow.rs:51: while d.decimal_point > 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:69: while d.decimal_point <= 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:73: 0 | 1 => 2,
crate/dec2flt/slow.rs:107: d.left_shift(F::SIG_BITS as usize + 1);
crate/dec2flt/slow.rs:109: if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
crate/dec2flt/slow.rs:120: if mantissa < (1_u64 << F::SIG_BITS) {
crate/dec2flt/slow.rs:124: mantissa &= (1_u64 << F::SIG_BITS) - 1;
crate/dec2flt/parse.rs:23: v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
crate/dec2flt/parse.rs:24: let v1 = (v & MASK).wrapping_mul(MUL1);
crate/dec2flt/parse.rs:25: let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
crate/dec2flt/parse.rs:26: ((v1.wrapping_add(v2) >> 32) as u32) as u64
crate/dec2flt/parse.rs:30:fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
crate/dec2flt/parse.rs:40: s = &s[8..];
crate/dec2flt/parse.rs:50: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:55: s = &s[count..];
crate/dec2flt/parse.rs:61:fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
crate/dec2flt/parse.rs:86:fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
crate/dec2flt/parse.rs:89: while scan_index < start.len() && scanning {
crate/dec2flt/parse.rs:91: if c == b'.' || c == b'0' {
crate/dec2flt/parse.rs:104:fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
crate/dec2flt/parse.rs:107: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:111: s = &s[1..];
crate/dec2flt/parse.rs:113: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:121:pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:129: if c == b'-' || c == b'+' {
crate/dec2flt/parse.rs:137: if !s.is_empty() && s[0].is_ascii_digit() {
crate/dec2flt/parse.rs:145: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:147: if exponent < (1_i64 << 59) {
crate/dec2flt/parse.rs:152: *s_ref = &s[count..];
crate/dec2flt/parse.rs:164:fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:198: if c == b'e' || c == b'E' {
crate/dec2flt/parse.rs:201: exp_number = parse_scientific(&mut s)?;
crate/dec2flt/parse.rs:234:pub fn parse_number(s: &[u8]) -> Option<Decimal> {
crate/dec2flt/parse.rs:244:pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
crate/dec2flt/parse.rs:260: register = (c << 16) | (b << 8) | a;
crate/dec2flt/parse.rs:269: register &= 0xDFDFDFDFDFDFDFDF;
crate/dec2flt/parse.rs:280: (INF_3, 3) => F::INFINITY,
crate/dec2flt/parse.rs:281: (INF_8, 8) => F::INFINITY,
crate/dec2flt/parse.rs:282: (NAN, 3) => F::NAN,
crate/dec2flt/parse.rs:286: if negative { Some(-float) } else { Some(float) }
STDERR:
(empty)
Current guarded native body, exact f64 boundary and unrestricted assembler:
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 39,111p crate/dec2flt/decimal.rs
EXIT: 0
STDOUT:
impl Decimal {
/// Detect if the float can be accurately reconstructed from native floats.
#[inline]
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
/// Try turning the decimal into an exact float representation, using machine-sized integers
/// and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
/// can be exactly represented as a machine float, since IEE-754 guarantees
/// no rounding will occur.
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
pub fn try_fast_path<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
&self,
) -> Option<F> {
// `Lemire` already entails these three operator bounds through
// `Float`; spelling them directly changes no admitted type. Charon
// needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
// The `set_precision` function takes care of setting the precision on architectures which
// require setting it by changing the global state (like the control word of the x87 FPU).
let _cw = set_precision::<F>();
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 112,138p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
///
/// Not intended for use outside of the `dec2flt` module.
#[doc(hidden)]
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
/// Gets a small power-of-ten for fast-path multiplication.
fn pow10_fast_path(exponent: usize) -> Self;
/// Converts integer into float through an as cast.
/// This is only called in the fast-path algorithm, and therefore
/// will not lose precision, since the value will always have
/// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
fn from_u64(v: u64) -> Self;
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 217,286p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
impl Lemire for f64 {
// Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
#[inline]
pub(super) fn pfe_empty() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Empty }
}
// Used in unit tests, keep public.
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
#[inline]
pub fn pfe_invalid() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Invalid }
}
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 315,365p crate/traits.rs
EXIT: 0
STDOUT:
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
// Exact value of trunc(1024 / log2(10)) from the upstream default.
const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
// This is the upstream default after substituting `Self::Int = u64`;
// it preserves every decoded field while avoiding unsupported generic
// associated-integer operator resolution.
fn integer_decode(self) -> (u64, i16, i8) {
let bits = self.to_bits();
let sign = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
let mantissa = if exponent == 0 {
(bits & Self::MANTISSA_MASK) << 1
} else {
(bits & Self::MANTISSA_MASK) | (1_u64 << 52)
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 245,291p crate/dec2flt/parse.rs
EXIT: 0
STDOUT:
// Since a valid string has at most the length 8, we can load
// all relevant characters into a u64 and work from there.
// This also generates much better code.
let mut register;
let len: usize;
// All valid strings are either of length 8 or 3.
if s.len() == 8 {
register = s.read_u64();
len = 8;
} else if s.len() == 3 {
let a = s[0] as u64;
let b = s[1] as u64;
let c = s[2] as u64;
register = (c << 16) | (b << 8) | a;
len = 3;
} else {
return None;
}
// Clear out the bits which turn ASCII uppercase characters into
// lowercase characters. The resulting string is all uppercase.
// What happens to other characters is irrelevant.
register &= 0xDFDFDFDFDFDFDFDF;
// u64 values corresponding to relevant cases
const INF_3: u64 = 0x464E49; // "INF"
const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
const NAN: u64 = 0x4E414E; // "NAN"
// Match register value to constant to parse string.
// Also match on the string length to catch edge cases
// like "inf\0\0\0\0\0".
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
}
STDERR:
(empty)
Fresh constant and symbolic-negation reproduction
=================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C opt-level=0 reference/model-evidence/binary64-probe.rs -o .trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
; ModuleID = 'binary64_negation_probe.566fd6d762029c-cgu.0'
source_filename = "binary64_negation_probe.566fd6d762029c-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 7, !"uwtable", i32 2}
!3 = !{!"rustc version 1.98.0-nightly (14210df0e 2026-05-31)"}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
.file "binary64_negation_probe.566fd6d762029c-cgu.0"
.section .text.neg_f64_trait_bits,"ax",@progbits
.globl neg_f64_trait_bits
.p2align 4
.type neg_f64_trait_bits,@function
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
.Lfunc_end0:
.size neg_f64_trait_bits, .Lfunc_end0-neg_f64_trait_bits
.cfi_endproc
.ident "rustc version 1.98.0-nightly (14210df0e 2026-05-31)"
.section ".note.GNU-stack","",@progbits
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum .trellis/scratch/binary64-probe .trellis/scratch/binary64-negation-probe.ll .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322 .trellis/scratch/binary64-probe
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
STDERR:
(empty)
Fresh checked-shift reproduction and full dynamic-count MIR
===========================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shl-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir ../../reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shl-probe u64-shl-probe.mir
EXIT: 0
STDOUT:
1d8bda234272af0f20a360fe4ff631c8ed038f9aac02bfe539192fff86706d4c u64-shl-probe
1d05de9f3cfb93082c17a57d39f7fc0813c3fe0d3ebd0efe470b0885fba931b9 u64-shl-probe.mir
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shr-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir ../../reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shr-probe u64-shr-probe.mir
EXIT: 0
STDOUT:
1cceba3e03b755a37112c16ad347161a9732793944f34d0a740470584a08c9fc u64-shr-probe
9a72f1d018d926b3e5672c8fb473e2495a710cf4a252c7515e12d2e5009c134e u64-shr-probe.mir
STDERR:
(empty)
Interpretation and limits
=========================
The constant source really evaluates f64::NAN; its nan=7ff8000000000000 observation
fixes that pinned constant, not arbitrary arithmetic-NaN signs or payloads.
The arbitrary-u64 qualified Neg probe passes w in rdi; movabsq loads 2^63 in rax,
xorq combines them, retq returns rax, with no branch or NaN exception. Its XOR law
holds for all 2^64 words, including every signaling/quiet NaN payload.
The checked dynamic-count MIR establishes the whole U64 x U32 branch condition,
not merely seven runtime samples: counts <64 shift, counts >=64 fail, without masking.
AND/OR remain exact over all words. from_u64 still asserts <=2^53 before casting;
the ordinary source guard gives -22<=exponent<=22, mantissa<=2^53, !many_digits.
The disguised source arm checks its integer product and <=2^53 before the cast,
and uses fixed table index 22. Only then may conditional Binary64NativeCallDomain
supply finite non-NaN cast/table operands and a positive nonzero divisor.
Thus reached native arithmetic is exact; generic arithmetic NaNs retain permitted-choice
semantics, not universal exact-bit equivalence. Assembly admits every BiasedFp field pair.
Equal-target preservation retains both rounding relations to the same target, without
deriving uniqueness from vocabulary or assuming an unresolved GOAL conclusion.
All 32 original GOALs remain pursued with their own quantifiers, domains and polarity.
These source-facing checks are evidence, not preservation Sound certification or GOAL proofs.
Managed checks and final scope verification
===========================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py compose-native . --check
EXIT: 0
Selected raw result fields:
{
"full_result": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/compose-native-1791584636440554217.json",
"matches": true,
"changed": false,
"mismatched_files": [],
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
COMMAND: python3 .trellis/scripts/check.py model-support-check .
EXIT: 0
Raw result:
{"ok": true, "errors": []}
COMMAND: python3 .trellis/scripts/check.py tablet . --json
EXIT: 0
Structured projection from the final full managed JSON result:
{
"command": [
"python3",
".trellis/scripts/check.py",
"tablet",
".",
"--json"
],
"exit_status": 0,
"ok": true,
"errors": [],
"node_count": 340,
"all_nodes_compile": true,
"elaboration_failures": [],
"structure_failures": [],
"warning_count": 696,
"warning_examples": [
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:364:4: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:587:8: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/StringIter.lean:13:4: declaration uses `sorry`"
],
"raw_stdout_sha256": "15a1d03a085481d315bcc1a4716aa174475f03e72d8f452f5f33d45a71f5ed91",
"stderr_line_count": 340,
"raw_stderr_sha256": "50c8fde0aef24c1b87ce95c51d21794927d6abba46d90fd04a8d3a714bfed46e"
}
This final command was captured and summarized by
python3 .trellis/scratch/managed-tablet-summary.py (exit 0).
Two earlier identical whole-Tablet checks also exited 0; one jq projection
reported tablet_exit=0 jq_exit=0, node_count=340, failing_elaboration=[],
invalid_structure=[]. The first tool preview truncated its verbose JSON;
that truncation was not used as a proof-closure certificate. The retained
warnings include permitted principal GOAL sketches and installed Aeneas
Slice/StringIter sorry warnings. No definition was supplied with sorry.
These checks establish elaboration, structure and composition freshness,
not preservation Sound or proof closure of the pursued GOALs.
COMMAND: python3 .trellis/scratch/preservation-scope-check.py
EXIT: 0
Raw result:
{
"ok": true,
"owner_checks": [
{
"node": "Binary64ModelDefault",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "210652331cd53e0254aae45856663c01d0552fe992b69608fe243260022ccd79"
},
{
"node": "ModelF64Neg",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "f7d74d4558333c0754ccce8f6861d1409c049fd4dfd1825daad2fd2f441eb78f"
},
{
"node": "ModelU64BitAnd",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "b401e17a058ec2909fb7a58d01f07867f03a933c2901338efebda252692ca6ff"
},
{
"node": "ModelU64BitOr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "c53e3e5ad29cc4419d07c3f2a8913e0f4df87ecbcf4ac1567a9e699a2bd18e2d"
},
{
"node": "ModelU64Shl",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "ed68845da19138d7406e8022c5a9adb765ed70c2ed075f41aea7c190dea9909a"
},
{
"node": "ModelU64Shr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "04b6ec376e7ec490c64183f2a18be832ea574391d7f24d49db7ddc10019cd2f0"
}
],
"principal_goal_pairs": [
{
"node": "AssemblyCorrespondence",
"target": "assembly_correspondence",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationDeterminism",
"target": "classification_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationSignificandDigit",
"target": "classification_significand_digit",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationTotality",
"target": "classification_totality",
"paired_files_byte_unchanged": true
},
{
"node": "ExponentValueAgreement",
"target": "exponent_value_agreement",
"paired_files_byte_unchanged": true
},
{
"node": "IntegerCorrectOrDefer",
"target": "integer_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NativeCorrectOrDefer",
"target": "native_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAcceptance",
"target": "number_helper_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAccumulatedValue",
"target": "number_helper_accumulated_value",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRecordBounds",
"target": "number_helper_record_bounds",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRejection",
"target": "number_helper_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserAccumulatedRounding",
"target": "parser_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserEqualTargetRounding",
"target": "parser_equal_target_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserExactRounding",
"target": "parser_exact_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInfinity",
"target": "parser_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInvalidRejection",
"target": "parser_invalid_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNanAcceptance",
"target": "parser_nan_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNonNanResults",
"target": "parser_non_nan_results",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericAcceptance",
"target": "parser_numeric_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericSign",
"target": "parser_numeric_sign",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserSignedZero",
"target": "parser_signed_zero",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserTotality",
"target": "parser_totality",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_SlowAccumulatedRounding",
"target": "slow_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchAbstractComposition",
"target": "dispatch_abstract_composition",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchComponentCompliance",
"target": "dispatch_component_compliance",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedExponent",
"target": "parser_selected_exponent",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedMagnitudeSign",
"target": "parser_selected_magnitude_sign",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingDeterminism",
"target": "rounding_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingTotality",
"target": "rounding_totality",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperInfinity",
"target": "special_helper_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperNan",
"target": "special_helper_nan",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperRejection",
"target": "special_helper_rejection",
"paired_files_byte_unchanged": true
}
],
"new_nodes": [],
"evidence_consumers_for_current_Sound": [
"Binary64ModelDefault",
"DecimalGoalVocabularyDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"frozen_boundary_unchanged": true,
"pre_existing_config_delta_unchanged": true,
"changed_paths_in_assigned_scope": [
"Tablet/Binary64ModelDefault.tex",
"Tablet/ModelF64Neg.tex",
"Tablet/ModelU64BitAnd.tex",
"Tablet/ModelU64BitOr.tex",
"Tablet/ModelU64Shl.tex",
"Tablet/ModelU64Shr.tex",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
],
"completion_meaning_audit_still_required": true
}
Delivery, acceptance and certification status
============================================
The executed kernel task is task_id=11 (worker request 118), compiler=managed,
under trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91.
Submitted scope is exactly the six owners' preservation sections and ten
reserved evidence paths listed above. No acceptance/publication outcome is
available before worker delivery; the host's real receipt must supply it.
The raw-only worker validator and a Submitted marker mean delivery, not host
acceptance, publication, preservation Sound or Modeling completion.
Keep retry-binary64-preservation-exclusively live until actual publication,
and verify-published-preservation-and-meanings live until current certification.
After publication, request current Sound on all changed evidence consumers,
including DecimalGoalVocabularyDefault's u64-shl/u64-bitor citations, and
repaired support before parents whose named gaps remain open. Do not reset
Binary64ModelDefault's genuine VerifierFail based on these worker checks.
The independent all-32 original-GOAL meaning audit remains required before
Modeling completion; a byte-unchanged pair check is not that semantic audit.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-negation-probe.rs
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
reference/model-evidence/binary64-negation.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
Primary evidence for binary64 trait negation
============================================
Scope and conclusion
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction and the
nightly-2026-06-01 toolchain fixed by modeling-input/SETUP.md and
modeling-input/manifest.json. It establishes the following statement for the
specific extracted Rust operation bound to ModelF64Neg:
For every u64 word w, including every signaling or quiet NaN payload,
to_bits(<f64 as core::ops::Neg>::neg(f64::from_bits(w)))
equals w XOR 0x8000000000000000.
Thus precisely bit 63 is toggled and every other bit is preserved. This is a
universal symbolic result, not an inference from finitely many test inputs.
Pinned identities
-----------------
The following command was run from the repository root. RROOT is the source
tree installed with the configured compiler.
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
RROOT=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
sha256sum "$R" \
"$RROOT/core/src/ops/arith.rs" \
"$RROOT/core/src/primitive_docs.rs" \
crate/dec2flt/mod.rs upstream/dec2flt/mod.rs \
generated.lean Tablet/model-support.json \
modeling-input/tool-identities.json \
reference/model-evidence/binary64-negation-probe.rs
Raw output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
modeling-input/tool-identities.json records the same rustc path and SHA-256.
The compiler reports:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Concrete core implementation
----------------------------
The following exact excerpt is core/src/ops/arith.rs:709-728 in the source
whose SHA-256 is 596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0:
macro_rules! neg_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const Neg for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> $t { -self }
}
forward_ref_unop! { impl Neg, neg for $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
The macro invocation explicitly includes f64. Its expansion is therefore the
concrete `impl Neg for f64`, with `Output = f64`, whose method body is the
primitive expression `-self`.
Frozen parser statement and primitive guarantee
------------------------------------------------
The adapted frozen parser and supplied upstream parser have identical text at
dec2flt/mod.rs:20-22. Their complete-file hashes are pinned above. The exact
three lines are:
//! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
//! process and re-apply it at the very end. This is correct in all edge cases since IEEE
//! floats are symmetric around zero, negating one simply flips the first bit.
The installed primitive documentation is pinned above by SHA-256
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5.
At primitive_docs.rs:1369-1375 it identifies f64 as binary64 and directs the
reader to the f32 documentation for the common floating-point rules:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The exact common rule at primitive_docs.rs:1256-1260 is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
This rule expressly covers unary negation and bit conversion, and expressly
distinguishes them from arithmetic NaN production. It therefore preserves the
quiet/signaling bit and every payload bit for NaNs as well as all non-sign bits
for finite values, zeros, and infinities. The parser statement identifies the
permitted sign-bit change as an actual flip in all edge cases.
Extraction and support binding
------------------------------
The frozen generated.lean, pinned above, contains this exact declaration and
trait implementation record:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
/-- Trait implementation: [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}]
Source: '/rustc/library/core/src/ops/arith.rs', lines 713:8-713:29
Name pattern: [core::ops::arith::Neg<f64, f64>] -/
@[reducible, rust_trait_impl "core::ops::arith::Neg<f64, f64>"]
def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
neg := F64.Insts.CoreOpsArithNegF64.neg
}
Thus the extracted external is the same f64 macro expansion and method body
identified above, not an abstract or different negation operation. Running
`python3 .trellis/scripts/pv_modeling.py inspect-native "$PWD"` and selecting
that declaration gives the following raw inventory fields:
name: F64.Insts.CoreOpsArithNegF64.neg
extracted_signature: : F64 → Result F64
rust_symbol: core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
raw_declaration_sha256: bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0
The raw declaration hash is independently reproduced after that inspection by:
I=$(ls -1t .trellis/scratch/inspect-native-*.json | head -n 1)
jq -j '.. | objects | select(.name? == "F64.Insts.CoreOpsArithNegF64.neg") | .source_utf8' "$I" | sha256sum
Raw output:
bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0 -
Tablet/model-support.json, whose complete-file hash is pinned above, copies all
four identity fields unchanged and binds this external to the model definition:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
Symbolic same-toolchain probe
-----------------------------
The retained probe source is:
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
The argument is an arbitrary symbolic u64. The qualified call forces the same
`Neg for f64` trait method identified by the core source and extraction. The
following exact commands use the extraction's compiler and target and retain
both optimized LLVM IR and assembly in the worker scratch directory:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-negation-probe.rs
IR=.trellis/scratch/binary64-negation-probe.ll
ASM=.trellis/scratch/binary64-negation-probe.s
"$R" --version --verbose
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir "$P" -o "$IR"
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm "$P" -o "$ASM"
sha256sum "$R" "$P" "$IR" "$ASM"
cat "$IR"
cat "$ASM"
Raw hash output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
Raw optimized LLVM IR function:
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
Raw optimized x86_64 assembly function:
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
Under the selected x86_64 C ABI, the symbolic input w arrives in %rdi and the
u64 result is returned in %rax. The loaded signed decimal constant
-9223372036854775808 has u64 bit pattern 0x8000000000000000, with bit 63 set
and every other bit clear. The emitted `xorq %rdi, %rax` therefore returns
w XOR 0x8000000000000000. There is no branch, floating-point exceptional
case, or input precondition in the emitted function.
Universal preservation conclusion
---------------------------------
The core macro and f64 instantiation connect the trait method to primitive
unary `-`; generated.lean and model-support.json connect that exact method to
ModelF64Neg. The parser source says the operation flips the sign bit in all
edge cases, while the primitive guarantee says every non-sign bit is preserved,
including the quiet/signaling and payload bits of NaNs. Finally, the symbolic
same-compiler/same-target probe makes the exact transformation explicit as XOR
with the bit-63 mask for its arbitrary u64 argument.
Because f64::from_bits accepts every one of the 2^64 u64 words and to_bits
returns the resulting raw word, the symbolic input covers the entire modeled
F64 carrier. Consequently the source result for every word is exactly the
model package's `ok` result containing that word with bit 63 toggled. This
includes both signs of zero and infinity, every finite/subnormal word, and
every possible NaN payload without canonicalization or quieting.
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/u64-bitand.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitAnd preservation evidence
================================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitAnd. The commands below were run from the repository
root on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790258751442882118.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790258751442882118.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790258751442882118.json
The exact U64 BitAnd entry in that index is:
name: U64.Insts.CoreOpsBitBitAndU64U64.bitand
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
source: /rustc/library/core/src/ops/bit.rs, lines 178:12-178:42
raw_declaration_sha256: 36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitAndU64U64.bitand") | .source_utf8' \
.trellis/scratch/inspect-native-1790258751442882118.json | sha256sum
Output:
36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line ranges are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '170,187p'
The pinned source says at lines 170-179:
macro_rules! bitand_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitAnd for $t {
type Output = $t;
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
and line 187 instantiates that implementation for u64:
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 conjunction `self & rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
--------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 105-116 and theorem at line 274 are:
def UScalar.and {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv &&& y.bv ⟩
instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where
hAnd x y := UScalar.and x y
theorem UScalar.bv_and {ty} (x y : UScalar ty) :
(x &&& y).bv = x.bv &&& y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 148-153 prove, for every width and bit index:
theorem BitVec.getElem!_and {w} (x y : BitVec w) (i : Nat) :
(x &&& y)[i]! = (x[i]! && y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_and, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.and_self]
Therefore `x &&& y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean conjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-bitor.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitOr preservation evidence
===============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitOr. The commands below were run from the repository root
on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790259866184055823.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790259866184055823.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790259866184055823.json
The exact U64 BitOr entry in that index is:
name: U64.Insts.CoreOpsBitBitOrU64U64.bitor
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
source: /rustc/library/core/src/ops/bit.rs, lines 282:12-282:41
raw_declaration_sha256: 85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitOrU64U64.bitor") | .source_utf8' \
.trellis/scratch/inspect-native-1790259866184055823.json | sha256sum
Output:
85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line range are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '274,291p'
The pinned source says at lines 274-289:
macro_rules! bitor_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitOr for $t {
type Output = $t;
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
forward_ref_binop! { impl BitOr, bitor for $t, $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
and line 291 instantiates that implementation for u64:
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 disjunction `self | rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
-------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 118-126 and theorem at line 275 are:
def UScalar.or {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv ||| y.bv ⟩
instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where
hOr x y := UScalar.or x y
theorem UScalar.bv_or {ty} (x y : UScalar ty) :
(x ||| y).bv = x.bv ||| y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 141-146 prove, for every width and bit index:
theorem BitVec.getElem!_or {w} (x y : BitVec w) (i : Nat) :
(x ||| y)[i]! = (x[i]! || y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_or, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.or_self]
Therefore `x ||| y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean disjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-shl-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x << count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shl.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shl preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shl. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a bounded U64 shift, and all U32 counts at least
64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790260978718245524.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790260978718245524.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790260978718245524.json
The exact U64 Shl entry in that fresh index is:
name: U64.Insts.CoreOpsBitShlU32U64.shl
extracted_signature: : Std.U64 → Std.U32 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
source: /rustc/library/core/src/ops/bit.rs, lines 489:12-489:41
raw_declaration_sha256: e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShlU32U64.shl") | .source_utf8' \
.trellis/scratch/inspect-native-1790260978718245524.json | sha256sum
Output:
e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d -
Thus this boundary is specifically u64 shifted by u32, and its extracted
codomain is the Aeneas Result used below to distinguish normal return from
checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '479,520p'
Lines 479-498 define the implementation macro:
macro_rules! shl_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shl<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shl(self, other: $f) -> $t {
self << other
}
}
forward_ref_binop! { impl Shl, shl for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 500-518 apply `shl_impl! { $t, u32 }` to every type in
`shl_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shl_impl_all {
($($t:ty)*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
shl_impl! { $t, u64 }
shl_impl! { $t, u128 }
shl_impl! { $t, usize }
...
)*)
}
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shl<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self << other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shl-probe.rs
with SHA-256:
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8
It places the same primitive expression `x << count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
./u64-shl-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir \
../../reference/model-evidence/u64-shl-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shl` operation and returns its bounded 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with the
expected truncation to 64 bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 17-21 and 29-31 define:
def UScalar.shiftLeft {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.shiftLeft s ⟩
else fail .integerOverflow
def UScalar.shiftLeft_UScalar {ty tys} (x : UScalar ty) (s : UScalar tys) :
Result (UScalar ty) :=
x.shiftLeft s.val
Lines 81-82 resolve the notation used by Tablet/ModelU64Shl.lean:
instance {ty0 ty1} : HShiftLeft (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftLeft x y := UScalar.shiftLeft_UScalar x y
Consequently `x <<< y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the 64-bit vector shift; at least 64 it is
exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftLeft_spec`, lines 193-205, proves the successful
branch has both equivalent bounded descriptions:
theorem UScalar.ShiftLeft_spec ... (hy : y.val < ty0.numBits) ... :
(x <<< y) ⦃ z =>
z.val = (x.val <<< y.val) % size ∧
z.bv = x.bv <<< y.val ⦄
For U64, `size` is `2^64`; hence the returned natural value is the mathematical
left shift reduced modulo `2^64`, and the returned carrier is exactly the
corresponding 64-bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 248-266 give the bit-level characterization: every result bit below
the shift count (or outside the fixed width) is false, and every in-width bit at
or above the count equals the corresponding input bit at index `i - n`:
theorem BitVec.getElem!_shiftLeft_false ...
(h : i < n ∨ w ≤ i) : (v <<< n)[i]! = false
theorem BitVec.getElem!_shiftLeft_eq ...
(h : n ≤ i ∧ i < w) : (v <<< n)[i]! = v[i - n]!
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive U64 shift. The Aeneas branch condition also succeeds and returns
`ok` of `BitVec.shiftLeft n`. `UScalar.ShiftLeft_spec` and the BitVec lemmas
identify both results as the same 64-bit word, equivalently `(x * 2^n) mod
2^64`, with discarded high bits and zero-filled low bits.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shl preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
reference/model-evidence/u64-shr-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x >> count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shr.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shr preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shr. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a logical U64 right shift, and all U32 counts at
least 64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790262316075577976.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790262316075577976.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790262316075577976.json
The exact U64 Shr entry in that fresh index is:
name: U64.Insts.CoreOpsBitShrU32U64.shr
extracted_signature: : Std.U64 -> Std.U32 -> Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
source: /rustc/library/core/src/ops/bit.rs, lines 612:12-612:41
raw_declaration_sha256: 77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 -> Std.U32 -> Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShrU32U64.shr") | .source_utf8' \
.trellis/scratch/inspect-native-1790262316075577976.json | sha256sum
Output:
77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f -
Tablet/model-support.json binds precisely this indexed declaration and
signature to dec2flt_model.ModelU64Shr. Thus the boundary is specifically u64
shifted by u32, and its extracted codomain is the Aeneas Result used below to
distinguish normal return from checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '602,641p'
Lines 602-620 define the implementation macro:
macro_rules! shr_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shr<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shr(self, other: $f) -> $t {
self >> other
}
}
forward_ref_binop! { impl Shr, shr for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 623-641 apply `shr_impl! { $t, u32 }` to every type in
`shr_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shr_impl_all {
($($t:ty)*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
shr_impl! { $t, u64 }
shr_impl! { $t, u128 }
shr_impl! { $t, usize }
...
)*)
}
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shr<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self >> other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shr-probe.rs
with SHA-256:
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee
It places the same primitive expression `x >> count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
./u64-shr-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir \
../../reference/model-evidence/u64-shr-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shr` operation and returns its logical 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with
zero-filled high bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 23-35 define:
def UScalar.shiftRight {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.ushiftRight s ⟩
else fail .integerOverflow
def UScalar.shiftRight_UScalar {ty tys} (x : UScalar ty)
(s : UScalar tys) : Result (UScalar ty) :=
x.shiftRight s.val
Lines 93-94 resolve the notation used by Tablet/ModelU64Shr.lean:
instance {ty0 ty1} : HShiftRight (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftRight x y := UScalar.shiftRight_UScalar x y
Consequently `x >>> y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the unsigned 64-bit vector shift; at least
64 it is exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftRight_spec`, lines 166-174, proves the successful
branch has both equivalent logical-shift descriptions:
theorem UScalar.ShiftRight_spec ... (hy : y.val < ty0.numBits) :
(x >>> y) ⦃ z =>
z.val = x.val >>> y.val ∧
z.bv = x.bv >>> y.val ⦄
Here natural-number `>>>` is division by `2^y.val`, so the returned numeric
value is `floor(x.val / 2^y.val)`, and the returned carrier is exactly the
unsigned shift of the fixed-width bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 268-283 give the bit-level logical zero-fill characterization. For
every result position, the total bit lookup is the input bit at the offset
position; positions whose offset is outside the 64-bit input are false:
theorem BitVec.getElem!_shiftRight {w} (v : BitVec w) (n i : Nat) :
(v >>> n)[i]! = v[n + i]!
theorem BitVec.getElem_shiftRight_false {m n : Nat} (v : BitVec m)
(hm : i < m) (h : m <= n + i) :
(v >>> n)[i]'hm = false
Together with `BitVec.getElem_shiftRight_lt`, this states that every in-range
source bit moves downward by the count and every newly exposed high bit is
zero. Because the carrier is unsigned, there is no sign extension.
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive unsigned U64 right shift. The Aeneas branch condition also
succeeds and returns `ok` of `BitVec.ushiftRight n`. `UScalar.ShiftRight_spec`
and the BitVec lemmas identify both results as the same 64-bit word,
equivalently `floor(x / 2^n)`, with every newly exposed high bit filled by zero.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shr preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:828c59712013bbc4a5fdb46a2016a1c2a2780fd900ac267ebb2ef41eb423ea05 |
| Preservation current fingerprint | preservation-v1:828c59712013bbc4a5fdb46a2016a1c2a2780fd900ac267ebb2ef41eb423ea05 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","lean_semantic_closure":"59844a6f7d5bfde463f4598d46c8abc4b4a9441985cf6f1d2eafb5abf4a49e56","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","lean_semantic_closure":"59844a6f7d5bfde463f4598d46c8abc4b4a9441985cf6f1d2eafb5abf4a49e56","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "8a4fa0963deaedd3f591bc7a9033e489a258fb5b72464421494154ee5fcf65a9",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:828c59712013bbc4a5fdb46a2016a1c2a2780fd900ac267ebb2ef41eb423ea05"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T2_current-applicability.txt",
"sha256": "aefdc935645f37c69a2c3f2e7c2fb00baad81970455148f3dbb591b0eeabced3",
"cited_by": [
"Tablet/ModelF64Neg.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation-probe.rs",
"sha256": "268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5",
"cited_by": [
"Tablet/ModelF64Neg.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation.txt",
"sha256": "e19a2cd2283c8435f6d6107d06ccc798cbba4d63f0220b32b5216e43ad071aac",
"cited_by": [
"Tablet/ModelF64Neg.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/u64-bitand.txt",
"sha256": "6a48b1a79f8a52a27fb06a0b25cda9de24f68395d66ab668ecac721806883f54",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-bitor.txt",
"sha256": "f3dadaec6c4ebc98d0d3178bf29df7436e52998b6b97e8d108ca97a6f8092e70",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl-probe.rs",
"sha256": "a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shl.txt"
]
},
{
"path": "reference/model-evidence/u64-shl.txt",
"sha256": "e4cacfd29333a91c1258524a520e849325a85a05cf50b0065ffbf91d7977f69c",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shr-probe.rs",
"sha256": "11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/u64-shr.txt",
"sha256": "c0295af2452a4748bc1a642580414acfc76285ba87b6203b6cbff7ff9924b6ad",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
}
]core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
Inspect related source (1)
- bitand · core/src/ops/bit.rs:178 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand |
|---|---|
| Recorded source | /rustc/library/core/src/ops/bit.rs |
| Lines | 178:12–178:42 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Std.U64 → Std.U64 → Result Std.U64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelU64BitAnd]
def ModelU64BitAnd (x y : Std.U64) : Result Std.U64 :=
-- BODY
ok (x &&& y)
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
inspect-native result, exact declaration and binding identities,
complete relevant call inventory, and checked unchanged toolchain and scalar
library identities are in
reference/model-evidence/P89_T2_current-applicability.txt.
That current inspection identifies this exact external as the extracted
u64--u64 BitAnd method, with result type
Result Std.U64, and records its Rust source span and raw declaration
hash. At that span the approved toolchain's u64 implementation
returns self & rhs for every pair, with no guard or failure branch.
At the pinned Aeneas revision, Std.U64 is a scalar containing exactly
a 64-bit vector, and scalar &&& constructs the vector
x.bv &&& y.bv; the pinned bit-vector lemma states that each
result bit is the Boolean conjunction of the corresponding input bits. The
binding defined here returns ok (x &&& y) unconditionally.
Consequently, for arbitrary modeled 64-bit words x and y, it succeeds and
returns exactly the same bounded 64-bit conjunction as the Rust method. No
reachability restriction is used.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelU64BitAnd · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T2_current-applicability.txt
Current applicability of reused binary64 and U64 preservation evidence
Task 11 / worker request 118; checked in the current private checkout.
All commands below ran in this assignment; EXIT records the command status.
Rust commands use LD_LIBRARY_PATH=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib
and RUSTUP_TOOLCHAIN=nightly-2026-06-01.
The managed Lean commands are recorded separately, not invoked by this script.
Reuse and scope
===============
Read-only predecessor: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002
The historical 45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
generated.lean hash belongs to that predecessor, never the current extraction.
The old primary evidence retains its original commands, raw identities and results.
Current checks below establish applicability; prior worker task 9 was rejected,
accepted=false, and its self-report is neither publication nor certification.
Only preservation sections of the six listed owners and ten reserved evidence paths
are submitted. No ordinary statement, Lean computation, GOAL pair, source, extraction,
provenance, Preamble, binding, dispatcher owner or existing config delta is edited.
No new node, route, under-model premise, GOAL decline or polarity change is proposed.
The new 2^59 exponent fold, final-point repair and A/B GOAL domains are not old semantics.
Unchanged primitive meanings are reused, not old parser correctness or old counterexamples.
{
"task_execution": {
"binding": {
"allowed_tasks": [
"ordinary",
"lean_closure"
],
"lightweight": false,
"max_timeout_seconds": 14400,
"model": "gpt-6.1-sol",
"provider": "codex",
"reasoning_effort": "xhigh",
"timeout_seconds": 14400
},
"compiler": "managed",
"profile": "sol-xhigh",
"task_id": 11,
"task_kind": "ordinary"
},
"acceptance_logic_identity": "trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91",
"parallel_scope": {
"exclusive": true,
"helper_prefixes": [
"P116_T1_"
],
"nodes": [
"Binary64ModelDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"shared_writes": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
]
}
}
Current file, compiler, configuration and library identities
============================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum GOAL.md generated.lean Tablet/model-support.json modeling-input/manifest.json modeling-input/extraction.json modeling-input/tool-identities.json modeling-input/SETUP.md modeling-input/revision-from.json crate/Cargo.toml crate/rust-toolchain.toml lean-toolchain lakefile.lean lake-manifest.json trellis.config.json reference/model-evidence/binary64-boundary.txt crate/dec2flt/common.rs crate/dec2flt/decimal.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/fpu.rs crate/dec2flt/lemire.rs crate/dec2flt/mod.rs crate/dec2flt/parse.rs crate/dec2flt/slow.rs crate/dec2flt/table.rs crate/lib.rs crate/num/imp/mod.rs crate/num/mod.rs crate/traits.rs upstream/dec2flt/common.rs upstream/dec2flt/decimal.rs upstream/dec2flt/decimal_seq.rs upstream/dec2flt/fpu.rs upstream/dec2flt/lemire.rs upstream/dec2flt/mod.rs upstream/dec2flt/parse.rs upstream/dec2flt/slow.rs upstream/dec2flt/table.rs upstream/traits.rs reference/model-evidence/binary64-probe.rs reference/model-evidence/binary64-negation-probe.rs reference/model-evidence/u64-shl-probe.rs reference/model-evidence/u64-shr-probe.rs Tablet/Binary64ModelDefault.lean Tablet/ModelF64Neg.lean Tablet/ModelU64BitAnd.lean Tablet/ModelU64BitOr.lean Tablet/ModelU64Shl.lean Tablet/ModelU64Shr.lean
EXIT: 0
STDOUT:
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
1a7d2eea7888b7bdb0421ed6bb96c5ee1e80afe8e788438cd30725f2120a2aea modeling-input/revision-from.json
10584b73664d42dc85fb009bb0783a616520c2cc05f3b0f8c64e5d5cb32e2905 crate/Cargo.toml
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
8dab550b59cec828a4ba436bc25ce9ad66547bdd7f55899b8cbf7e4f65389518 lakefile.lean
a5f9756cd42129193c0285127cddb734224e9c69686fc2de56de2c9d48ed0695 lake-manifest.json
d8fceb13f84ecbf5bf6e9fd7ecdcb061569cfabdb0079243e2eb1609d012ac02 trellis.config.json
749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e reference/model-evidence/binary64-boundary.txt
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b crate/lib.rs
df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1 crate/num/imp/mod.rs
d84067991b142196281bc0968d32634bdcdb9a3a41c2ce2fd3c344d0f61504af crate/num/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e reference/model-evidence/binary64-probe.rs
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8 reference/model-evidence/u64-shl-probe.rs
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee reference/model-evidence/u64-shr-probe.rs
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3 Tablet/Binary64ModelDefault.lean
9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2 Tablet/ModelF64Neg.lean
3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179 Tablet/ModelU64BitAnd.lean
aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f Tablet/ModelU64BitOr.lean
af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad Tablet/ModelU64Shl.lean
54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b Tablet/ModelU64Shr.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo /home/leanagent/pv_spike/tools/charon/bin/charon /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
EXIT: 0
STDOUT:
54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade /home/leanagent/pv_spike/tools/charon/bin/charon
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
STDERR:
(empty)
All installed tool hashes equal the current tool-identities.json pins.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
EXIT: 0
STDOUT:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print cfg --target x86_64-unknown-linux-gnu
EXIT: 0
STDOUT:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat crate/Cargo.toml modeling-input/extraction.json
EXIT: 0
STDOUT:
# Standalone extraction package for the supplied `core::num::dec2flt` slice.
# The package metadata and profiles select the configured environment; source
# correspondence and extraction adaptations are recorded in ../SETUP.md and
# local preservation comments.
[package]
name = "dec2flt-model"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
path = "lib.rs"
[features]
default = []
optimize_for_size = []
[profile.dev]
overflow-checks = true
[profile.release]
overflow-checks = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(target_has_reliable_f16)"] }
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
STDERR:
(empty)
Current effective tools:
{
"aeneas": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"cargo": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"charon": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"env": {
"LD_LIBRARY_PATH": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib",
"RUSTUP_TOOLCHAIN": "nightly-2026-06-01"
},
"lean": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"lean_paths": [
"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean"
],
"readonly": [
"/home/leanagent/pv_spike/tools",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages"
],
"timeouts": {
"aeneas": 3600,
"cargo": 600,
"charon": 600,
"lean": 3600
}
}
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
EXIT: 0
STDOUT:
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
EXIT: 0
STDOUT:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
100644 blob f8582928fe49a0ce75e143b46bb0a8826d7fddae backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
100644 blob d3eb5022efc22d1d6c3ac055965f612c7f2fbca9 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
100644 blob f7bc57109569cdd0fb0c3323021c73673dcfcd33 backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
100644 blob e5733a774268c8dee71bd4ba402240d151bb8cb8 backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
Predecessor pair and probe reuse checks
=======================================
Tablet/Binary64ModelDefault.lean: predecessor_sha256=03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3; whole Lean byte-identical.
Tablet/Binary64ModelDefault.tex: predecessor_sha256=57c6e9ed282cf2dd718f822c6a31255040c71b5c7531488f3951d9c4d4d8b822; ordinary NL definition byte-identical.
Tablet/ModelF64Neg.lean: predecessor_sha256=9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2; whole Lean byte-identical.
Tablet/ModelF64Neg.tex: predecessor_sha256=9d2811046df611e45e2637da57241bace75c3de5822e03126de5f1fc9faeb859; ordinary NL definition byte-identical.
Tablet/ModelU64BitAnd.lean: predecessor_sha256=3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179; whole Lean byte-identical.
Tablet/ModelU64BitAnd.tex: predecessor_sha256=db8a1445918e94fd1c11f92f1c5f218f165aec945ac2ebdeda3cc1675165f8fe; ordinary NL definition byte-identical.
Tablet/ModelU64BitOr.lean: predecessor_sha256=aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f; whole Lean byte-identical.
Tablet/ModelU64BitOr.tex: predecessor_sha256=fbbb37c3cfa81c5811869baf46671d93a6c457042f0a5bbb78ba32c26607dbe2; ordinary NL definition byte-identical.
Tablet/ModelU64Shl.lean: predecessor_sha256=af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad; whole Lean byte-identical.
Tablet/ModelU64Shl.tex: predecessor_sha256=725582880c20b16d00487e01aceb0552a39263616563280cee0d49635984beab; ordinary NL definition byte-identical.
Tablet/ModelU64Shr.lean: predecessor_sha256=54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b; whole Lean byte-identical.
Tablet/ModelU64Shr.tex: predecessor_sha256=3def4409d97d8316d4d77dc2fe01c4142219859ea9596b835ac40f83c3a18784; ordinary NL definition byte-identical.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-negation-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-negation-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shl-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shr-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
Current raw declarations and exact support bindings
===================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py inspect-native .
EXIT: 0
STDOUT:
{
"full_index": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json",
"declaration_count": 24,
"declarations": [
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 \u2192 Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 \u2192 Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 \u2192 Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 \u2192 Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 \u2192 Std.U64 \u2192 Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02"
}
],
"declarations_omitted": 9
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
EXIT: 0
STDOUT:
fbe3b76ef8fbb588841979e071c52eee0fc850472ac55da6f2ca2033e4a34cf4 /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
STDERR:
(empty)
RAW DECLARATION:
/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:
Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43
Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]
Visibility: public -/
@[rust_fun "core::clone::impls::{core::clone::Clone<f64>}::clone"]
axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dfbdb508142706b4c716f701e52a26d63d764f088dacfa461dd81c6df0b9bf0d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_DIGITS]
Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34
Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_DIGITS"]
axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 19dc0621c0c5c7d2a24f090dd7870ffa858de15fc4e1cc7bf57f16d64816c9bc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NAN]
Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22
Name pattern: [core::f64::{f64}::NAN]
Visibility: public -/
@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 75cd3ccca5992f42ef5afa9287573410d249d40f9bcc3120fae72389b2e2419d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27
Name pattern: [core::f64::{f64}::INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::INFINITY"]
axiom core.f64.F64.INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 9a5fb08a6bae926bafdba709d6da6aaad52b8f41c7dbf3e4b2a28b2bc0542716
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NEG_INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31
Name pattern: [core::f64::{f64}::NEG_INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::NEG_INFINITY"]
axiom core.f64.F64.NEG_INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f5d6435579e1da8caecfc1a3b0039a0ce4e250e7dc55c4c69f3edbdd2a5a10f6
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::EXPONENT_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32
Name pattern: [core::f64::{f64}::EXPONENT_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::EXPONENT_MASK"]
axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dcd87a62501dc8e76079204a4b43546a4750077e1f425f01dcd58c96bf31a865
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32
Name pattern: [core::f64::{f64}::MANTISSA_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_MASK"]
axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): cf1585ae2e94a7bf5bb6b5ff37a06a0677b7e8d81420c1e0ca7ee29eca8cfd4c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::classify]:
Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45
Name pattern: [core::f64::{f64}::classify]
Visibility: public -/
@[rust_fun "core::f64::{f64}::classify"]
axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
IDENTITY AND BINDING:
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 7cf497c5bfc31455d5490d5da75914d7eaf9e522aa2eccd14fe9935502b5127c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::to_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37
Name pattern: [core::f64::{f64}::to_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::to_bits"]
axiom core.f64.F64.to_bits : F64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b35203125fea8ba89df874b609344bbe8ad61a61fcb946a184a72c729a1e3364
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::from_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42
Name pattern: [core::f64::{f64}::from_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::from_bits"]
axiom core.f64.F64.from_bits : Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f819b0951f4f63943abf8d4787a2f9489ffd1137fa91529e0771a303bc8fcb94
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41
Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul"]
axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 4adead3b54aa85bfb81b7122b0e942b2c6f3d232d548d8361a2a2ca067be1e7f
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41
Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div"]
axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 62ca24414fa18ef9709d7c5703429d7262f27d017abc975ffb532ae284ba054a
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 945f30e7dbb62802e6ba5bb9d9445e100528b2a52d3b0b6a3a0629c939ff9860
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b66bd94c28f512804622c3717705dbe7ef5a3ced5beaac7435704d053038c36e
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 68909ba4060a48df31ea54bcf0510b089709a3a644c9c1b0770780a98d31f4cc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 5c0105f2c7ce3d255f053e0ccbefa65f73f65de1462832217571cf8cd4963e47
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f100256a450680392496fb74934592e9e2822a1648320153e27c1c0d100ff482
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5
Visibility: public -/
axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
: Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 0bb769d884e3d54d7aa94163fdf4c8fc589050ed84f4fa0d11f694cf599cdb8f
All four identity fields and full raw declaration equal predecessor; current binding matches.
Complete relevant call and wiring inventories
=============================================
This deliberately includes record wiring and scalar lowerings, not just direct external calls.
The four U64 external trait fields wire into Int; generic scalar notation in generated.lean
also lowers directly to the installed operations with the same full-domain meanings.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n 'F64\.Insts\.(CoreClone|CoreOpsArith)|core\.f64\.F64\.|U64\.Insts\.CoreOpsBit|coreops(bit|arith)|\.from_u64|\.pow10_fast_path|FloatInst\.(INFINITY|NEG_INFINITY|NAN|NEG_NAN|SIG_|EXP_|INFINITE_POWER)|&&&|\|\|\||<<<|>>>' generated.lean
EXIT: 0
STDOUT:
25:axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
31:def F64.Insts.CoreCloneClone : core.clone.Clone F64 := {
32: clone := F64.Insts.CoreCloneClone.clone
40: cloneInst := F64.Insts.CoreCloneClone
48:axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
54:@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
61:axiom core.f64.F64.INFINITY : Result F64
68:axiom core.f64.F64.NEG_INFINITY : Result F64
75:axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
82:axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
101:axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
108:axiom core.f64.F64.to_bits : F64 → Result Std.U64
115:axiom core.f64.F64.from_bits : Std.U64 → Result F64
138:axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
144:def F64.Insts.CoreOpsArithMulF64F64 : core.ops.arith.Mul F64 F64 F64 := {
145: mul := F64.Insts.CoreOpsArithMulF64F64.mul
162:axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
168:def F64.Insts.CoreOpsArithDivF64F64 : core.ops.arith.Div F64 F64 F64 := {
169: div := F64.Insts.CoreOpsArithDivF64F64.div
185:axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
191:def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
192: neg := F64.Insts.CoreOpsArithNegF64.neg
200:axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
207:def U64.Insts.CoreOpsBitBitAndU64U64 : core.ops.bit.BitAnd Std.U64 Std.U64
209: bitand := U64.Insts.CoreOpsBitBitAndU64U64.bitand
226:axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
233:def U64.Insts.CoreOpsBitBitOrU64U64 : core.ops.bit.BitOr Std.U64 Std.U64
235: bitor := U64.Insts.CoreOpsBitBitOrU64U64.bitor
252:axiom U64.Insts.CoreOpsBitShlU32U64.shl
259:def U64.Insts.CoreOpsBitShlU32U64 : core.ops.bit.Shl Std.U64 Std.U32 Std.U64
261: shl := U64.Insts.CoreOpsBitShlU32U64.shl
278:axiom U64.Insts.CoreOpsBitShrU32U64.shr
285:def U64.Insts.CoreOpsBitShrU32U64 : core.ops.bit.Shr Std.U64 Std.U32 Std.U64
287: shr := U64.Insts.CoreOpsBitShrU32U64.shr
393: let i ← lift (a ||| b)
394: let i1 ← lift (i &&& 9259542123273814144#u64)
635: coreopsbitShrSelfU32SelfInst : core.ops.bit.Shr Self Std.U32 Self
636: coreopsbitShlSelfU32SelfInst : core.ops.bit.Shl Self Std.U32 Self
637: coreopsbitBitAndInst : core.ops.bit.BitAnd Self Self Self
638: coreopsbitBitOrInst : core.ops.bit.BitOr Self Self Self
664: coreopsarithDivInst : core.ops.arith.Div Self Self Self
665: coreopsarithNegInst : core.ops.arith.Neg Self Self
666: coreopsarithMulInst : core.ops.arith.Mul Self Self Self
726: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
727: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
728: (coreopsarithNegInst : core.ops.arith.Neg F F)
739: let value ← LemireInst.from_u64 self.mantissa
746: let t ← LemireInst.pow10_fast_path i2
747: coreopsarithDivInst.div value t
751: let t ← LemireInst.pow10_fast_path i1
752: coreopsarithMulInst.mul value t
754: then let t ← coreopsarithNegInst.neg value1
769: let t ← LemireInst.from_u64 val
771: let t1 ← LemireInst.pow10_fast_path i4
772: let value ← coreopsarithMulInst.mul t t1
774: then let t2 ← coreopsarithNegInst.neg value
1018: let i5 ← lift (1#u8 &&& i4)
1219: let shift1 ← lift (shift &&& 63#usize)
1228: let i1 ← x_a >>> 11#i32
1230: let i2 ← lift (2047#u16 &&& x_a)
1232: let i3 ← lift (2047#u16 &&& x_b)
1264: let i2 ← i1 <<< shift
1370: let i ← n >>> shift
1400: let i ← n >>> shift
1451: let i1 ← n >>> shift
1453: let i2 ← lift (n &&& mask)
1490: let i ← n >>> shift
1492: let i1 ← lift (n &&& mask)
1544: let i4 ← 1#u64 <<< shift
1704: let i3 ← 1#i64 <<< 59#i32
2971: let i3 ← r >>> 64#i32
2990: then 18446744073709551615#u64 >>> precision
3000: let i4 ← lift (first_hi &&& mask)
3016: let i2 ← i1 >>> 16#i32
3028: let i ← traitsFloatInst.INFINITE_POWER
3045: let w1 ← w <<< lz
3046: let i5 ← traitsFloatInst.SIG_BITS
3058: let i8 ← hi >>> 63#i32
3064: let mantissa ← hi >>> i12
3070: let i18 ← traitsFloatInst.EXP_MIN
3081: let mantissa1 ← mantissa >>> i22
3082: let i23 ← lift (mantissa1 &&& 1#u64)
3084: let mantissa3 ← mantissa2 >>> 1#i32
3085: let i24 ← 1#u64 <<< i5
3102: let i24 ← lift (mantissa &&& 3#u64)
3108: let i28 ← mantissa <<< i27
3111: ok (mantissa &&& i29)
3117: let i20 ← lift (mantissa1 &&& 1#u64)
3119: let mantissa3 ← mantissa2 >>> 1#i32
3120: let i21 ← 2#u64 <<< i5
3125: let mantissa5 ← 1#u64 <<< i5
3129: let i22 ← 1#u64 <<< i5
3131: let mantissa5 ← lift (mantissa4 &&& i23)
3137: let i8 ← hi >>> 63#i32
3143: let mantissa ← hi >>> i12
3149: let i18 ← traitsFloatInst.EXP_MIN
3160: let mantissa1 ← mantissa >>> i22
3161: let i23 ← lift (mantissa1 &&& 1#u64)
3163: let mantissa3 ← mantissa2 >>> 1#i32
3164: let i24 ← 1#u64 <<< i5
3181: let i24 ← lift (mantissa &&& 3#u64)
3187: let i28 ← mantissa <<< i27
3190: ok (mantissa &&& i29)
3196: let i20 ← lift (mantissa1 &&& 1#u64)
3198: let mantissa3 ← mantissa2 >>> 1#i32
3199: let i21 ← 2#u64 <<< i5
3204: let mantissa5 ← 1#u64 <<< i5
3208: let i22 ← 1#u64 <<< i5
3210: let mantissa5 ← lift (mantissa4 &&& i23)
3232: let i ← LemireInst.traitsFloatExtInst.FloatInst.SIG_TOTAL_BITS
3233: 1#u64 <<< i
3240: let bits ← core.f64.F64.to_bits self
3241: let i ← bits >>> 63#i32
3245: let i1 ← core.f64.F64.EXPONENT_MASK
3246: let i2 ← lift (bits &&& i1)
3247: let i3 ← i2 >>> 52#i32
3253: let i4 ← core.f64.F64.MANTISSA_MASK
3254: let i5 ← lift (bits &&& i4)
3255: i5 <<< 1#i32
3258: let i4 ← core.f64.F64.MANTISSA_MASK
3259: let i5 ← lift (bits &&& i4)
3260: let i6 ← 1#u64 <<< 52#i32
3261: ok (i5 ||| i6)
3269:def F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3271: core.f64.F64.from_bits v
3278: core.f64.F64.classify self
3285: core.f64.F64.to_bits self
3324: core.f64.F64.MANTISSA_MASK
3331: core.f64.F64.EXPONENT_MASK
3339: core.f64.F64.MANTISSA_DIGITS
3352: core.f64.F64.from_bits 18444492273895866368#u64
3359: core.f64.F64.NAN
3366: core.f64.F64.NEG_INFINITY
3373: core.f64.F64.INFINITY
3381: let i ← FloatInst.EXP_BIAS
3392: let i ← FloatInst.EXP_SAT
3393: i >>> 1#i32
3402: let i ← FloatInst.EXP_SAT
3411: let i ← FloatInst.EXP_BITS
3412: let i1 ← 1#u32 <<< i
3422: let i1 ← FloatInst.SIG_BITS
3432: let i ← FloatInst.SIG_TOTAL_BITS
3471: coreopsbitShrSelfU32SelfInst := U64.Insts.CoreOpsBitShrU32U64
3472: coreopsbitShlSelfU32SelfInst := U64.Insts.CoreOpsBitShlU32U64
3473: coreopsbitBitAndInst := U64.Insts.CoreOpsBitBitAndU64U64
3474: coreopsbitBitOrInst := U64.Insts.CoreOpsBitBitOrU64U64
3512: coreopsarithDivInst := F64.Insts.CoreOpsArithDivF64F64
3513: coreopsarithNegInst := F64.Insts.CoreOpsArithNegF64
3514: coreopsarithMulInst := F64.Insts.CoreOpsArithMulF64F64
3529: from_u64_bits := F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3537:axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3543:def F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3545: let i ← lift (exponent &&& 31#usize)
3547: | 0 => core.f64.F64.from_bits 4607182418800017408#u64
3548: | 1 => core.f64.F64.from_bits 4621819117588971520#u64
3549: | 2 => core.f64.F64.from_bits 4636737291354636288#u64
3550: | 3 => core.f64.F64.from_bits 4652007308841189376#u64
3551: | 4 => core.f64.F64.from_bits 4666723172467343360#u64
3552: | 5 => core.f64.F64.from_bits 4681608360884174848#u64
3553: | 6 => core.f64.F64.from_bits 4696837146684686336#u64
3554: | 7 => core.f64.F64.from_bits 4711630319722168320#u64
3555: | 8 => core.f64.F64.from_bits 4726483295884279808#u64
3556: | 9 => core.f64.F64.from_bits 4741671816366391296#u64
3557: | 10 => core.f64.F64.from_bits 4756540486875873280#u64
3558: | 11 => core.f64.F64.from_bits 4771362005757984768#u64
3559: | 12 => core.f64.F64.from_bits 4786511204640096256#u64
3560: | 13 => core.f64.F64.from_bits 4801453603149578240#u64
3561: | 14 => core.f64.F64.from_bits 4816244402031689728#u64
3562: | 15 => core.f64.F64.from_bits 4831355200913801216#u64
3563: | 16 => core.f64.F64.from_bits 4846369599423283200#u64
3564: | 17 => core.f64.F64.from_bits 4861130398305394688#u64
3565: | 18 => core.f64.F64.from_bits 4876203697187506176#u64
3566: | 19 => core.f64.F64.from_bits 4891288408196988160#u64
3567: | 20 => core.f64.F64.from_bits 4906019910204099648#u64
3568: | 21 => core.f64.F64.from_bits 4921056587992461136#u64
3569: | 22 => core.f64.F64.from_bits 4936209963552724370#u64
3570: | _ => core.f64.F64.from_bits 0#u64
3606: F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3607: from_u64 := F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3643: let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
3644: let i2 ← i <<< i1
3645: let word ← lift (x.m ||| i2)
3646: traitsFloatExtInst.from_u64_bits word
3903: let i ← traitsFloatInst.EXP_MIN
3939: let i ← traitsFloatInst.INFINITE_POWER
3971: let i5 ← traitsFloatInst.EXP_MIN
3977: let i8 ← traitsFloatInst.SIG_BITS
3984: let i12 ← 1#u64 <<< i11
3999: let i16 ← 1#u64 <<< i8
4004: let i17 ← 1#u64 <<< i8
4006: let mantissa2 ← lift (mantissa1 &&& i18)
4011: let i14 ← 1#u64 <<< i8
4016: let i15 ← 1#u64 <<< i8
4018: let mantissa1 ← lift (mantissa &&& i16)
4035: let register1 ← lift (register &&& 16131858542891098079#u64)
4039: let float ← traitsFloatInst.INFINITY
4041: then let t ← traitsFloatInst.coreopsarithNegInst.neg float
4056: let i5 ← c <<< 16#i32
4057: let i6 ← b <<< 8#i32
4058: let i7 ← lift (i5 ||| i6)
4059: let register ← lift (i7 ||| a)
4060: let register1 ← lift (register &&& 16131858542891098079#u64)
4063: let float ← traitsFloatInst.INFINITY
4066: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4071: let float ← traitsFloatInst.NAN
4074: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4237: let i1 ← v1 >>> 8#i32
4239: let i2 ← lift (v2 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4243: let i3 ← v2 >>> 16#i32
4244: let i4 ← lift (i3 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4249: let i6 ← i5 >>> 32#i32
4561: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4562: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4563: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4611: coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
4656: let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
4657: let i2 ← i <<< i1
4658: let assembled_word ← lift (selected_pair.m ||| i2)
4664: let result ← coreopsarithNegInst.neg assembly_result
4731: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4732: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4733: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4737: num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
4738: coreopsarithMulInst coreopsarithNegInst s
STDERR:
(empty)
Rust inventory is a complete operation-syntax superset, including generic and scalar forms;
trait bounds, comments and non-U64 integer operations are included, not silently omitted.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n '<<|>>|[&|]|Neg::neg|Div::div|Mul::mul|from_u64|pow10_fast_path|SIG_BITS|SIG_TOTAL_BITS|F::NAN|F::INFINITY|Some\(-float\)' crate/traits.rs crate/dec2flt
EXIT: 0
STDOUT:
crate/traits.rs:95: const SIG_TOTAL_BITS: u32;
crate/traits.rs:101: const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
crate/traits.rs:104: const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
crate/traits.rs:110: const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
crate/traits.rs:116: const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
crate/traits.rs:137: /// (in the 32-bit case). In both cases,the power of five(5^|q|)
crate/traits.rs:172: fn from_u64_bits(v: u64) -> Self;
crate/traits.rs:177: /// exponent will be `-(EXP_BIAS + SIG_BITS)`, which is the minimum subnormal power. For
crate/traits.rs:178: /// infinity or NaN, the exponent will be `EXP_SAT - EXP_BIAS - SIG_BITS`.
crate/traits.rs:204: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:229: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:230: Self::from_bits((v & 0xFFFF) as u16)
crate/traits.rs:238: let sign = if bits >> 15 == 0 { 1 } else { -1 };
crate/traits.rs:239: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
crate/traits.rs:241: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:243: (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
crate/traits.rs:264: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:288: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:289: f32::from_bits((v & 0xFFFFFFFF) as u32)
crate/traits.rs:297: let sign = if bits >> 31 == 0 { 1 } else { -1 };
crate/traits.rs:298: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
crate/traits.rs:300: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:302: (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
crate/traits.rs:320: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:341: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:350: let sign = if bits >> 63 == 0 { 1 } else { -1 };
crate/traits.rs:351: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
crate/traits.rs:353: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:355: (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
crate/dec2flt/common.rs:10: fn read_u64(&self) -> u64;
crate/dec2flt/common.rs:13: fn write_u64(&mut self, value: u64);
crate/dec2flt/common.rs:16: fn offset_from(&self, other: &Self) -> isize;
crate/dec2flt/common.rs:22: fn read_u64(&self) -> u64 {
crate/dec2flt/common.rs:24: tmp.copy_from_slice(&self[..8]);
crate/dec2flt/common.rs:29: fn write_u64(&mut self, value: u64) {
crate/dec2flt/common.rs:30: self[..8].copy_from_slice(&value.to_le_bytes())
crate/dec2flt/common.rs:34: fn offset_from(&self, other: &Self) -> isize {
crate/dec2flt/common.rs:47: (a | b) & 0x8080_8080_8080_8080 == 0
crate/dec2flt/mod.rs:116: /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:120: /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:124: /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
crate/dec2flt/mod.rs:127: /// Maximum mantissa for the fast-path (`1 << 53` for f64).
crate/dec2flt/mod.rs:128: const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
crate/dec2flt/mod.rs:131: fn pow10_fast_path(exponent: usize) -> Self;
crate/dec2flt/mod.rs:137: fn from_u64(v: u64) -> Self;
crate/dec2flt/mod.rs:147: // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
crate/dec2flt/mod.rs:153: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:157: match exponent & 7 {
crate/dec2flt/mod.rs:172: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:183: // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
crate/dec2flt/mod.rs:187: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:190: match exponent & 15 {
crate/dec2flt/mod.rs:211: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:218: // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
crate/dec2flt/mod.rs:222: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:226: match exponent & 31 {
crate/dec2flt/mod.rs:263: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:284: word |= (x.p_biased as u64) << F::SIG_BITS;
crate/dec2flt/mod.rs:285: F::from_u64_bits(word)
crate/dec2flt/mod.rs:299: SignOnly { body: &'a [u8], negative: bool },
crate/dec2flt/mod.rs:302: body: &'a [u8],
crate/dec2flt/mod.rs:309: body: &'a [u8],
crate/dec2flt/mod.rs:317: body: &'a [u8],
crate/dec2flt/mod.rs:330: pub body: &'a [u8],
crate/dec2flt/mod.rs:362: s: &'a str,
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
crate/dec2flt/mod.rs:369: if c == b'-' || c == b'+' {
crate/dec2flt/mod.rs:370: body = &body[1..];
crate/dec2flt/mod.rs:431: // occur exactly when `many_digits && fp.p_biased >= 0`.
crate/dec2flt/mod.rs:432: let second_compute_guard = num.many_digits && fp.p_biased >= 0;
crate/dec2flt/mod.rs:468: let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
crate/dec2flt/mod.rs:472: core::ops::Neg::neg(assembly_result)
crate/dec2flt/mod.rs:514: s: &str,
crate/dec2flt/fpu.rs:31: /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
crate/dec2flt/fpu.rs:32: /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
crate/dec2flt/fpu.rs:33: /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
crate/dec2flt/fpu.rs:52: in(reg) &cw,
crate/dec2flt/fpu.rs:76: in(reg) &mut cw,
crate/dec2flt/fpu.rs:83: set_cw((cw & 0xFCFF) | cw_precision);
crate/dec2flt/fpu.rs:89: fn drop(&mut self) {
crate/dec2flt/decimal.rs:42: fn can_use_fast_path<F: Lemire>(&self) -> bool {
crate/dec2flt/decimal.rs:44: && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
crate/dec2flt/decimal.rs:45: && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
crate/dec2flt/decimal.rs:46: && !self.many_digits
crate/dec2flt/decimal.rs:65: &self,
crate/dec2flt/decimal.rs:84: let value = F::from_u64(self.mantissa);
crate/dec2flt/decimal.rs:88: core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
crate/dec2flt/decimal.rs:90: core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
crate/dec2flt/decimal.rs:99: core::ops::Mul::mul(
crate/dec2flt/decimal.rs:100: F::from_u64(mantissa),
crate/dec2flt/decimal.rs:101: F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
crate/dec2flt/decimal.rs:106: Some(core::ops::Neg::neg(value))
crate/dec2flt/decimal_seq.rs:74: pub(super) fn try_add_digit(&mut self, digit: u8) {
crate/dec2flt/decimal_seq.rs:83: pub fn trim(&mut self) {
crate/dec2flt/decimal_seq.rs:92: while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
crate/dec2flt/decimal_seq.rs:97: pub(super) fn round(&self) -> u64 {
crate/dec2flt/decimal_seq.rs:98: if self.num_digits == 0 || self.decimal_point < 0 {
crate/dec2flt/decimal_seq.rs:118: if self.digits[dp] == 5 && dp + 1 == self.num_digits {
crate/dec2flt/decimal_seq.rs:119: round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
crate/dec2flt/decimal_seq.rs:130: pub(super) fn left_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:142: n += (self.digits[read_index] as u64) << shift;
crate/dec2flt/decimal_seq.rs:176: pub(super) fn right_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:181: while (n >> shift) == 0 && !all_zero {
crate/dec2flt/decimal_seq.rs:191: while (n >> shift) == 0 {
crate/dec2flt/decimal_seq.rs:209: let mask = (1_u64 << shift) - 1;
crate/dec2flt/decimal_seq.rs:211: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:212: n = (10 * (n & mask)) + self.digits[read_index] as u64;
crate/dec2flt/decimal_seq.rs:218: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:219: n = 10 * (n & mask);
crate/dec2flt/decimal_seq.rs:236:fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
crate/dec2flt/decimal_seq.rs:240: while i != 0 && scanning {
crate/dec2flt/decimal_seq.rs:242: if c == b'0' || c == b'.' {
crate/dec2flt/decimal_seq.rs:254:// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
crate/dec2flt/decimal_seq.rs:257:fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
crate/dec2flt/decimal_seq.rs:259: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/decimal_seq.rs:264: &s[count..]
crate/dec2flt/decimal_seq.rs:288:pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
crate/dec2flt/decimal_seq.rs:296: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:297: s = &s[1..];
crate/dec2flt/decimal_seq.rs:300: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:302: if !s.is_empty() && s[0] == b'.' {
crate/dec2flt/decimal_seq.rs:303: s = &s[1..];
crate/dec2flt/decimal_seq.rs:309: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:310: s = &s[1..];
crate/dec2flt/decimal_seq.rs:313: while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
crate/dec2flt/decimal_seq.rs:320: s = &s[8..];
crate/dec2flt/decimal_seq.rs:322: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:350: if ch == b'e' || ch == b'E' {
crate/dec2flt/decimal_seq.rs:362: let mut exponent_suffix = &s[1..];
crate/dec2flt/decimal_seq.rs:363: explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
crate/dec2flt/decimal_seq.rs:375:fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
crate/dec2flt/decimal_seq.rs:433: shift &= 63;
crate/dec2flt/decimal_seq.rs:436: let num_new_digits = (x_a >> 11) as _;
crate/dec2flt/decimal_seq.rs:437: let pow5_a = (0x7FF & x_a) as usize;
crate/dec2flt/decimal_seq.rs:438: let pow5_b = (0x7FF & x_b) as usize;
crate/dec2flt/decimal_seq.rs:439: let pow5 = &TABLE_POW5[pow5_a..];
crate/dec2flt/decimal_seq.rs:441: for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
crate/dec2flt/lemire.rs:32: if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
crate/dec2flt/lemire.rs:39: w <<= lz;
crate/dec2flt/lemire.rs:40: let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
crate/dec2flt/lemire.rs:57: let inside_safe_exponent = (q >= -27) && (q <= 55);
crate/dec2flt/lemire.rs:62: let upperbit = (hi >> 63) as i32;
crate/dec2flt/lemire.rs:63: let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
crate/dec2flt/lemire.rs:71: mantissa >>= -power2 + 1;
crate/dec2flt/lemire.rs:72: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:73: mantissa >>= 1;
crate/dec2flt/lemire.rs:74: power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
crate/dec2flt/lemire.rs:89: && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:90: && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:91: && mantissa & 0b11 == 0b01
crate/dec2flt/lemire.rs:92: && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
crate/dec2flt/lemire.rs:95: mantissa &= !1_u64;
crate/dec2flt/lemire.rs:98: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:99: mantissa >>= 1;
crate/dec2flt/lemire.rs:100: if mantissa >= (2_u64 << F::SIG_BITS) {
crate/dec2flt/lemire.rs:104: mantissa = 1_u64 << F::SIG_BITS;
crate/dec2flt/lemire.rs:108: mantissa &= !(1_u64 << F::SIG_BITS);
crate/dec2flt/lemire.rs:122: (q.wrapping_mul(152_170 + 65536) >> 16) + 63
crate/dec2flt/lemire.rs:128: (r as u64, (r >> 64) as u64)
crate/dec2flt/lemire.rs:140: 0xFFFF_FFFF_FFFF_FFFF_u64 >> precision
crate/dec2flt/lemire.rs:155: if first_hi & mask == mask {
crate/dec2flt/slow.rs:27:pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
crate/dec2flt/slow.rs:33: let get_shift = |n| {
crate/dec2flt/slow.rs:43: if d.num_digits == 0 || d.decimal_point < -324 {
crate/dec2flt/slow.rs:51: while d.decimal_point > 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:69: while d.decimal_point <= 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:73: 0 | 1 => 2,
crate/dec2flt/slow.rs:107: d.left_shift(F::SIG_BITS as usize + 1);
crate/dec2flt/slow.rs:109: if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
crate/dec2flt/slow.rs:120: if mantissa < (1_u64 << F::SIG_BITS) {
crate/dec2flt/slow.rs:124: mantissa &= (1_u64 << F::SIG_BITS) - 1;
crate/dec2flt/parse.rs:23: v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
crate/dec2flt/parse.rs:24: let v1 = (v & MASK).wrapping_mul(MUL1);
crate/dec2flt/parse.rs:25: let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
crate/dec2flt/parse.rs:26: ((v1.wrapping_add(v2) >> 32) as u32) as u64
crate/dec2flt/parse.rs:30:fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
crate/dec2flt/parse.rs:40: s = &s[8..];
crate/dec2flt/parse.rs:50: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:55: s = &s[count..];
crate/dec2flt/parse.rs:61:fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
crate/dec2flt/parse.rs:86:fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
crate/dec2flt/parse.rs:89: while scan_index < start.len() && scanning {
crate/dec2flt/parse.rs:91: if c == b'.' || c == b'0' {
crate/dec2flt/parse.rs:104:fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
crate/dec2flt/parse.rs:107: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:111: s = &s[1..];
crate/dec2flt/parse.rs:113: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:121:pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:129: if c == b'-' || c == b'+' {
crate/dec2flt/parse.rs:137: if !s.is_empty() && s[0].is_ascii_digit() {
crate/dec2flt/parse.rs:145: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:147: if exponent < (1_i64 << 59) {
crate/dec2flt/parse.rs:152: *s_ref = &s[count..];
crate/dec2flt/parse.rs:164:fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:198: if c == b'e' || c == b'E' {
crate/dec2flt/parse.rs:201: exp_number = parse_scientific(&mut s)?;
crate/dec2flt/parse.rs:234:pub fn parse_number(s: &[u8]) -> Option<Decimal> {
crate/dec2flt/parse.rs:244:pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
crate/dec2flt/parse.rs:260: register = (c << 16) | (b << 8) | a;
crate/dec2flt/parse.rs:269: register &= 0xDFDFDFDFDFDFDFDF;
crate/dec2flt/parse.rs:280: (INF_3, 3) => F::INFINITY,
crate/dec2flt/parse.rs:281: (INF_8, 8) => F::INFINITY,
crate/dec2flt/parse.rs:282: (NAN, 3) => F::NAN,
crate/dec2flt/parse.rs:286: if negative { Some(-float) } else { Some(float) }
STDERR:
(empty)
Current guarded native body, exact f64 boundary and unrestricted assembler:
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 39,111p crate/dec2flt/decimal.rs
EXIT: 0
STDOUT:
impl Decimal {
/// Detect if the float can be accurately reconstructed from native floats.
#[inline]
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
/// Try turning the decimal into an exact float representation, using machine-sized integers
/// and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
/// can be exactly represented as a machine float, since IEE-754 guarantees
/// no rounding will occur.
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
pub fn try_fast_path<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
&self,
) -> Option<F> {
// `Lemire` already entails these three operator bounds through
// `Float`; spelling them directly changes no admitted type. Charon
// needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
// The `set_precision` function takes care of setting the precision on architectures which
// require setting it by changing the global state (like the control word of the x87 FPU).
let _cw = set_precision::<F>();
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 112,138p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
///
/// Not intended for use outside of the `dec2flt` module.
#[doc(hidden)]
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
/// Gets a small power-of-ten for fast-path multiplication.
fn pow10_fast_path(exponent: usize) -> Self;
/// Converts integer into float through an as cast.
/// This is only called in the fast-path algorithm, and therefore
/// will not lose precision, since the value will always have
/// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
fn from_u64(v: u64) -> Self;
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 217,286p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
impl Lemire for f64 {
// Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
#[inline]
pub(super) fn pfe_empty() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Empty }
}
// Used in unit tests, keep public.
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
#[inline]
pub fn pfe_invalid() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Invalid }
}
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 315,365p crate/traits.rs
EXIT: 0
STDOUT:
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
// Exact value of trunc(1024 / log2(10)) from the upstream default.
const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
// This is the upstream default after substituting `Self::Int = u64`;
// it preserves every decoded field while avoiding unsupported generic
// associated-integer operator resolution.
fn integer_decode(self) -> (u64, i16, i8) {
let bits = self.to_bits();
let sign = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
let mantissa = if exponent == 0 {
(bits & Self::MANTISSA_MASK) << 1
} else {
(bits & Self::MANTISSA_MASK) | (1_u64 << 52)
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 245,291p crate/dec2flt/parse.rs
EXIT: 0
STDOUT:
// Since a valid string has at most the length 8, we can load
// all relevant characters into a u64 and work from there.
// This also generates much better code.
let mut register;
let len: usize;
// All valid strings are either of length 8 or 3.
if s.len() == 8 {
register = s.read_u64();
len = 8;
} else if s.len() == 3 {
let a = s[0] as u64;
let b = s[1] as u64;
let c = s[2] as u64;
register = (c << 16) | (b << 8) | a;
len = 3;
} else {
return None;
}
// Clear out the bits which turn ASCII uppercase characters into
// lowercase characters. The resulting string is all uppercase.
// What happens to other characters is irrelevant.
register &= 0xDFDFDFDFDFDFDFDF;
// u64 values corresponding to relevant cases
const INF_3: u64 = 0x464E49; // "INF"
const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
const NAN: u64 = 0x4E414E; // "NAN"
// Match register value to constant to parse string.
// Also match on the string length to catch edge cases
// like "inf\0\0\0\0\0".
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
}
STDERR:
(empty)
Fresh constant and symbolic-negation reproduction
=================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C opt-level=0 reference/model-evidence/binary64-probe.rs -o .trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
; ModuleID = 'binary64_negation_probe.566fd6d762029c-cgu.0'
source_filename = "binary64_negation_probe.566fd6d762029c-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 7, !"uwtable", i32 2}
!3 = !{!"rustc version 1.98.0-nightly (14210df0e 2026-05-31)"}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
.file "binary64_negation_probe.566fd6d762029c-cgu.0"
.section .text.neg_f64_trait_bits,"ax",@progbits
.globl neg_f64_trait_bits
.p2align 4
.type neg_f64_trait_bits,@function
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
.Lfunc_end0:
.size neg_f64_trait_bits, .Lfunc_end0-neg_f64_trait_bits
.cfi_endproc
.ident "rustc version 1.98.0-nightly (14210df0e 2026-05-31)"
.section ".note.GNU-stack","",@progbits
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum .trellis/scratch/binary64-probe .trellis/scratch/binary64-negation-probe.ll .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322 .trellis/scratch/binary64-probe
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
STDERR:
(empty)
Fresh checked-shift reproduction and full dynamic-count MIR
===========================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shl-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir ../../reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shl-probe u64-shl-probe.mir
EXIT: 0
STDOUT:
1d8bda234272af0f20a360fe4ff631c8ed038f9aac02bfe539192fff86706d4c u64-shl-probe
1d05de9f3cfb93082c17a57d39f7fc0813c3fe0d3ebd0efe470b0885fba931b9 u64-shl-probe.mir
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shr-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir ../../reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shr-probe u64-shr-probe.mir
EXIT: 0
STDOUT:
1cceba3e03b755a37112c16ad347161a9732793944f34d0a740470584a08c9fc u64-shr-probe
9a72f1d018d926b3e5672c8fb473e2495a710cf4a252c7515e12d2e5009c134e u64-shr-probe.mir
STDERR:
(empty)
Interpretation and limits
=========================
The constant source really evaluates f64::NAN; its nan=7ff8000000000000 observation
fixes that pinned constant, not arbitrary arithmetic-NaN signs or payloads.
The arbitrary-u64 qualified Neg probe passes w in rdi; movabsq loads 2^63 in rax,
xorq combines them, retq returns rax, with no branch or NaN exception. Its XOR law
holds for all 2^64 words, including every signaling/quiet NaN payload.
The checked dynamic-count MIR establishes the whole U64 x U32 branch condition,
not merely seven runtime samples: counts <64 shift, counts >=64 fail, without masking.
AND/OR remain exact over all words. from_u64 still asserts <=2^53 before casting;
the ordinary source guard gives -22<=exponent<=22, mantissa<=2^53, !many_digits.
The disguised source arm checks its integer product and <=2^53 before the cast,
and uses fixed table index 22. Only then may conditional Binary64NativeCallDomain
supply finite non-NaN cast/table operands and a positive nonzero divisor.
Thus reached native arithmetic is exact; generic arithmetic NaNs retain permitted-choice
semantics, not universal exact-bit equivalence. Assembly admits every BiasedFp field pair.
Equal-target preservation retains both rounding relations to the same target, without
deriving uniqueness from vocabulary or assuming an unresolved GOAL conclusion.
All 32 original GOALs remain pursued with their own quantifiers, domains and polarity.
These source-facing checks are evidence, not preservation Sound certification or GOAL proofs.
Managed checks and final scope verification
===========================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py compose-native . --check
EXIT: 0
Selected raw result fields:
{
"full_result": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/compose-native-1791584636440554217.json",
"matches": true,
"changed": false,
"mismatched_files": [],
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
COMMAND: python3 .trellis/scripts/check.py model-support-check .
EXIT: 0
Raw result:
{"ok": true, "errors": []}
COMMAND: python3 .trellis/scripts/check.py tablet . --json
EXIT: 0
Structured projection from the final full managed JSON result:
{
"command": [
"python3",
".trellis/scripts/check.py",
"tablet",
".",
"--json"
],
"exit_status": 0,
"ok": true,
"errors": [],
"node_count": 340,
"all_nodes_compile": true,
"elaboration_failures": [],
"structure_failures": [],
"warning_count": 696,
"warning_examples": [
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:364:4: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:587:8: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/StringIter.lean:13:4: declaration uses `sorry`"
],
"raw_stdout_sha256": "15a1d03a085481d315bcc1a4716aa174475f03e72d8f452f5f33d45a71f5ed91",
"stderr_line_count": 340,
"raw_stderr_sha256": "50c8fde0aef24c1b87ce95c51d21794927d6abba46d90fd04a8d3a714bfed46e"
}
This final command was captured and summarized by
python3 .trellis/scratch/managed-tablet-summary.py (exit 0).
Two earlier identical whole-Tablet checks also exited 0; one jq projection
reported tablet_exit=0 jq_exit=0, node_count=340, failing_elaboration=[],
invalid_structure=[]. The first tool preview truncated its verbose JSON;
that truncation was not used as a proof-closure certificate. The retained
warnings include permitted principal GOAL sketches and installed Aeneas
Slice/StringIter sorry warnings. No definition was supplied with sorry.
These checks establish elaboration, structure and composition freshness,
not preservation Sound or proof closure of the pursued GOALs.
COMMAND: python3 .trellis/scratch/preservation-scope-check.py
EXIT: 0
Raw result:
{
"ok": true,
"owner_checks": [
{
"node": "Binary64ModelDefault",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "210652331cd53e0254aae45856663c01d0552fe992b69608fe243260022ccd79"
},
{
"node": "ModelF64Neg",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "f7d74d4558333c0754ccce8f6861d1409c049fd4dfd1825daad2fd2f441eb78f"
},
{
"node": "ModelU64BitAnd",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "b401e17a058ec2909fb7a58d01f07867f03a933c2901338efebda252692ca6ff"
},
{
"node": "ModelU64BitOr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "c53e3e5ad29cc4419d07c3f2a8913e0f4df87ecbcf4ac1567a9e699a2bd18e2d"
},
{
"node": "ModelU64Shl",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "ed68845da19138d7406e8022c5a9adb765ed70c2ed075f41aea7c190dea9909a"
},
{
"node": "ModelU64Shr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "04b6ec376e7ec490c64183f2a18be832ea574391d7f24d49db7ddc10019cd2f0"
}
],
"principal_goal_pairs": [
{
"node": "AssemblyCorrespondence",
"target": "assembly_correspondence",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationDeterminism",
"target": "classification_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationSignificandDigit",
"target": "classification_significand_digit",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationTotality",
"target": "classification_totality",
"paired_files_byte_unchanged": true
},
{
"node": "ExponentValueAgreement",
"target": "exponent_value_agreement",
"paired_files_byte_unchanged": true
},
{
"node": "IntegerCorrectOrDefer",
"target": "integer_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NativeCorrectOrDefer",
"target": "native_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAcceptance",
"target": "number_helper_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAccumulatedValue",
"target": "number_helper_accumulated_value",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRecordBounds",
"target": "number_helper_record_bounds",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRejection",
"target": "number_helper_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserAccumulatedRounding",
"target": "parser_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserEqualTargetRounding",
"target": "parser_equal_target_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserExactRounding",
"target": "parser_exact_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInfinity",
"target": "parser_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInvalidRejection",
"target": "parser_invalid_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNanAcceptance",
"target": "parser_nan_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNonNanResults",
"target": "parser_non_nan_results",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericAcceptance",
"target": "parser_numeric_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericSign",
"target": "parser_numeric_sign",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserSignedZero",
"target": "parser_signed_zero",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserTotality",
"target": "parser_totality",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_SlowAccumulatedRounding",
"target": "slow_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchAbstractComposition",
"target": "dispatch_abstract_composition",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchComponentCompliance",
"target": "dispatch_component_compliance",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedExponent",
"target": "parser_selected_exponent",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedMagnitudeSign",
"target": "parser_selected_magnitude_sign",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingDeterminism",
"target": "rounding_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingTotality",
"target": "rounding_totality",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperInfinity",
"target": "special_helper_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperNan",
"target": "special_helper_nan",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperRejection",
"target": "special_helper_rejection",
"paired_files_byte_unchanged": true
}
],
"new_nodes": [],
"evidence_consumers_for_current_Sound": [
"Binary64ModelDefault",
"DecimalGoalVocabularyDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"frozen_boundary_unchanged": true,
"pre_existing_config_delta_unchanged": true,
"changed_paths_in_assigned_scope": [
"Tablet/Binary64ModelDefault.tex",
"Tablet/ModelF64Neg.tex",
"Tablet/ModelU64BitAnd.tex",
"Tablet/ModelU64BitOr.tex",
"Tablet/ModelU64Shl.tex",
"Tablet/ModelU64Shr.tex",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
],
"completion_meaning_audit_still_required": true
}
Delivery, acceptance and certification status
============================================
The executed kernel task is task_id=11 (worker request 118), compiler=managed,
under trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91.
Submitted scope is exactly the six owners' preservation sections and ten
reserved evidence paths listed above. No acceptance/publication outcome is
available before worker delivery; the host's real receipt must supply it.
The raw-only worker validator and a Submitted marker mean delivery, not host
acceptance, publication, preservation Sound or Modeling completion.
Keep retry-binary64-preservation-exclusively live until actual publication,
and verify-published-preservation-and-meanings live until current certification.
After publication, request current Sound on all changed evidence consumers,
including DecimalGoalVocabularyDefault's u64-shl/u64-bitor citations, and
repaired support before parents whose named gaps remain open. Do not reset
Binary64ModelDefault's genuine VerifierFail based on these worker checks.
The independent all-32 original-GOAL meaning audit remains required before
Modeling completion; a byte-unchanged pair check is not that semantic audit.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-negation-probe.rs
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
reference/model-evidence/binary64-negation.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
Primary evidence for binary64 trait negation
============================================
Scope and conclusion
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction and the
nightly-2026-06-01 toolchain fixed by modeling-input/SETUP.md and
modeling-input/manifest.json. It establishes the following statement for the
specific extracted Rust operation bound to ModelF64Neg:
For every u64 word w, including every signaling or quiet NaN payload,
to_bits(<f64 as core::ops::Neg>::neg(f64::from_bits(w)))
equals w XOR 0x8000000000000000.
Thus precisely bit 63 is toggled and every other bit is preserved. This is a
universal symbolic result, not an inference from finitely many test inputs.
Pinned identities
-----------------
The following command was run from the repository root. RROOT is the source
tree installed with the configured compiler.
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
RROOT=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
sha256sum "$R" \
"$RROOT/core/src/ops/arith.rs" \
"$RROOT/core/src/primitive_docs.rs" \
crate/dec2flt/mod.rs upstream/dec2flt/mod.rs \
generated.lean Tablet/model-support.json \
modeling-input/tool-identities.json \
reference/model-evidence/binary64-negation-probe.rs
Raw output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
modeling-input/tool-identities.json records the same rustc path and SHA-256.
The compiler reports:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Concrete core implementation
----------------------------
The following exact excerpt is core/src/ops/arith.rs:709-728 in the source
whose SHA-256 is 596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0:
macro_rules! neg_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const Neg for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> $t { -self }
}
forward_ref_unop! { impl Neg, neg for $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
The macro invocation explicitly includes f64. Its expansion is therefore the
concrete `impl Neg for f64`, with `Output = f64`, whose method body is the
primitive expression `-self`.
Frozen parser statement and primitive guarantee
------------------------------------------------
The adapted frozen parser and supplied upstream parser have identical text at
dec2flt/mod.rs:20-22. Their complete-file hashes are pinned above. The exact
three lines are:
//! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
//! process and re-apply it at the very end. This is correct in all edge cases since IEEE
//! floats are symmetric around zero, negating one simply flips the first bit.
The installed primitive documentation is pinned above by SHA-256
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5.
At primitive_docs.rs:1369-1375 it identifies f64 as binary64 and directs the
reader to the f32 documentation for the common floating-point rules:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The exact common rule at primitive_docs.rs:1256-1260 is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
This rule expressly covers unary negation and bit conversion, and expressly
distinguishes them from arithmetic NaN production. It therefore preserves the
quiet/signaling bit and every payload bit for NaNs as well as all non-sign bits
for finite values, zeros, and infinities. The parser statement identifies the
permitted sign-bit change as an actual flip in all edge cases.
Extraction and support binding
------------------------------
The frozen generated.lean, pinned above, contains this exact declaration and
trait implementation record:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
/-- Trait implementation: [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}]
Source: '/rustc/library/core/src/ops/arith.rs', lines 713:8-713:29
Name pattern: [core::ops::arith::Neg<f64, f64>] -/
@[reducible, rust_trait_impl "core::ops::arith::Neg<f64, f64>"]
def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
neg := F64.Insts.CoreOpsArithNegF64.neg
}
Thus the extracted external is the same f64 macro expansion and method body
identified above, not an abstract or different negation operation. Running
`python3 .trellis/scripts/pv_modeling.py inspect-native "$PWD"` and selecting
that declaration gives the following raw inventory fields:
name: F64.Insts.CoreOpsArithNegF64.neg
extracted_signature: : F64 → Result F64
rust_symbol: core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
raw_declaration_sha256: bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0
The raw declaration hash is independently reproduced after that inspection by:
I=$(ls -1t .trellis/scratch/inspect-native-*.json | head -n 1)
jq -j '.. | objects | select(.name? == "F64.Insts.CoreOpsArithNegF64.neg") | .source_utf8' "$I" | sha256sum
Raw output:
bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0 -
Tablet/model-support.json, whose complete-file hash is pinned above, copies all
four identity fields unchanged and binds this external to the model definition:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
Symbolic same-toolchain probe
-----------------------------
The retained probe source is:
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
The argument is an arbitrary symbolic u64. The qualified call forces the same
`Neg for f64` trait method identified by the core source and extraction. The
following exact commands use the extraction's compiler and target and retain
both optimized LLVM IR and assembly in the worker scratch directory:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-negation-probe.rs
IR=.trellis/scratch/binary64-negation-probe.ll
ASM=.trellis/scratch/binary64-negation-probe.s
"$R" --version --verbose
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir "$P" -o "$IR"
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm "$P" -o "$ASM"
sha256sum "$R" "$P" "$IR" "$ASM"
cat "$IR"
cat "$ASM"
Raw hash output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
Raw optimized LLVM IR function:
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
Raw optimized x86_64 assembly function:
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
Under the selected x86_64 C ABI, the symbolic input w arrives in %rdi and the
u64 result is returned in %rax. The loaded signed decimal constant
-9223372036854775808 has u64 bit pattern 0x8000000000000000, with bit 63 set
and every other bit clear. The emitted `xorq %rdi, %rax` therefore returns
w XOR 0x8000000000000000. There is no branch, floating-point exceptional
case, or input precondition in the emitted function.
Universal preservation conclusion
---------------------------------
The core macro and f64 instantiation connect the trait method to primitive
unary `-`; generated.lean and model-support.json connect that exact method to
ModelF64Neg. The parser source says the operation flips the sign bit in all
edge cases, while the primitive guarantee says every non-sign bit is preserved,
including the quiet/signaling and payload bits of NaNs. Finally, the symbolic
same-compiler/same-target probe makes the exact transformation explicit as XOR
with the bit-63 mask for its arbitrary u64 argument.
Because f64::from_bits accepts every one of the 2^64 u64 words and to_bits
returns the resulting raw word, the symbolic input covers the entire modeled
F64 carrier. Consequently the source result for every word is exactly the
model package's `ok` result containing that word with bit 63 toggled. This
includes both signs of zero and infinity, every finite/subnormal word, and
every possible NaN payload without canonicalization or quieting.
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/u64-bitand.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitAnd preservation evidence
================================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitAnd. The commands below were run from the repository
root on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790258751442882118.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790258751442882118.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790258751442882118.json
The exact U64 BitAnd entry in that index is:
name: U64.Insts.CoreOpsBitBitAndU64U64.bitand
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
source: /rustc/library/core/src/ops/bit.rs, lines 178:12-178:42
raw_declaration_sha256: 36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitAndU64U64.bitand") | .source_utf8' \
.trellis/scratch/inspect-native-1790258751442882118.json | sha256sum
Output:
36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line ranges are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '170,187p'
The pinned source says at lines 170-179:
macro_rules! bitand_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitAnd for $t {
type Output = $t;
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
and line 187 instantiates that implementation for u64:
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 conjunction `self & rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
--------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 105-116 and theorem at line 274 are:
def UScalar.and {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv &&& y.bv ⟩
instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where
hAnd x y := UScalar.and x y
theorem UScalar.bv_and {ty} (x y : UScalar ty) :
(x &&& y).bv = x.bv &&& y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 148-153 prove, for every width and bit index:
theorem BitVec.getElem!_and {w} (x y : BitVec w) (i : Nat) :
(x &&& y)[i]! = (x[i]! && y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_and, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.and_self]
Therefore `x &&& y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean conjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-bitor.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitOr preservation evidence
===============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitOr. The commands below were run from the repository root
on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790259866184055823.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790259866184055823.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790259866184055823.json
The exact U64 BitOr entry in that index is:
name: U64.Insts.CoreOpsBitBitOrU64U64.bitor
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
source: /rustc/library/core/src/ops/bit.rs, lines 282:12-282:41
raw_declaration_sha256: 85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitOrU64U64.bitor") | .source_utf8' \
.trellis/scratch/inspect-native-1790259866184055823.json | sha256sum
Output:
85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line range are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '274,291p'
The pinned source says at lines 274-289:
macro_rules! bitor_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitOr for $t {
type Output = $t;
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
forward_ref_binop! { impl BitOr, bitor for $t, $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
and line 291 instantiates that implementation for u64:
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 disjunction `self | rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
-------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 118-126 and theorem at line 275 are:
def UScalar.or {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv ||| y.bv ⟩
instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where
hOr x y := UScalar.or x y
theorem UScalar.bv_or {ty} (x y : UScalar ty) :
(x ||| y).bv = x.bv ||| y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 141-146 prove, for every width and bit index:
theorem BitVec.getElem!_or {w} (x y : BitVec w) (i : Nat) :
(x ||| y)[i]! = (x[i]! || y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_or, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.or_self]
Therefore `x ||| y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean disjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-shl-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x << count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shl.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shl preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shl. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a bounded U64 shift, and all U32 counts at least
64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790260978718245524.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790260978718245524.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790260978718245524.json
The exact U64 Shl entry in that fresh index is:
name: U64.Insts.CoreOpsBitShlU32U64.shl
extracted_signature: : Std.U64 → Std.U32 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
source: /rustc/library/core/src/ops/bit.rs, lines 489:12-489:41
raw_declaration_sha256: e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShlU32U64.shl") | .source_utf8' \
.trellis/scratch/inspect-native-1790260978718245524.json | sha256sum
Output:
e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d -
Thus this boundary is specifically u64 shifted by u32, and its extracted
codomain is the Aeneas Result used below to distinguish normal return from
checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '479,520p'
Lines 479-498 define the implementation macro:
macro_rules! shl_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shl<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shl(self, other: $f) -> $t {
self << other
}
}
forward_ref_binop! { impl Shl, shl for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 500-518 apply `shl_impl! { $t, u32 }` to every type in
`shl_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shl_impl_all {
($($t:ty)*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
shl_impl! { $t, u64 }
shl_impl! { $t, u128 }
shl_impl! { $t, usize }
...
)*)
}
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shl<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self << other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shl-probe.rs
with SHA-256:
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8
It places the same primitive expression `x << count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
./u64-shl-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir \
../../reference/model-evidence/u64-shl-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shl` operation and returns its bounded 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with the
expected truncation to 64 bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 17-21 and 29-31 define:
def UScalar.shiftLeft {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.shiftLeft s ⟩
else fail .integerOverflow
def UScalar.shiftLeft_UScalar {ty tys} (x : UScalar ty) (s : UScalar tys) :
Result (UScalar ty) :=
x.shiftLeft s.val
Lines 81-82 resolve the notation used by Tablet/ModelU64Shl.lean:
instance {ty0 ty1} : HShiftLeft (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftLeft x y := UScalar.shiftLeft_UScalar x y
Consequently `x <<< y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the 64-bit vector shift; at least 64 it is
exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftLeft_spec`, lines 193-205, proves the successful
branch has both equivalent bounded descriptions:
theorem UScalar.ShiftLeft_spec ... (hy : y.val < ty0.numBits) ... :
(x <<< y) ⦃ z =>
z.val = (x.val <<< y.val) % size ∧
z.bv = x.bv <<< y.val ⦄
For U64, `size` is `2^64`; hence the returned natural value is the mathematical
left shift reduced modulo `2^64`, and the returned carrier is exactly the
corresponding 64-bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 248-266 give the bit-level characterization: every result bit below
the shift count (or outside the fixed width) is false, and every in-width bit at
or above the count equals the corresponding input bit at index `i - n`:
theorem BitVec.getElem!_shiftLeft_false ...
(h : i < n ∨ w ≤ i) : (v <<< n)[i]! = false
theorem BitVec.getElem!_shiftLeft_eq ...
(h : n ≤ i ∧ i < w) : (v <<< n)[i]! = v[i - n]!
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive U64 shift. The Aeneas branch condition also succeeds and returns
`ok` of `BitVec.shiftLeft n`. `UScalar.ShiftLeft_spec` and the BitVec lemmas
identify both results as the same 64-bit word, equivalently `(x * 2^n) mod
2^64`, with discarded high bits and zero-filled low bits.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shl preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
reference/model-evidence/u64-shr-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x >> count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shr.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shr preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shr. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a logical U64 right shift, and all U32 counts at
least 64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790262316075577976.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790262316075577976.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790262316075577976.json
The exact U64 Shr entry in that fresh index is:
name: U64.Insts.CoreOpsBitShrU32U64.shr
extracted_signature: : Std.U64 -> Std.U32 -> Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
source: /rustc/library/core/src/ops/bit.rs, lines 612:12-612:41
raw_declaration_sha256: 77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 -> Std.U32 -> Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShrU32U64.shr") | .source_utf8' \
.trellis/scratch/inspect-native-1790262316075577976.json | sha256sum
Output:
77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f -
Tablet/model-support.json binds precisely this indexed declaration and
signature to dec2flt_model.ModelU64Shr. Thus the boundary is specifically u64
shifted by u32, and its extracted codomain is the Aeneas Result used below to
distinguish normal return from checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '602,641p'
Lines 602-620 define the implementation macro:
macro_rules! shr_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shr<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shr(self, other: $f) -> $t {
self >> other
}
}
forward_ref_binop! { impl Shr, shr for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 623-641 apply `shr_impl! { $t, u32 }` to every type in
`shr_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shr_impl_all {
($($t:ty)*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
shr_impl! { $t, u64 }
shr_impl! { $t, u128 }
shr_impl! { $t, usize }
...
)*)
}
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shr<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self >> other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shr-probe.rs
with SHA-256:
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee
It places the same primitive expression `x >> count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
./u64-shr-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir \
../../reference/model-evidence/u64-shr-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shr` operation and returns its logical 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with
zero-filled high bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 23-35 define:
def UScalar.shiftRight {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.ushiftRight s ⟩
else fail .integerOverflow
def UScalar.shiftRight_UScalar {ty tys} (x : UScalar ty)
(s : UScalar tys) : Result (UScalar ty) :=
x.shiftRight s.val
Lines 93-94 resolve the notation used by Tablet/ModelU64Shr.lean:
instance {ty0 ty1} : HShiftRight (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftRight x y := UScalar.shiftRight_UScalar x y
Consequently `x >>> y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the unsigned 64-bit vector shift; at least
64 it is exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftRight_spec`, lines 166-174, proves the successful
branch has both equivalent logical-shift descriptions:
theorem UScalar.ShiftRight_spec ... (hy : y.val < ty0.numBits) :
(x >>> y) ⦃ z =>
z.val = x.val >>> y.val ∧
z.bv = x.bv >>> y.val ⦄
Here natural-number `>>>` is division by `2^y.val`, so the returned numeric
value is `floor(x.val / 2^y.val)`, and the returned carrier is exactly the
unsigned shift of the fixed-width bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 268-283 give the bit-level logical zero-fill characterization. For
every result position, the total bit lookup is the input bit at the offset
position; positions whose offset is outside the 64-bit input are false:
theorem BitVec.getElem!_shiftRight {w} (v : BitVec w) (n i : Nat) :
(v >>> n)[i]! = v[n + i]!
theorem BitVec.getElem_shiftRight_false {m n : Nat} (v : BitVec m)
(hm : i < m) (h : m <= n + i) :
(v >>> n)[i]'hm = false
Together with `BitVec.getElem_shiftRight_lt`, this states that every in-range
source bit moves downward by the count and every newly exposed high bit is
zero. Because the carrier is unsigned, there is no sign extension.
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive unsigned U64 right shift. The Aeneas branch condition also
succeeds and returns `ok` of `BitVec.ushiftRight n`. `UScalar.ShiftRight_spec`
and the BitVec lemmas identify both results as the same 64-bit word,
equivalently `floor(x / 2^n)`, with every newly exposed high bit filled by zero.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shr preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
Assumptions / kernel axioms
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:851b361c5ea3a25718e293f8310f06bd42a9165470dd80f94eab8e1bbe728f60 |
| Preservation current fingerprint | preservation-v1:851b361c5ea3a25718e293f8310f06bd42a9165470dd80f94eab8e1bbe728f60 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","lean_semantic_closure":"760c8d11170d28936cd7ec6e873cfae06073816f6f416afbff2e50ca335191e5","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","lean_semantic_closure":"760c8d11170d28936cd7ec6e873cfae06073816f6f416afbff2e50ca335191e5","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "eb50192d75f60bb1d47307d5afbf8a8f03c454eefcab8038ebfc98e9517af815",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:851b361c5ea3a25718e293f8310f06bd42a9165470dd80f94eab8e1bbe728f60"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T2_current-applicability.txt",
"sha256": "aefdc935645f37c69a2c3f2e7c2fb00baad81970455148f3dbb591b0eeabced3",
"cited_by": [
"Tablet/ModelU64BitAnd.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation-probe.rs",
"sha256": "268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation.txt",
"sha256": "e19a2cd2283c8435f6d6107d06ccc798cbba4d63f0220b32b5216e43ad071aac",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/u64-bitand.txt",
"sha256": "6a48b1a79f8a52a27fb06a0b25cda9de24f68395d66ab668ecac721806883f54",
"cited_by": [
"Tablet/ModelU64BitAnd.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-bitor.txt",
"sha256": "f3dadaec6c4ebc98d0d3178bf29df7436e52998b6b97e8d108ca97a6f8092e70",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl-probe.rs",
"sha256": "a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shl.txt"
]
},
{
"path": "reference/model-evidence/u64-shl.txt",
"sha256": "e4cacfd29333a91c1258524a520e849325a85a05cf50b0065ffbf91d7977f69c",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shr-probe.rs",
"sha256": "11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/u64-shr.txt",
"sha256": "c0295af2452a4748bc1a642580414acfc76285ba87b6203b6cbff7ff9924b6ad",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
}
]core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
Inspect related source (1)
- bitor · core/src/ops/bit.rs:282 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor |
|---|---|
| Recorded source | /rustc/library/core/src/ops/bit.rs |
| Lines | 282:12–282:41 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Std.U64 → Std.U64 → Result Std.U64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelU64BitOr]
def ModelU64BitOr (x y : Std.U64) : Result Std.U64 :=
-- BODY
ok (x ||| y)
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
inspect-native result, exact declaration and binding identities,
complete relevant call inventory, and checked unchanged toolchain and scalar
library identities are in
reference/model-evidence/P89_T2_current-applicability.txt.
That current inspection identifies this exact external as the extracted
u64--u64 BitOr method, with result type
Result Std.U64, and records its Rust source span and raw declaration
hash. At that span the approved toolchain's u64 implementation
returns self | rhs for every pair, with no guard or failure branch.
At the pinned Aeneas revision, Std.U64 is a scalar containing exactly
a 64-bit vector, and scalar ||| constructs the vector
x.bv ||| y.bv; the pinned bit-vector lemma states that each
result bit is the Boolean disjunction of the corresponding input bits. The
binding defined here returns ok (x ||| y) unconditionally.
Consequently, for arbitrary modeled 64-bit words x and y, it succeeds and
returns exactly the same bounded 64-bit disjunction as the Rust method. No
reachability restriction is used.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelU64BitOr · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T2_current-applicability.txt
Current applicability of reused binary64 and U64 preservation evidence
Task 11 / worker request 118; checked in the current private checkout.
All commands below ran in this assignment; EXIT records the command status.
Rust commands use LD_LIBRARY_PATH=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib
and RUSTUP_TOOLCHAIN=nightly-2026-06-01.
The managed Lean commands are recorded separately, not invoked by this script.
Reuse and scope
===============
Read-only predecessor: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002
The historical 45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
generated.lean hash belongs to that predecessor, never the current extraction.
The old primary evidence retains its original commands, raw identities and results.
Current checks below establish applicability; prior worker task 9 was rejected,
accepted=false, and its self-report is neither publication nor certification.
Only preservation sections of the six listed owners and ten reserved evidence paths
are submitted. No ordinary statement, Lean computation, GOAL pair, source, extraction,
provenance, Preamble, binding, dispatcher owner or existing config delta is edited.
No new node, route, under-model premise, GOAL decline or polarity change is proposed.
The new 2^59 exponent fold, final-point repair and A/B GOAL domains are not old semantics.
Unchanged primitive meanings are reused, not old parser correctness or old counterexamples.
{
"task_execution": {
"binding": {
"allowed_tasks": [
"ordinary",
"lean_closure"
],
"lightweight": false,
"max_timeout_seconds": 14400,
"model": "gpt-6.1-sol",
"provider": "codex",
"reasoning_effort": "xhigh",
"timeout_seconds": 14400
},
"compiler": "managed",
"profile": "sol-xhigh",
"task_id": 11,
"task_kind": "ordinary"
},
"acceptance_logic_identity": "trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91",
"parallel_scope": {
"exclusive": true,
"helper_prefixes": [
"P116_T1_"
],
"nodes": [
"Binary64ModelDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"shared_writes": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
]
}
}
Current file, compiler, configuration and library identities
============================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum GOAL.md generated.lean Tablet/model-support.json modeling-input/manifest.json modeling-input/extraction.json modeling-input/tool-identities.json modeling-input/SETUP.md modeling-input/revision-from.json crate/Cargo.toml crate/rust-toolchain.toml lean-toolchain lakefile.lean lake-manifest.json trellis.config.json reference/model-evidence/binary64-boundary.txt crate/dec2flt/common.rs crate/dec2flt/decimal.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/fpu.rs crate/dec2flt/lemire.rs crate/dec2flt/mod.rs crate/dec2flt/parse.rs crate/dec2flt/slow.rs crate/dec2flt/table.rs crate/lib.rs crate/num/imp/mod.rs crate/num/mod.rs crate/traits.rs upstream/dec2flt/common.rs upstream/dec2flt/decimal.rs upstream/dec2flt/decimal_seq.rs upstream/dec2flt/fpu.rs upstream/dec2flt/lemire.rs upstream/dec2flt/mod.rs upstream/dec2flt/parse.rs upstream/dec2flt/slow.rs upstream/dec2flt/table.rs upstream/traits.rs reference/model-evidence/binary64-probe.rs reference/model-evidence/binary64-negation-probe.rs reference/model-evidence/u64-shl-probe.rs reference/model-evidence/u64-shr-probe.rs Tablet/Binary64ModelDefault.lean Tablet/ModelF64Neg.lean Tablet/ModelU64BitAnd.lean Tablet/ModelU64BitOr.lean Tablet/ModelU64Shl.lean Tablet/ModelU64Shr.lean
EXIT: 0
STDOUT:
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
1a7d2eea7888b7bdb0421ed6bb96c5ee1e80afe8e788438cd30725f2120a2aea modeling-input/revision-from.json
10584b73664d42dc85fb009bb0783a616520c2cc05f3b0f8c64e5d5cb32e2905 crate/Cargo.toml
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
8dab550b59cec828a4ba436bc25ce9ad66547bdd7f55899b8cbf7e4f65389518 lakefile.lean
a5f9756cd42129193c0285127cddb734224e9c69686fc2de56de2c9d48ed0695 lake-manifest.json
d8fceb13f84ecbf5bf6e9fd7ecdcb061569cfabdb0079243e2eb1609d012ac02 trellis.config.json
749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e reference/model-evidence/binary64-boundary.txt
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b crate/lib.rs
df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1 crate/num/imp/mod.rs
d84067991b142196281bc0968d32634bdcdb9a3a41c2ce2fd3c344d0f61504af crate/num/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e reference/model-evidence/binary64-probe.rs
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8 reference/model-evidence/u64-shl-probe.rs
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee reference/model-evidence/u64-shr-probe.rs
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3 Tablet/Binary64ModelDefault.lean
9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2 Tablet/ModelF64Neg.lean
3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179 Tablet/ModelU64BitAnd.lean
aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f Tablet/ModelU64BitOr.lean
af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad Tablet/ModelU64Shl.lean
54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b Tablet/ModelU64Shr.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo /home/leanagent/pv_spike/tools/charon/bin/charon /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
EXIT: 0
STDOUT:
54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade /home/leanagent/pv_spike/tools/charon/bin/charon
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
STDERR:
(empty)
All installed tool hashes equal the current tool-identities.json pins.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
EXIT: 0
STDOUT:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print cfg --target x86_64-unknown-linux-gnu
EXIT: 0
STDOUT:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat crate/Cargo.toml modeling-input/extraction.json
EXIT: 0
STDOUT:
# Standalone extraction package for the supplied `core::num::dec2flt` slice.
# The package metadata and profiles select the configured environment; source
# correspondence and extraction adaptations are recorded in ../SETUP.md and
# local preservation comments.
[package]
name = "dec2flt-model"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
path = "lib.rs"
[features]
default = []
optimize_for_size = []
[profile.dev]
overflow-checks = true
[profile.release]
overflow-checks = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(target_has_reliable_f16)"] }
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
STDERR:
(empty)
Current effective tools:
{
"aeneas": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"cargo": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"charon": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"env": {
"LD_LIBRARY_PATH": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib",
"RUSTUP_TOOLCHAIN": "nightly-2026-06-01"
},
"lean": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"lean_paths": [
"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean"
],
"readonly": [
"/home/leanagent/pv_spike/tools",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages"
],
"timeouts": {
"aeneas": 3600,
"cargo": 600,
"charon": 600,
"lean": 3600
}
}
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
EXIT: 0
STDOUT:
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
EXIT: 0
STDOUT:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
100644 blob f8582928fe49a0ce75e143b46bb0a8826d7fddae backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
100644 blob d3eb5022efc22d1d6c3ac055965f612c7f2fbca9 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
100644 blob f7bc57109569cdd0fb0c3323021c73673dcfcd33 backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
100644 blob e5733a774268c8dee71bd4ba402240d151bb8cb8 backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
Predecessor pair and probe reuse checks
=======================================
Tablet/Binary64ModelDefault.lean: predecessor_sha256=03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3; whole Lean byte-identical.
Tablet/Binary64ModelDefault.tex: predecessor_sha256=57c6e9ed282cf2dd718f822c6a31255040c71b5c7531488f3951d9c4d4d8b822; ordinary NL definition byte-identical.
Tablet/ModelF64Neg.lean: predecessor_sha256=9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2; whole Lean byte-identical.
Tablet/ModelF64Neg.tex: predecessor_sha256=9d2811046df611e45e2637da57241bace75c3de5822e03126de5f1fc9faeb859; ordinary NL definition byte-identical.
Tablet/ModelU64BitAnd.lean: predecessor_sha256=3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179; whole Lean byte-identical.
Tablet/ModelU64BitAnd.tex: predecessor_sha256=db8a1445918e94fd1c11f92f1c5f218f165aec945ac2ebdeda3cc1675165f8fe; ordinary NL definition byte-identical.
Tablet/ModelU64BitOr.lean: predecessor_sha256=aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f; whole Lean byte-identical.
Tablet/ModelU64BitOr.tex: predecessor_sha256=fbbb37c3cfa81c5811869baf46671d93a6c457042f0a5bbb78ba32c26607dbe2; ordinary NL definition byte-identical.
Tablet/ModelU64Shl.lean: predecessor_sha256=af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad; whole Lean byte-identical.
Tablet/ModelU64Shl.tex: predecessor_sha256=725582880c20b16d00487e01aceb0552a39263616563280cee0d49635984beab; ordinary NL definition byte-identical.
Tablet/ModelU64Shr.lean: predecessor_sha256=54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b; whole Lean byte-identical.
Tablet/ModelU64Shr.tex: predecessor_sha256=3def4409d97d8316d4d77dc2fe01c4142219859ea9596b835ac40f83c3a18784; ordinary NL definition byte-identical.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-negation-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-negation-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shl-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shr-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
Current raw declarations and exact support bindings
===================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py inspect-native .
EXIT: 0
STDOUT:
{
"full_index": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json",
"declaration_count": 24,
"declarations": [
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 \u2192 Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 \u2192 Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 \u2192 Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 \u2192 Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 \u2192 Std.U64 \u2192 Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02"
}
],
"declarations_omitted": 9
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
EXIT: 0
STDOUT:
fbe3b76ef8fbb588841979e071c52eee0fc850472ac55da6f2ca2033e4a34cf4 /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
STDERR:
(empty)
RAW DECLARATION:
/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:
Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43
Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]
Visibility: public -/
@[rust_fun "core::clone::impls::{core::clone::Clone<f64>}::clone"]
axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dfbdb508142706b4c716f701e52a26d63d764f088dacfa461dd81c6df0b9bf0d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_DIGITS]
Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34
Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_DIGITS"]
axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 19dc0621c0c5c7d2a24f090dd7870ffa858de15fc4e1cc7bf57f16d64816c9bc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NAN]
Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22
Name pattern: [core::f64::{f64}::NAN]
Visibility: public -/
@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 75cd3ccca5992f42ef5afa9287573410d249d40f9bcc3120fae72389b2e2419d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27
Name pattern: [core::f64::{f64}::INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::INFINITY"]
axiom core.f64.F64.INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 9a5fb08a6bae926bafdba709d6da6aaad52b8f41c7dbf3e4b2a28b2bc0542716
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NEG_INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31
Name pattern: [core::f64::{f64}::NEG_INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::NEG_INFINITY"]
axiom core.f64.F64.NEG_INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f5d6435579e1da8caecfc1a3b0039a0ce4e250e7dc55c4c69f3edbdd2a5a10f6
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::EXPONENT_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32
Name pattern: [core::f64::{f64}::EXPONENT_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::EXPONENT_MASK"]
axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dcd87a62501dc8e76079204a4b43546a4750077e1f425f01dcd58c96bf31a865
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32
Name pattern: [core::f64::{f64}::MANTISSA_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_MASK"]
axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): cf1585ae2e94a7bf5bb6b5ff37a06a0677b7e8d81420c1e0ca7ee29eca8cfd4c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::classify]:
Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45
Name pattern: [core::f64::{f64}::classify]
Visibility: public -/
@[rust_fun "core::f64::{f64}::classify"]
axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
IDENTITY AND BINDING:
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 7cf497c5bfc31455d5490d5da75914d7eaf9e522aa2eccd14fe9935502b5127c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::to_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37
Name pattern: [core::f64::{f64}::to_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::to_bits"]
axiom core.f64.F64.to_bits : F64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b35203125fea8ba89df874b609344bbe8ad61a61fcb946a184a72c729a1e3364
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::from_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42
Name pattern: [core::f64::{f64}::from_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::from_bits"]
axiom core.f64.F64.from_bits : Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f819b0951f4f63943abf8d4787a2f9489ffd1137fa91529e0771a303bc8fcb94
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41
Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul"]
axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 4adead3b54aa85bfb81b7122b0e942b2c6f3d232d548d8361a2a2ca067be1e7f
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41
Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div"]
axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 62ca24414fa18ef9709d7c5703429d7262f27d017abc975ffb532ae284ba054a
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 945f30e7dbb62802e6ba5bb9d9445e100528b2a52d3b0b6a3a0629c939ff9860
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b66bd94c28f512804622c3717705dbe7ef5a3ced5beaac7435704d053038c36e
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 68909ba4060a48df31ea54bcf0510b089709a3a644c9c1b0770780a98d31f4cc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 5c0105f2c7ce3d255f053e0ccbefa65f73f65de1462832217571cf8cd4963e47
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f100256a450680392496fb74934592e9e2822a1648320153e27c1c0d100ff482
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5
Visibility: public -/
axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
: Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 0bb769d884e3d54d7aa94163fdf4c8fc589050ed84f4fa0d11f694cf599cdb8f
All four identity fields and full raw declaration equal predecessor; current binding matches.
Complete relevant call and wiring inventories
=============================================
This deliberately includes record wiring and scalar lowerings, not just direct external calls.
The four U64 external trait fields wire into Int; generic scalar notation in generated.lean
also lowers directly to the installed operations with the same full-domain meanings.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n 'F64\.Insts\.(CoreClone|CoreOpsArith)|core\.f64\.F64\.|U64\.Insts\.CoreOpsBit|coreops(bit|arith)|\.from_u64|\.pow10_fast_path|FloatInst\.(INFINITY|NEG_INFINITY|NAN|NEG_NAN|SIG_|EXP_|INFINITE_POWER)|&&&|\|\|\||<<<|>>>' generated.lean
EXIT: 0
STDOUT:
25:axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
31:def F64.Insts.CoreCloneClone : core.clone.Clone F64 := {
32: clone := F64.Insts.CoreCloneClone.clone
40: cloneInst := F64.Insts.CoreCloneClone
48:axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
54:@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
61:axiom core.f64.F64.INFINITY : Result F64
68:axiom core.f64.F64.NEG_INFINITY : Result F64
75:axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
82:axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
101:axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
108:axiom core.f64.F64.to_bits : F64 → Result Std.U64
115:axiom core.f64.F64.from_bits : Std.U64 → Result F64
138:axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
144:def F64.Insts.CoreOpsArithMulF64F64 : core.ops.arith.Mul F64 F64 F64 := {
145: mul := F64.Insts.CoreOpsArithMulF64F64.mul
162:axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
168:def F64.Insts.CoreOpsArithDivF64F64 : core.ops.arith.Div F64 F64 F64 := {
169: div := F64.Insts.CoreOpsArithDivF64F64.div
185:axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
191:def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
192: neg := F64.Insts.CoreOpsArithNegF64.neg
200:axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
207:def U64.Insts.CoreOpsBitBitAndU64U64 : core.ops.bit.BitAnd Std.U64 Std.U64
209: bitand := U64.Insts.CoreOpsBitBitAndU64U64.bitand
226:axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
233:def U64.Insts.CoreOpsBitBitOrU64U64 : core.ops.bit.BitOr Std.U64 Std.U64
235: bitor := U64.Insts.CoreOpsBitBitOrU64U64.bitor
252:axiom U64.Insts.CoreOpsBitShlU32U64.shl
259:def U64.Insts.CoreOpsBitShlU32U64 : core.ops.bit.Shl Std.U64 Std.U32 Std.U64
261: shl := U64.Insts.CoreOpsBitShlU32U64.shl
278:axiom U64.Insts.CoreOpsBitShrU32U64.shr
285:def U64.Insts.CoreOpsBitShrU32U64 : core.ops.bit.Shr Std.U64 Std.U32 Std.U64
287: shr := U64.Insts.CoreOpsBitShrU32U64.shr
393: let i ← lift (a ||| b)
394: let i1 ← lift (i &&& 9259542123273814144#u64)
635: coreopsbitShrSelfU32SelfInst : core.ops.bit.Shr Self Std.U32 Self
636: coreopsbitShlSelfU32SelfInst : core.ops.bit.Shl Self Std.U32 Self
637: coreopsbitBitAndInst : core.ops.bit.BitAnd Self Self Self
638: coreopsbitBitOrInst : core.ops.bit.BitOr Self Self Self
664: coreopsarithDivInst : core.ops.arith.Div Self Self Self
665: coreopsarithNegInst : core.ops.arith.Neg Self Self
666: coreopsarithMulInst : core.ops.arith.Mul Self Self Self
726: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
727: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
728: (coreopsarithNegInst : core.ops.arith.Neg F F)
739: let value ← LemireInst.from_u64 self.mantissa
746: let t ← LemireInst.pow10_fast_path i2
747: coreopsarithDivInst.div value t
751: let t ← LemireInst.pow10_fast_path i1
752: coreopsarithMulInst.mul value t
754: then let t ← coreopsarithNegInst.neg value1
769: let t ← LemireInst.from_u64 val
771: let t1 ← LemireInst.pow10_fast_path i4
772: let value ← coreopsarithMulInst.mul t t1
774: then let t2 ← coreopsarithNegInst.neg value
1018: let i5 ← lift (1#u8 &&& i4)
1219: let shift1 ← lift (shift &&& 63#usize)
1228: let i1 ← x_a >>> 11#i32
1230: let i2 ← lift (2047#u16 &&& x_a)
1232: let i3 ← lift (2047#u16 &&& x_b)
1264: let i2 ← i1 <<< shift
1370: let i ← n >>> shift
1400: let i ← n >>> shift
1451: let i1 ← n >>> shift
1453: let i2 ← lift (n &&& mask)
1490: let i ← n >>> shift
1492: let i1 ← lift (n &&& mask)
1544: let i4 ← 1#u64 <<< shift
1704: let i3 ← 1#i64 <<< 59#i32
2971: let i3 ← r >>> 64#i32
2990: then 18446744073709551615#u64 >>> precision
3000: let i4 ← lift (first_hi &&& mask)
3016: let i2 ← i1 >>> 16#i32
3028: let i ← traitsFloatInst.INFINITE_POWER
3045: let w1 ← w <<< lz
3046: let i5 ← traitsFloatInst.SIG_BITS
3058: let i8 ← hi >>> 63#i32
3064: let mantissa ← hi >>> i12
3070: let i18 ← traitsFloatInst.EXP_MIN
3081: let mantissa1 ← mantissa >>> i22
3082: let i23 ← lift (mantissa1 &&& 1#u64)
3084: let mantissa3 ← mantissa2 >>> 1#i32
3085: let i24 ← 1#u64 <<< i5
3102: let i24 ← lift (mantissa &&& 3#u64)
3108: let i28 ← mantissa <<< i27
3111: ok (mantissa &&& i29)
3117: let i20 ← lift (mantissa1 &&& 1#u64)
3119: let mantissa3 ← mantissa2 >>> 1#i32
3120: let i21 ← 2#u64 <<< i5
3125: let mantissa5 ← 1#u64 <<< i5
3129: let i22 ← 1#u64 <<< i5
3131: let mantissa5 ← lift (mantissa4 &&& i23)
3137: let i8 ← hi >>> 63#i32
3143: let mantissa ← hi >>> i12
3149: let i18 ← traitsFloatInst.EXP_MIN
3160: let mantissa1 ← mantissa >>> i22
3161: let i23 ← lift (mantissa1 &&& 1#u64)
3163: let mantissa3 ← mantissa2 >>> 1#i32
3164: let i24 ← 1#u64 <<< i5
3181: let i24 ← lift (mantissa &&& 3#u64)
3187: let i28 ← mantissa <<< i27
3190: ok (mantissa &&& i29)
3196: let i20 ← lift (mantissa1 &&& 1#u64)
3198: let mantissa3 ← mantissa2 >>> 1#i32
3199: let i21 ← 2#u64 <<< i5
3204: let mantissa5 ← 1#u64 <<< i5
3208: let i22 ← 1#u64 <<< i5
3210: let mantissa5 ← lift (mantissa4 &&& i23)
3232: let i ← LemireInst.traitsFloatExtInst.FloatInst.SIG_TOTAL_BITS
3233: 1#u64 <<< i
3240: let bits ← core.f64.F64.to_bits self
3241: let i ← bits >>> 63#i32
3245: let i1 ← core.f64.F64.EXPONENT_MASK
3246: let i2 ← lift (bits &&& i1)
3247: let i3 ← i2 >>> 52#i32
3253: let i4 ← core.f64.F64.MANTISSA_MASK
3254: let i5 ← lift (bits &&& i4)
3255: i5 <<< 1#i32
3258: let i4 ← core.f64.F64.MANTISSA_MASK
3259: let i5 ← lift (bits &&& i4)
3260: let i6 ← 1#u64 <<< 52#i32
3261: ok (i5 ||| i6)
3269:def F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3271: core.f64.F64.from_bits v
3278: core.f64.F64.classify self
3285: core.f64.F64.to_bits self
3324: core.f64.F64.MANTISSA_MASK
3331: core.f64.F64.EXPONENT_MASK
3339: core.f64.F64.MANTISSA_DIGITS
3352: core.f64.F64.from_bits 18444492273895866368#u64
3359: core.f64.F64.NAN
3366: core.f64.F64.NEG_INFINITY
3373: core.f64.F64.INFINITY
3381: let i ← FloatInst.EXP_BIAS
3392: let i ← FloatInst.EXP_SAT
3393: i >>> 1#i32
3402: let i ← FloatInst.EXP_SAT
3411: let i ← FloatInst.EXP_BITS
3412: let i1 ← 1#u32 <<< i
3422: let i1 ← FloatInst.SIG_BITS
3432: let i ← FloatInst.SIG_TOTAL_BITS
3471: coreopsbitShrSelfU32SelfInst := U64.Insts.CoreOpsBitShrU32U64
3472: coreopsbitShlSelfU32SelfInst := U64.Insts.CoreOpsBitShlU32U64
3473: coreopsbitBitAndInst := U64.Insts.CoreOpsBitBitAndU64U64
3474: coreopsbitBitOrInst := U64.Insts.CoreOpsBitBitOrU64U64
3512: coreopsarithDivInst := F64.Insts.CoreOpsArithDivF64F64
3513: coreopsarithNegInst := F64.Insts.CoreOpsArithNegF64
3514: coreopsarithMulInst := F64.Insts.CoreOpsArithMulF64F64
3529: from_u64_bits := F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3537:axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3543:def F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3545: let i ← lift (exponent &&& 31#usize)
3547: | 0 => core.f64.F64.from_bits 4607182418800017408#u64
3548: | 1 => core.f64.F64.from_bits 4621819117588971520#u64
3549: | 2 => core.f64.F64.from_bits 4636737291354636288#u64
3550: | 3 => core.f64.F64.from_bits 4652007308841189376#u64
3551: | 4 => core.f64.F64.from_bits 4666723172467343360#u64
3552: | 5 => core.f64.F64.from_bits 4681608360884174848#u64
3553: | 6 => core.f64.F64.from_bits 4696837146684686336#u64
3554: | 7 => core.f64.F64.from_bits 4711630319722168320#u64
3555: | 8 => core.f64.F64.from_bits 4726483295884279808#u64
3556: | 9 => core.f64.F64.from_bits 4741671816366391296#u64
3557: | 10 => core.f64.F64.from_bits 4756540486875873280#u64
3558: | 11 => core.f64.F64.from_bits 4771362005757984768#u64
3559: | 12 => core.f64.F64.from_bits 4786511204640096256#u64
3560: | 13 => core.f64.F64.from_bits 4801453603149578240#u64
3561: | 14 => core.f64.F64.from_bits 4816244402031689728#u64
3562: | 15 => core.f64.F64.from_bits 4831355200913801216#u64
3563: | 16 => core.f64.F64.from_bits 4846369599423283200#u64
3564: | 17 => core.f64.F64.from_bits 4861130398305394688#u64
3565: | 18 => core.f64.F64.from_bits 4876203697187506176#u64
3566: | 19 => core.f64.F64.from_bits 4891288408196988160#u64
3567: | 20 => core.f64.F64.from_bits 4906019910204099648#u64
3568: | 21 => core.f64.F64.from_bits 4921056587992461136#u64
3569: | 22 => core.f64.F64.from_bits 4936209963552724370#u64
3570: | _ => core.f64.F64.from_bits 0#u64
3606: F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3607: from_u64 := F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3643: let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
3644: let i2 ← i <<< i1
3645: let word ← lift (x.m ||| i2)
3646: traitsFloatExtInst.from_u64_bits word
3903: let i ← traitsFloatInst.EXP_MIN
3939: let i ← traitsFloatInst.INFINITE_POWER
3971: let i5 ← traitsFloatInst.EXP_MIN
3977: let i8 ← traitsFloatInst.SIG_BITS
3984: let i12 ← 1#u64 <<< i11
3999: let i16 ← 1#u64 <<< i8
4004: let i17 ← 1#u64 <<< i8
4006: let mantissa2 ← lift (mantissa1 &&& i18)
4011: let i14 ← 1#u64 <<< i8
4016: let i15 ← 1#u64 <<< i8
4018: let mantissa1 ← lift (mantissa &&& i16)
4035: let register1 ← lift (register &&& 16131858542891098079#u64)
4039: let float ← traitsFloatInst.INFINITY
4041: then let t ← traitsFloatInst.coreopsarithNegInst.neg float
4056: let i5 ← c <<< 16#i32
4057: let i6 ← b <<< 8#i32
4058: let i7 ← lift (i5 ||| i6)
4059: let register ← lift (i7 ||| a)
4060: let register1 ← lift (register &&& 16131858542891098079#u64)
4063: let float ← traitsFloatInst.INFINITY
4066: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4071: let float ← traitsFloatInst.NAN
4074: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4237: let i1 ← v1 >>> 8#i32
4239: let i2 ← lift (v2 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4243: let i3 ← v2 >>> 16#i32
4244: let i4 ← lift (i3 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4249: let i6 ← i5 >>> 32#i32
4561: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4562: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4563: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4611: coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
4656: let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
4657: let i2 ← i <<< i1
4658: let assembled_word ← lift (selected_pair.m ||| i2)
4664: let result ← coreopsarithNegInst.neg assembly_result
4731: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4732: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4733: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4737: num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
4738: coreopsarithMulInst coreopsarithNegInst s
STDERR:
(empty)
Rust inventory is a complete operation-syntax superset, including generic and scalar forms;
trait bounds, comments and non-U64 integer operations are included, not silently omitted.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n '<<|>>|[&|]|Neg::neg|Div::div|Mul::mul|from_u64|pow10_fast_path|SIG_BITS|SIG_TOTAL_BITS|F::NAN|F::INFINITY|Some\(-float\)' crate/traits.rs crate/dec2flt
EXIT: 0
STDOUT:
crate/traits.rs:95: const SIG_TOTAL_BITS: u32;
crate/traits.rs:101: const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
crate/traits.rs:104: const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
crate/traits.rs:110: const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
crate/traits.rs:116: const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
crate/traits.rs:137: /// (in the 32-bit case). In both cases,the power of five(5^|q|)
crate/traits.rs:172: fn from_u64_bits(v: u64) -> Self;
crate/traits.rs:177: /// exponent will be `-(EXP_BIAS + SIG_BITS)`, which is the minimum subnormal power. For
crate/traits.rs:178: /// infinity or NaN, the exponent will be `EXP_SAT - EXP_BIAS - SIG_BITS`.
crate/traits.rs:204: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:229: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:230: Self::from_bits((v & 0xFFFF) as u16)
crate/traits.rs:238: let sign = if bits >> 15 == 0 { 1 } else { -1 };
crate/traits.rs:239: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
crate/traits.rs:241: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:243: (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
crate/traits.rs:264: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:288: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:289: f32::from_bits((v & 0xFFFFFFFF) as u32)
crate/traits.rs:297: let sign = if bits >> 31 == 0 { 1 } else { -1 };
crate/traits.rs:298: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
crate/traits.rs:300: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:302: (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
crate/traits.rs:320: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:341: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:350: let sign = if bits >> 63 == 0 { 1 } else { -1 };
crate/traits.rs:351: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
crate/traits.rs:353: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:355: (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
crate/dec2flt/common.rs:10: fn read_u64(&self) -> u64;
crate/dec2flt/common.rs:13: fn write_u64(&mut self, value: u64);
crate/dec2flt/common.rs:16: fn offset_from(&self, other: &Self) -> isize;
crate/dec2flt/common.rs:22: fn read_u64(&self) -> u64 {
crate/dec2flt/common.rs:24: tmp.copy_from_slice(&self[..8]);
crate/dec2flt/common.rs:29: fn write_u64(&mut self, value: u64) {
crate/dec2flt/common.rs:30: self[..8].copy_from_slice(&value.to_le_bytes())
crate/dec2flt/common.rs:34: fn offset_from(&self, other: &Self) -> isize {
crate/dec2flt/common.rs:47: (a | b) & 0x8080_8080_8080_8080 == 0
crate/dec2flt/mod.rs:116: /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:120: /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:124: /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
crate/dec2flt/mod.rs:127: /// Maximum mantissa for the fast-path (`1 << 53` for f64).
crate/dec2flt/mod.rs:128: const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
crate/dec2flt/mod.rs:131: fn pow10_fast_path(exponent: usize) -> Self;
crate/dec2flt/mod.rs:137: fn from_u64(v: u64) -> Self;
crate/dec2flt/mod.rs:147: // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
crate/dec2flt/mod.rs:153: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:157: match exponent & 7 {
crate/dec2flt/mod.rs:172: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:183: // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
crate/dec2flt/mod.rs:187: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:190: match exponent & 15 {
crate/dec2flt/mod.rs:211: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:218: // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
crate/dec2flt/mod.rs:222: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:226: match exponent & 31 {
crate/dec2flt/mod.rs:263: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:284: word |= (x.p_biased as u64) << F::SIG_BITS;
crate/dec2flt/mod.rs:285: F::from_u64_bits(word)
crate/dec2flt/mod.rs:299: SignOnly { body: &'a [u8], negative: bool },
crate/dec2flt/mod.rs:302: body: &'a [u8],
crate/dec2flt/mod.rs:309: body: &'a [u8],
crate/dec2flt/mod.rs:317: body: &'a [u8],
crate/dec2flt/mod.rs:330: pub body: &'a [u8],
crate/dec2flt/mod.rs:362: s: &'a str,
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
crate/dec2flt/mod.rs:369: if c == b'-' || c == b'+' {
crate/dec2flt/mod.rs:370: body = &body[1..];
crate/dec2flt/mod.rs:431: // occur exactly when `many_digits && fp.p_biased >= 0`.
crate/dec2flt/mod.rs:432: let second_compute_guard = num.many_digits && fp.p_biased >= 0;
crate/dec2flt/mod.rs:468: let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
crate/dec2flt/mod.rs:472: core::ops::Neg::neg(assembly_result)
crate/dec2flt/mod.rs:514: s: &str,
crate/dec2flt/fpu.rs:31: /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
crate/dec2flt/fpu.rs:32: /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
crate/dec2flt/fpu.rs:33: /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
crate/dec2flt/fpu.rs:52: in(reg) &cw,
crate/dec2flt/fpu.rs:76: in(reg) &mut cw,
crate/dec2flt/fpu.rs:83: set_cw((cw & 0xFCFF) | cw_precision);
crate/dec2flt/fpu.rs:89: fn drop(&mut self) {
crate/dec2flt/decimal.rs:42: fn can_use_fast_path<F: Lemire>(&self) -> bool {
crate/dec2flt/decimal.rs:44: && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
crate/dec2flt/decimal.rs:45: && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
crate/dec2flt/decimal.rs:46: && !self.many_digits
crate/dec2flt/decimal.rs:65: &self,
crate/dec2flt/decimal.rs:84: let value = F::from_u64(self.mantissa);
crate/dec2flt/decimal.rs:88: core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
crate/dec2flt/decimal.rs:90: core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
crate/dec2flt/decimal.rs:99: core::ops::Mul::mul(
crate/dec2flt/decimal.rs:100: F::from_u64(mantissa),
crate/dec2flt/decimal.rs:101: F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
crate/dec2flt/decimal.rs:106: Some(core::ops::Neg::neg(value))
crate/dec2flt/decimal_seq.rs:74: pub(super) fn try_add_digit(&mut self, digit: u8) {
crate/dec2flt/decimal_seq.rs:83: pub fn trim(&mut self) {
crate/dec2flt/decimal_seq.rs:92: while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
crate/dec2flt/decimal_seq.rs:97: pub(super) fn round(&self) -> u64 {
crate/dec2flt/decimal_seq.rs:98: if self.num_digits == 0 || self.decimal_point < 0 {
crate/dec2flt/decimal_seq.rs:118: if self.digits[dp] == 5 && dp + 1 == self.num_digits {
crate/dec2flt/decimal_seq.rs:119: round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
crate/dec2flt/decimal_seq.rs:130: pub(super) fn left_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:142: n += (self.digits[read_index] as u64) << shift;
crate/dec2flt/decimal_seq.rs:176: pub(super) fn right_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:181: while (n >> shift) == 0 && !all_zero {
crate/dec2flt/decimal_seq.rs:191: while (n >> shift) == 0 {
crate/dec2flt/decimal_seq.rs:209: let mask = (1_u64 << shift) - 1;
crate/dec2flt/decimal_seq.rs:211: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:212: n = (10 * (n & mask)) + self.digits[read_index] as u64;
crate/dec2flt/decimal_seq.rs:218: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:219: n = 10 * (n & mask);
crate/dec2flt/decimal_seq.rs:236:fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
crate/dec2flt/decimal_seq.rs:240: while i != 0 && scanning {
crate/dec2flt/decimal_seq.rs:242: if c == b'0' || c == b'.' {
crate/dec2flt/decimal_seq.rs:254:// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
crate/dec2flt/decimal_seq.rs:257:fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
crate/dec2flt/decimal_seq.rs:259: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/decimal_seq.rs:264: &s[count..]
crate/dec2flt/decimal_seq.rs:288:pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
crate/dec2flt/decimal_seq.rs:296: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:297: s = &s[1..];
crate/dec2flt/decimal_seq.rs:300: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:302: if !s.is_empty() && s[0] == b'.' {
crate/dec2flt/decimal_seq.rs:303: s = &s[1..];
crate/dec2flt/decimal_seq.rs:309: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:310: s = &s[1..];
crate/dec2flt/decimal_seq.rs:313: while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
crate/dec2flt/decimal_seq.rs:320: s = &s[8..];
crate/dec2flt/decimal_seq.rs:322: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:350: if ch == b'e' || ch == b'E' {
crate/dec2flt/decimal_seq.rs:362: let mut exponent_suffix = &s[1..];
crate/dec2flt/decimal_seq.rs:363: explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
crate/dec2flt/decimal_seq.rs:375:fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
crate/dec2flt/decimal_seq.rs:433: shift &= 63;
crate/dec2flt/decimal_seq.rs:436: let num_new_digits = (x_a >> 11) as _;
crate/dec2flt/decimal_seq.rs:437: let pow5_a = (0x7FF & x_a) as usize;
crate/dec2flt/decimal_seq.rs:438: let pow5_b = (0x7FF & x_b) as usize;
crate/dec2flt/decimal_seq.rs:439: let pow5 = &TABLE_POW5[pow5_a..];
crate/dec2flt/decimal_seq.rs:441: for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
crate/dec2flt/lemire.rs:32: if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
crate/dec2flt/lemire.rs:39: w <<= lz;
crate/dec2flt/lemire.rs:40: let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
crate/dec2flt/lemire.rs:57: let inside_safe_exponent = (q >= -27) && (q <= 55);
crate/dec2flt/lemire.rs:62: let upperbit = (hi >> 63) as i32;
crate/dec2flt/lemire.rs:63: let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
crate/dec2flt/lemire.rs:71: mantissa >>= -power2 + 1;
crate/dec2flt/lemire.rs:72: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:73: mantissa >>= 1;
crate/dec2flt/lemire.rs:74: power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
crate/dec2flt/lemire.rs:89: && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:90: && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:91: && mantissa & 0b11 == 0b01
crate/dec2flt/lemire.rs:92: && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
crate/dec2flt/lemire.rs:95: mantissa &= !1_u64;
crate/dec2flt/lemire.rs:98: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:99: mantissa >>= 1;
crate/dec2flt/lemire.rs:100: if mantissa >= (2_u64 << F::SIG_BITS) {
crate/dec2flt/lemire.rs:104: mantissa = 1_u64 << F::SIG_BITS;
crate/dec2flt/lemire.rs:108: mantissa &= !(1_u64 << F::SIG_BITS);
crate/dec2flt/lemire.rs:122: (q.wrapping_mul(152_170 + 65536) >> 16) + 63
crate/dec2flt/lemire.rs:128: (r as u64, (r >> 64) as u64)
crate/dec2flt/lemire.rs:140: 0xFFFF_FFFF_FFFF_FFFF_u64 >> precision
crate/dec2flt/lemire.rs:155: if first_hi & mask == mask {
crate/dec2flt/slow.rs:27:pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
crate/dec2flt/slow.rs:33: let get_shift = |n| {
crate/dec2flt/slow.rs:43: if d.num_digits == 0 || d.decimal_point < -324 {
crate/dec2flt/slow.rs:51: while d.decimal_point > 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:69: while d.decimal_point <= 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:73: 0 | 1 => 2,
crate/dec2flt/slow.rs:107: d.left_shift(F::SIG_BITS as usize + 1);
crate/dec2flt/slow.rs:109: if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
crate/dec2flt/slow.rs:120: if mantissa < (1_u64 << F::SIG_BITS) {
crate/dec2flt/slow.rs:124: mantissa &= (1_u64 << F::SIG_BITS) - 1;
crate/dec2flt/parse.rs:23: v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
crate/dec2flt/parse.rs:24: let v1 = (v & MASK).wrapping_mul(MUL1);
crate/dec2flt/parse.rs:25: let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
crate/dec2flt/parse.rs:26: ((v1.wrapping_add(v2) >> 32) as u32) as u64
crate/dec2flt/parse.rs:30:fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
crate/dec2flt/parse.rs:40: s = &s[8..];
crate/dec2flt/parse.rs:50: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:55: s = &s[count..];
crate/dec2flt/parse.rs:61:fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
crate/dec2flt/parse.rs:86:fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
crate/dec2flt/parse.rs:89: while scan_index < start.len() && scanning {
crate/dec2flt/parse.rs:91: if c == b'.' || c == b'0' {
crate/dec2flt/parse.rs:104:fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
crate/dec2flt/parse.rs:107: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:111: s = &s[1..];
crate/dec2flt/parse.rs:113: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:121:pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:129: if c == b'-' || c == b'+' {
crate/dec2flt/parse.rs:137: if !s.is_empty() && s[0].is_ascii_digit() {
crate/dec2flt/parse.rs:145: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:147: if exponent < (1_i64 << 59) {
crate/dec2flt/parse.rs:152: *s_ref = &s[count..];
crate/dec2flt/parse.rs:164:fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:198: if c == b'e' || c == b'E' {
crate/dec2flt/parse.rs:201: exp_number = parse_scientific(&mut s)?;
crate/dec2flt/parse.rs:234:pub fn parse_number(s: &[u8]) -> Option<Decimal> {
crate/dec2flt/parse.rs:244:pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
crate/dec2flt/parse.rs:260: register = (c << 16) | (b << 8) | a;
crate/dec2flt/parse.rs:269: register &= 0xDFDFDFDFDFDFDFDF;
crate/dec2flt/parse.rs:280: (INF_3, 3) => F::INFINITY,
crate/dec2flt/parse.rs:281: (INF_8, 8) => F::INFINITY,
crate/dec2flt/parse.rs:282: (NAN, 3) => F::NAN,
crate/dec2flt/parse.rs:286: if negative { Some(-float) } else { Some(float) }
STDERR:
(empty)
Current guarded native body, exact f64 boundary and unrestricted assembler:
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 39,111p crate/dec2flt/decimal.rs
EXIT: 0
STDOUT:
impl Decimal {
/// Detect if the float can be accurately reconstructed from native floats.
#[inline]
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
/// Try turning the decimal into an exact float representation, using machine-sized integers
/// and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
/// can be exactly represented as a machine float, since IEE-754 guarantees
/// no rounding will occur.
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
pub fn try_fast_path<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
&self,
) -> Option<F> {
// `Lemire` already entails these three operator bounds through
// `Float`; spelling them directly changes no admitted type. Charon
// needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
// The `set_precision` function takes care of setting the precision on architectures which
// require setting it by changing the global state (like the control word of the x87 FPU).
let _cw = set_precision::<F>();
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 112,138p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
///
/// Not intended for use outside of the `dec2flt` module.
#[doc(hidden)]
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
/// Gets a small power-of-ten for fast-path multiplication.
fn pow10_fast_path(exponent: usize) -> Self;
/// Converts integer into float through an as cast.
/// This is only called in the fast-path algorithm, and therefore
/// will not lose precision, since the value will always have
/// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
fn from_u64(v: u64) -> Self;
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 217,286p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
impl Lemire for f64 {
// Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
#[inline]
pub(super) fn pfe_empty() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Empty }
}
// Used in unit tests, keep public.
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
#[inline]
pub fn pfe_invalid() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Invalid }
}
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 315,365p crate/traits.rs
EXIT: 0
STDOUT:
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
// Exact value of trunc(1024 / log2(10)) from the upstream default.
const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
// This is the upstream default after substituting `Self::Int = u64`;
// it preserves every decoded field while avoiding unsupported generic
// associated-integer operator resolution.
fn integer_decode(self) -> (u64, i16, i8) {
let bits = self.to_bits();
let sign = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
let mantissa = if exponent == 0 {
(bits & Self::MANTISSA_MASK) << 1
} else {
(bits & Self::MANTISSA_MASK) | (1_u64 << 52)
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 245,291p crate/dec2flt/parse.rs
EXIT: 0
STDOUT:
// Since a valid string has at most the length 8, we can load
// all relevant characters into a u64 and work from there.
// This also generates much better code.
let mut register;
let len: usize;
// All valid strings are either of length 8 or 3.
if s.len() == 8 {
register = s.read_u64();
len = 8;
} else if s.len() == 3 {
let a = s[0] as u64;
let b = s[1] as u64;
let c = s[2] as u64;
register = (c << 16) | (b << 8) | a;
len = 3;
} else {
return None;
}
// Clear out the bits which turn ASCII uppercase characters into
// lowercase characters. The resulting string is all uppercase.
// What happens to other characters is irrelevant.
register &= 0xDFDFDFDFDFDFDFDF;
// u64 values corresponding to relevant cases
const INF_3: u64 = 0x464E49; // "INF"
const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
const NAN: u64 = 0x4E414E; // "NAN"
// Match register value to constant to parse string.
// Also match on the string length to catch edge cases
// like "inf\0\0\0\0\0".
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
}
STDERR:
(empty)
Fresh constant and symbolic-negation reproduction
=================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C opt-level=0 reference/model-evidence/binary64-probe.rs -o .trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
; ModuleID = 'binary64_negation_probe.566fd6d762029c-cgu.0'
source_filename = "binary64_negation_probe.566fd6d762029c-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 7, !"uwtable", i32 2}
!3 = !{!"rustc version 1.98.0-nightly (14210df0e 2026-05-31)"}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
.file "binary64_negation_probe.566fd6d762029c-cgu.0"
.section .text.neg_f64_trait_bits,"ax",@progbits
.globl neg_f64_trait_bits
.p2align 4
.type neg_f64_trait_bits,@function
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
.Lfunc_end0:
.size neg_f64_trait_bits, .Lfunc_end0-neg_f64_trait_bits
.cfi_endproc
.ident "rustc version 1.98.0-nightly (14210df0e 2026-05-31)"
.section ".note.GNU-stack","",@progbits
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum .trellis/scratch/binary64-probe .trellis/scratch/binary64-negation-probe.ll .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322 .trellis/scratch/binary64-probe
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
STDERR:
(empty)
Fresh checked-shift reproduction and full dynamic-count MIR
===========================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shl-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir ../../reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shl-probe u64-shl-probe.mir
EXIT: 0
STDOUT:
1d8bda234272af0f20a360fe4ff631c8ed038f9aac02bfe539192fff86706d4c u64-shl-probe
1d05de9f3cfb93082c17a57d39f7fc0813c3fe0d3ebd0efe470b0885fba931b9 u64-shl-probe.mir
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shr-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir ../../reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shr-probe u64-shr-probe.mir
EXIT: 0
STDOUT:
1cceba3e03b755a37112c16ad347161a9732793944f34d0a740470584a08c9fc u64-shr-probe
9a72f1d018d926b3e5672c8fb473e2495a710cf4a252c7515e12d2e5009c134e u64-shr-probe.mir
STDERR:
(empty)
Interpretation and limits
=========================
The constant source really evaluates f64::NAN; its nan=7ff8000000000000 observation
fixes that pinned constant, not arbitrary arithmetic-NaN signs or payloads.
The arbitrary-u64 qualified Neg probe passes w in rdi; movabsq loads 2^63 in rax,
xorq combines them, retq returns rax, with no branch or NaN exception. Its XOR law
holds for all 2^64 words, including every signaling/quiet NaN payload.
The checked dynamic-count MIR establishes the whole U64 x U32 branch condition,
not merely seven runtime samples: counts <64 shift, counts >=64 fail, without masking.
AND/OR remain exact over all words. from_u64 still asserts <=2^53 before casting;
the ordinary source guard gives -22<=exponent<=22, mantissa<=2^53, !many_digits.
The disguised source arm checks its integer product and <=2^53 before the cast,
and uses fixed table index 22. Only then may conditional Binary64NativeCallDomain
supply finite non-NaN cast/table operands and a positive nonzero divisor.
Thus reached native arithmetic is exact; generic arithmetic NaNs retain permitted-choice
semantics, not universal exact-bit equivalence. Assembly admits every BiasedFp field pair.
Equal-target preservation retains both rounding relations to the same target, without
deriving uniqueness from vocabulary or assuming an unresolved GOAL conclusion.
All 32 original GOALs remain pursued with their own quantifiers, domains and polarity.
These source-facing checks are evidence, not preservation Sound certification or GOAL proofs.
Managed checks and final scope verification
===========================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py compose-native . --check
EXIT: 0
Selected raw result fields:
{
"full_result": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/compose-native-1791584636440554217.json",
"matches": true,
"changed": false,
"mismatched_files": [],
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
COMMAND: python3 .trellis/scripts/check.py model-support-check .
EXIT: 0
Raw result:
{"ok": true, "errors": []}
COMMAND: python3 .trellis/scripts/check.py tablet . --json
EXIT: 0
Structured projection from the final full managed JSON result:
{
"command": [
"python3",
".trellis/scripts/check.py",
"tablet",
".",
"--json"
],
"exit_status": 0,
"ok": true,
"errors": [],
"node_count": 340,
"all_nodes_compile": true,
"elaboration_failures": [],
"structure_failures": [],
"warning_count": 696,
"warning_examples": [
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:364:4: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:587:8: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/StringIter.lean:13:4: declaration uses `sorry`"
],
"raw_stdout_sha256": "15a1d03a085481d315bcc1a4716aa174475f03e72d8f452f5f33d45a71f5ed91",
"stderr_line_count": 340,
"raw_stderr_sha256": "50c8fde0aef24c1b87ce95c51d21794927d6abba46d90fd04a8d3a714bfed46e"
}
This final command was captured and summarized by
python3 .trellis/scratch/managed-tablet-summary.py (exit 0).
Two earlier identical whole-Tablet checks also exited 0; one jq projection
reported tablet_exit=0 jq_exit=0, node_count=340, failing_elaboration=[],
invalid_structure=[]. The first tool preview truncated its verbose JSON;
that truncation was not used as a proof-closure certificate. The retained
warnings include permitted principal GOAL sketches and installed Aeneas
Slice/StringIter sorry warnings. No definition was supplied with sorry.
These checks establish elaboration, structure and composition freshness,
not preservation Sound or proof closure of the pursued GOALs.
COMMAND: python3 .trellis/scratch/preservation-scope-check.py
EXIT: 0
Raw result:
{
"ok": true,
"owner_checks": [
{
"node": "Binary64ModelDefault",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "210652331cd53e0254aae45856663c01d0552fe992b69608fe243260022ccd79"
},
{
"node": "ModelF64Neg",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "f7d74d4558333c0754ccce8f6861d1409c049fd4dfd1825daad2fd2f441eb78f"
},
{
"node": "ModelU64BitAnd",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "b401e17a058ec2909fb7a58d01f07867f03a933c2901338efebda252692ca6ff"
},
{
"node": "ModelU64BitOr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "c53e3e5ad29cc4419d07c3f2a8913e0f4df87ecbcf4ac1567a9e699a2bd18e2d"
},
{
"node": "ModelU64Shl",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "ed68845da19138d7406e8022c5a9adb765ed70c2ed075f41aea7c190dea9909a"
},
{
"node": "ModelU64Shr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "04b6ec376e7ec490c64183f2a18be832ea574391d7f24d49db7ddc10019cd2f0"
}
],
"principal_goal_pairs": [
{
"node": "AssemblyCorrespondence",
"target": "assembly_correspondence",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationDeterminism",
"target": "classification_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationSignificandDigit",
"target": "classification_significand_digit",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationTotality",
"target": "classification_totality",
"paired_files_byte_unchanged": true
},
{
"node": "ExponentValueAgreement",
"target": "exponent_value_agreement",
"paired_files_byte_unchanged": true
},
{
"node": "IntegerCorrectOrDefer",
"target": "integer_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NativeCorrectOrDefer",
"target": "native_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAcceptance",
"target": "number_helper_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAccumulatedValue",
"target": "number_helper_accumulated_value",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRecordBounds",
"target": "number_helper_record_bounds",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRejection",
"target": "number_helper_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserAccumulatedRounding",
"target": "parser_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserEqualTargetRounding",
"target": "parser_equal_target_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserExactRounding",
"target": "parser_exact_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInfinity",
"target": "parser_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInvalidRejection",
"target": "parser_invalid_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNanAcceptance",
"target": "parser_nan_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNonNanResults",
"target": "parser_non_nan_results",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericAcceptance",
"target": "parser_numeric_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericSign",
"target": "parser_numeric_sign",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserSignedZero",
"target": "parser_signed_zero",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserTotality",
"target": "parser_totality",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_SlowAccumulatedRounding",
"target": "slow_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchAbstractComposition",
"target": "dispatch_abstract_composition",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchComponentCompliance",
"target": "dispatch_component_compliance",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedExponent",
"target": "parser_selected_exponent",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedMagnitudeSign",
"target": "parser_selected_magnitude_sign",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingDeterminism",
"target": "rounding_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingTotality",
"target": "rounding_totality",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperInfinity",
"target": "special_helper_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperNan",
"target": "special_helper_nan",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperRejection",
"target": "special_helper_rejection",
"paired_files_byte_unchanged": true
}
],
"new_nodes": [],
"evidence_consumers_for_current_Sound": [
"Binary64ModelDefault",
"DecimalGoalVocabularyDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"frozen_boundary_unchanged": true,
"pre_existing_config_delta_unchanged": true,
"changed_paths_in_assigned_scope": [
"Tablet/Binary64ModelDefault.tex",
"Tablet/ModelF64Neg.tex",
"Tablet/ModelU64BitAnd.tex",
"Tablet/ModelU64BitOr.tex",
"Tablet/ModelU64Shl.tex",
"Tablet/ModelU64Shr.tex",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
],
"completion_meaning_audit_still_required": true
}
Delivery, acceptance and certification status
============================================
The executed kernel task is task_id=11 (worker request 118), compiler=managed,
under trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91.
Submitted scope is exactly the six owners' preservation sections and ten
reserved evidence paths listed above. No acceptance/publication outcome is
available before worker delivery; the host's real receipt must supply it.
The raw-only worker validator and a Submitted marker mean delivery, not host
acceptance, publication, preservation Sound or Modeling completion.
Keep retry-binary64-preservation-exclusively live until actual publication,
and verify-published-preservation-and-meanings live until current certification.
After publication, request current Sound on all changed evidence consumers,
including DecimalGoalVocabularyDefault's u64-shl/u64-bitor citations, and
repaired support before parents whose named gaps remain open. Do not reset
Binary64ModelDefault's genuine VerifierFail based on these worker checks.
The independent all-32 original-GOAL meaning audit remains required before
Modeling completion; a byte-unchanged pair check is not that semantic audit.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-negation-probe.rs
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
reference/model-evidence/binary64-negation.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
Primary evidence for binary64 trait negation
============================================
Scope and conclusion
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction and the
nightly-2026-06-01 toolchain fixed by modeling-input/SETUP.md and
modeling-input/manifest.json. It establishes the following statement for the
specific extracted Rust operation bound to ModelF64Neg:
For every u64 word w, including every signaling or quiet NaN payload,
to_bits(<f64 as core::ops::Neg>::neg(f64::from_bits(w)))
equals w XOR 0x8000000000000000.
Thus precisely bit 63 is toggled and every other bit is preserved. This is a
universal symbolic result, not an inference from finitely many test inputs.
Pinned identities
-----------------
The following command was run from the repository root. RROOT is the source
tree installed with the configured compiler.
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
RROOT=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
sha256sum "$R" \
"$RROOT/core/src/ops/arith.rs" \
"$RROOT/core/src/primitive_docs.rs" \
crate/dec2flt/mod.rs upstream/dec2flt/mod.rs \
generated.lean Tablet/model-support.json \
modeling-input/tool-identities.json \
reference/model-evidence/binary64-negation-probe.rs
Raw output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
modeling-input/tool-identities.json records the same rustc path and SHA-256.
The compiler reports:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Concrete core implementation
----------------------------
The following exact excerpt is core/src/ops/arith.rs:709-728 in the source
whose SHA-256 is 596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0:
macro_rules! neg_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const Neg for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> $t { -self }
}
forward_ref_unop! { impl Neg, neg for $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
The macro invocation explicitly includes f64. Its expansion is therefore the
concrete `impl Neg for f64`, with `Output = f64`, whose method body is the
primitive expression `-self`.
Frozen parser statement and primitive guarantee
------------------------------------------------
The adapted frozen parser and supplied upstream parser have identical text at
dec2flt/mod.rs:20-22. Their complete-file hashes are pinned above. The exact
three lines are:
//! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
//! process and re-apply it at the very end. This is correct in all edge cases since IEEE
//! floats are symmetric around zero, negating one simply flips the first bit.
The installed primitive documentation is pinned above by SHA-256
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5.
At primitive_docs.rs:1369-1375 it identifies f64 as binary64 and directs the
reader to the f32 documentation for the common floating-point rules:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The exact common rule at primitive_docs.rs:1256-1260 is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
This rule expressly covers unary negation and bit conversion, and expressly
distinguishes them from arithmetic NaN production. It therefore preserves the
quiet/signaling bit and every payload bit for NaNs as well as all non-sign bits
for finite values, zeros, and infinities. The parser statement identifies the
permitted sign-bit change as an actual flip in all edge cases.
Extraction and support binding
------------------------------
The frozen generated.lean, pinned above, contains this exact declaration and
trait implementation record:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
/-- Trait implementation: [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}]
Source: '/rustc/library/core/src/ops/arith.rs', lines 713:8-713:29
Name pattern: [core::ops::arith::Neg<f64, f64>] -/
@[reducible, rust_trait_impl "core::ops::arith::Neg<f64, f64>"]
def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
neg := F64.Insts.CoreOpsArithNegF64.neg
}
Thus the extracted external is the same f64 macro expansion and method body
identified above, not an abstract or different negation operation. Running
`python3 .trellis/scripts/pv_modeling.py inspect-native "$PWD"` and selecting
that declaration gives the following raw inventory fields:
name: F64.Insts.CoreOpsArithNegF64.neg
extracted_signature: : F64 → Result F64
rust_symbol: core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
raw_declaration_sha256: bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0
The raw declaration hash is independently reproduced after that inspection by:
I=$(ls -1t .trellis/scratch/inspect-native-*.json | head -n 1)
jq -j '.. | objects | select(.name? == "F64.Insts.CoreOpsArithNegF64.neg") | .source_utf8' "$I" | sha256sum
Raw output:
bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0 -
Tablet/model-support.json, whose complete-file hash is pinned above, copies all
four identity fields unchanged and binds this external to the model definition:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
Symbolic same-toolchain probe
-----------------------------
The retained probe source is:
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
The argument is an arbitrary symbolic u64. The qualified call forces the same
`Neg for f64` trait method identified by the core source and extraction. The
following exact commands use the extraction's compiler and target and retain
both optimized LLVM IR and assembly in the worker scratch directory:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-negation-probe.rs
IR=.trellis/scratch/binary64-negation-probe.ll
ASM=.trellis/scratch/binary64-negation-probe.s
"$R" --version --verbose
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir "$P" -o "$IR"
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm "$P" -o "$ASM"
sha256sum "$R" "$P" "$IR" "$ASM"
cat "$IR"
cat "$ASM"
Raw hash output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
Raw optimized LLVM IR function:
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
Raw optimized x86_64 assembly function:
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
Under the selected x86_64 C ABI, the symbolic input w arrives in %rdi and the
u64 result is returned in %rax. The loaded signed decimal constant
-9223372036854775808 has u64 bit pattern 0x8000000000000000, with bit 63 set
and every other bit clear. The emitted `xorq %rdi, %rax` therefore returns
w XOR 0x8000000000000000. There is no branch, floating-point exceptional
case, or input precondition in the emitted function.
Universal preservation conclusion
---------------------------------
The core macro and f64 instantiation connect the trait method to primitive
unary `-`; generated.lean and model-support.json connect that exact method to
ModelF64Neg. The parser source says the operation flips the sign bit in all
edge cases, while the primitive guarantee says every non-sign bit is preserved,
including the quiet/signaling and payload bits of NaNs. Finally, the symbolic
same-compiler/same-target probe makes the exact transformation explicit as XOR
with the bit-63 mask for its arbitrary u64 argument.
Because f64::from_bits accepts every one of the 2^64 u64 words and to_bits
returns the resulting raw word, the symbolic input covers the entire modeled
F64 carrier. Consequently the source result for every word is exactly the
model package's `ok` result containing that word with bit 63 toggled. This
includes both signs of zero and infinity, every finite/subnormal word, and
every possible NaN payload without canonicalization or quieting.
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/u64-bitand.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitAnd preservation evidence
================================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitAnd. The commands below were run from the repository
root on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790258751442882118.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790258751442882118.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790258751442882118.json
The exact U64 BitAnd entry in that index is:
name: U64.Insts.CoreOpsBitBitAndU64U64.bitand
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
source: /rustc/library/core/src/ops/bit.rs, lines 178:12-178:42
raw_declaration_sha256: 36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitAndU64U64.bitand") | .source_utf8' \
.trellis/scratch/inspect-native-1790258751442882118.json | sha256sum
Output:
36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line ranges are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '170,187p'
The pinned source says at lines 170-179:
macro_rules! bitand_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitAnd for $t {
type Output = $t;
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
and line 187 instantiates that implementation for u64:
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 conjunction `self & rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
--------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 105-116 and theorem at line 274 are:
def UScalar.and {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv &&& y.bv ⟩
instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where
hAnd x y := UScalar.and x y
theorem UScalar.bv_and {ty} (x y : UScalar ty) :
(x &&& y).bv = x.bv &&& y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 148-153 prove, for every width and bit index:
theorem BitVec.getElem!_and {w} (x y : BitVec w) (i : Nat) :
(x &&& y)[i]! = (x[i]! && y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_and, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.and_self]
Therefore `x &&& y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean conjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-bitor.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitOr preservation evidence
===============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitOr. The commands below were run from the repository root
on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790259866184055823.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790259866184055823.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790259866184055823.json
The exact U64 BitOr entry in that index is:
name: U64.Insts.CoreOpsBitBitOrU64U64.bitor
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
source: /rustc/library/core/src/ops/bit.rs, lines 282:12-282:41
raw_declaration_sha256: 85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitOrU64U64.bitor") | .source_utf8' \
.trellis/scratch/inspect-native-1790259866184055823.json | sha256sum
Output:
85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line range are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '274,291p'
The pinned source says at lines 274-289:
macro_rules! bitor_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitOr for $t {
type Output = $t;
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
forward_ref_binop! { impl BitOr, bitor for $t, $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
and line 291 instantiates that implementation for u64:
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 disjunction `self | rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
-------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 118-126 and theorem at line 275 are:
def UScalar.or {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv ||| y.bv ⟩
instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where
hOr x y := UScalar.or x y
theorem UScalar.bv_or {ty} (x y : UScalar ty) :
(x ||| y).bv = x.bv ||| y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 141-146 prove, for every width and bit index:
theorem BitVec.getElem!_or {w} (x y : BitVec w) (i : Nat) :
(x ||| y)[i]! = (x[i]! || y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_or, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.or_self]
Therefore `x ||| y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean disjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-shl-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x << count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shl.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shl preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shl. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a bounded U64 shift, and all U32 counts at least
64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790260978718245524.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790260978718245524.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790260978718245524.json
The exact U64 Shl entry in that fresh index is:
name: U64.Insts.CoreOpsBitShlU32U64.shl
extracted_signature: : Std.U64 → Std.U32 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
source: /rustc/library/core/src/ops/bit.rs, lines 489:12-489:41
raw_declaration_sha256: e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShlU32U64.shl") | .source_utf8' \
.trellis/scratch/inspect-native-1790260978718245524.json | sha256sum
Output:
e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d -
Thus this boundary is specifically u64 shifted by u32, and its extracted
codomain is the Aeneas Result used below to distinguish normal return from
checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '479,520p'
Lines 479-498 define the implementation macro:
macro_rules! shl_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shl<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shl(self, other: $f) -> $t {
self << other
}
}
forward_ref_binop! { impl Shl, shl for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 500-518 apply `shl_impl! { $t, u32 }` to every type in
`shl_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shl_impl_all {
($($t:ty)*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
shl_impl! { $t, u64 }
shl_impl! { $t, u128 }
shl_impl! { $t, usize }
...
)*)
}
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shl<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self << other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shl-probe.rs
with SHA-256:
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8
It places the same primitive expression `x << count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
./u64-shl-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir \
../../reference/model-evidence/u64-shl-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shl` operation and returns its bounded 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with the
expected truncation to 64 bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 17-21 and 29-31 define:
def UScalar.shiftLeft {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.shiftLeft s ⟩
else fail .integerOverflow
def UScalar.shiftLeft_UScalar {ty tys} (x : UScalar ty) (s : UScalar tys) :
Result (UScalar ty) :=
x.shiftLeft s.val
Lines 81-82 resolve the notation used by Tablet/ModelU64Shl.lean:
instance {ty0 ty1} : HShiftLeft (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftLeft x y := UScalar.shiftLeft_UScalar x y
Consequently `x <<< y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the 64-bit vector shift; at least 64 it is
exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftLeft_spec`, lines 193-205, proves the successful
branch has both equivalent bounded descriptions:
theorem UScalar.ShiftLeft_spec ... (hy : y.val < ty0.numBits) ... :
(x <<< y) ⦃ z =>
z.val = (x.val <<< y.val) % size ∧
z.bv = x.bv <<< y.val ⦄
For U64, `size` is `2^64`; hence the returned natural value is the mathematical
left shift reduced modulo `2^64`, and the returned carrier is exactly the
corresponding 64-bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 248-266 give the bit-level characterization: every result bit below
the shift count (or outside the fixed width) is false, and every in-width bit at
or above the count equals the corresponding input bit at index `i - n`:
theorem BitVec.getElem!_shiftLeft_false ...
(h : i < n ∨ w ≤ i) : (v <<< n)[i]! = false
theorem BitVec.getElem!_shiftLeft_eq ...
(h : n ≤ i ∧ i < w) : (v <<< n)[i]! = v[i - n]!
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive U64 shift. The Aeneas branch condition also succeeds and returns
`ok` of `BitVec.shiftLeft n`. `UScalar.ShiftLeft_spec` and the BitVec lemmas
identify both results as the same 64-bit word, equivalently `(x * 2^n) mod
2^64`, with discarded high bits and zero-filled low bits.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shl preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
reference/model-evidence/u64-shr-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x >> count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shr.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shr preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shr. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a logical U64 right shift, and all U32 counts at
least 64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790262316075577976.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790262316075577976.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790262316075577976.json
The exact U64 Shr entry in that fresh index is:
name: U64.Insts.CoreOpsBitShrU32U64.shr
extracted_signature: : Std.U64 -> Std.U32 -> Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
source: /rustc/library/core/src/ops/bit.rs, lines 612:12-612:41
raw_declaration_sha256: 77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 -> Std.U32 -> Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShrU32U64.shr") | .source_utf8' \
.trellis/scratch/inspect-native-1790262316075577976.json | sha256sum
Output:
77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f -
Tablet/model-support.json binds precisely this indexed declaration and
signature to dec2flt_model.ModelU64Shr. Thus the boundary is specifically u64
shifted by u32, and its extracted codomain is the Aeneas Result used below to
distinguish normal return from checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '602,641p'
Lines 602-620 define the implementation macro:
macro_rules! shr_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shr<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shr(self, other: $f) -> $t {
self >> other
}
}
forward_ref_binop! { impl Shr, shr for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 623-641 apply `shr_impl! { $t, u32 }` to every type in
`shr_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shr_impl_all {
($($t:ty)*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
shr_impl! { $t, u64 }
shr_impl! { $t, u128 }
shr_impl! { $t, usize }
...
)*)
}
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shr<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self >> other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shr-probe.rs
with SHA-256:
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee
It places the same primitive expression `x >> count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
./u64-shr-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir \
../../reference/model-evidence/u64-shr-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shr` operation and returns its logical 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with
zero-filled high bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 23-35 define:
def UScalar.shiftRight {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.ushiftRight s ⟩
else fail .integerOverflow
def UScalar.shiftRight_UScalar {ty tys} (x : UScalar ty)
(s : UScalar tys) : Result (UScalar ty) :=
x.shiftRight s.val
Lines 93-94 resolve the notation used by Tablet/ModelU64Shr.lean:
instance {ty0 ty1} : HShiftRight (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftRight x y := UScalar.shiftRight_UScalar x y
Consequently `x >>> y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the unsigned 64-bit vector shift; at least
64 it is exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftRight_spec`, lines 166-174, proves the successful
branch has both equivalent logical-shift descriptions:
theorem UScalar.ShiftRight_spec ... (hy : y.val < ty0.numBits) :
(x >>> y) ⦃ z =>
z.val = x.val >>> y.val ∧
z.bv = x.bv >>> y.val ⦄
Here natural-number `>>>` is division by `2^y.val`, so the returned numeric
value is `floor(x.val / 2^y.val)`, and the returned carrier is exactly the
unsigned shift of the fixed-width bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 268-283 give the bit-level logical zero-fill characterization. For
every result position, the total bit lookup is the input bit at the offset
position; positions whose offset is outside the 64-bit input are false:
theorem BitVec.getElem!_shiftRight {w} (v : BitVec w) (n i : Nat) :
(v >>> n)[i]! = v[n + i]!
theorem BitVec.getElem_shiftRight_false {m n : Nat} (v : BitVec m)
(hm : i < m) (h : m <= n + i) :
(v >>> n)[i]'hm = false
Together with `BitVec.getElem_shiftRight_lt`, this states that every in-range
source bit moves downward by the count and every newly exposed high bit is
zero. Because the carrier is unsigned, there is no sign extension.
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive unsigned U64 right shift. The Aeneas branch condition also
succeeds and returns `ok` of `BitVec.ushiftRight n`. `UScalar.ShiftRight_spec`
and the BitVec lemmas identify both results as the same 64-bit word,
equivalently `floor(x / 2^n)`, with every newly exposed high bit filled by zero.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shr preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
Assumptions / kernel axioms
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:45a22ba5ce0a622d07615411d02dfc2e10cb3aa1fa5a905e24fd0c754155f165 |
| Preservation current fingerprint | preservation-v1:45a22ba5ce0a622d07615411d02dfc2e10cb3aa1fa5a905e24fd0c754155f165 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","lean_semantic_closure":"04e1b81bf028ff964b48f52dab02eb081dc327262e2d8152947aee00dc27c1b3","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","lean_semantic_closure":"04e1b81bf028ff964b48f52dab02eb081dc327262e2d8152947aee00dc27c1b3","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "9498c80852cd0a3b7da6e2f5aa672111b8b149484638fc9121d049dcff9f7145",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:45a22ba5ce0a622d07615411d02dfc2e10cb3aa1fa5a905e24fd0c754155f165"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T2_current-applicability.txt",
"sha256": "aefdc935645f37c69a2c3f2e7c2fb00baad81970455148f3dbb591b0eeabced3",
"cited_by": [
"Tablet/ModelU64BitOr.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation-probe.rs",
"sha256": "268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation.txt",
"sha256": "e19a2cd2283c8435f6d6107d06ccc798cbba4d63f0220b32b5216e43ad071aac",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/u64-bitand.txt",
"sha256": "6a48b1a79f8a52a27fb06a0b25cda9de24f68395d66ab668ecac721806883f54",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-bitor.txt",
"sha256": "f3dadaec6c4ebc98d0d3178bf29df7436e52998b6b97e8d108ca97a6f8092e70",
"cited_by": [
"Tablet/ModelU64BitOr.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl-probe.rs",
"sha256": "a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shl.txt"
]
},
{
"path": "reference/model-evidence/u64-shl.txt",
"sha256": "e4cacfd29333a91c1258524a520e849325a85a05cf50b0065ffbf91d7977f69c",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shr-probe.rs",
"sha256": "11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/u64-shr.txt",
"sha256": "c0295af2452a4748bc1a642580414acfc76285ba87b6203b6cbff7ff9924b6ad",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
}
]core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
Inspect related source (1)
- shl · core/src/ops/bit.rs:489 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl |
|---|---|
| Recorded source | /rustc/library/core/src/ops/bit.rs |
| Lines | 489:12–489:41 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Std.U64 → Std.U32 → Result Std.U64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelU64Shl]
def ModelU64Shl (x : Std.U64) (y : Std.U32) : Result Std.U64 :=
-- BODY
x <<< y
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
inspect-native result, exact declaration and binding identities,
complete relevant call inventory, checked compiler/library/configuration
identities, and reproduced checked probe and general MIR are in
reference/model-evidence/P89_T2_current-applicability.txt.
The restored source is directly retained at
reference/model-evidence/u64-shl-probe.rs.
That current inspection identifies this exact external as
Shl<u32> for u64, with signature
Std.U64 -> Std.U32 -> Result Std.U64, its Rust source span, and its
raw declaration hash. At that span the approved rust-src defines the method as
self << other, instantiates it for u64/u32, and
marks it rustc_inherit_overflow_checks. The frozen Cargo profiles
enable overflow checks and use unwinding panics; a same-toolchain probe and MIR
show the general dynamic-count guard n < 64, followed by the bounded
u64 shift on success and the checked-overflow unwind edge otherwise.Std.U64 and Std.U32 are
respectively 64- and 32-bit unsigned scalar carriers. The <<<
instance resolves through UScalar.shiftLeft_UScalar to a branch on
the count's full unsigned value. Below 64 it returns ok of
BitVec.shiftLeft; the pinned scalar specification and bit-vector
lemmas identify its value as the mathematical left shift modulo 2^{64} and
its bits as the exact zero-filled, high-bit-truncated 64-bit shift. At 64 or
above it returns fail integerOverflow. Thus, case by case over every
32-bit count, the binding and Rust both produce the same bounded 64-bit result
below 64, while the Rust checked-shift panic and the extracted Aeneas
integerOverflow failure correspond at 64 and above. No
source-reachability restriction is used.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelU64Shl · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T2_current-applicability.txt
Current applicability of reused binary64 and U64 preservation evidence
Task 11 / worker request 118; checked in the current private checkout.
All commands below ran in this assignment; EXIT records the command status.
Rust commands use LD_LIBRARY_PATH=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib
and RUSTUP_TOOLCHAIN=nightly-2026-06-01.
The managed Lean commands are recorded separately, not invoked by this script.
Reuse and scope
===============
Read-only predecessor: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002
The historical 45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
generated.lean hash belongs to that predecessor, never the current extraction.
The old primary evidence retains its original commands, raw identities and results.
Current checks below establish applicability; prior worker task 9 was rejected,
accepted=false, and its self-report is neither publication nor certification.
Only preservation sections of the six listed owners and ten reserved evidence paths
are submitted. No ordinary statement, Lean computation, GOAL pair, source, extraction,
provenance, Preamble, binding, dispatcher owner or existing config delta is edited.
No new node, route, under-model premise, GOAL decline or polarity change is proposed.
The new 2^59 exponent fold, final-point repair and A/B GOAL domains are not old semantics.
Unchanged primitive meanings are reused, not old parser correctness or old counterexamples.
{
"task_execution": {
"binding": {
"allowed_tasks": [
"ordinary",
"lean_closure"
],
"lightweight": false,
"max_timeout_seconds": 14400,
"model": "gpt-6.1-sol",
"provider": "codex",
"reasoning_effort": "xhigh",
"timeout_seconds": 14400
},
"compiler": "managed",
"profile": "sol-xhigh",
"task_id": 11,
"task_kind": "ordinary"
},
"acceptance_logic_identity": "trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91",
"parallel_scope": {
"exclusive": true,
"helper_prefixes": [
"P116_T1_"
],
"nodes": [
"Binary64ModelDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"shared_writes": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
]
}
}
Current file, compiler, configuration and library identities
============================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum GOAL.md generated.lean Tablet/model-support.json modeling-input/manifest.json modeling-input/extraction.json modeling-input/tool-identities.json modeling-input/SETUP.md modeling-input/revision-from.json crate/Cargo.toml crate/rust-toolchain.toml lean-toolchain lakefile.lean lake-manifest.json trellis.config.json reference/model-evidence/binary64-boundary.txt crate/dec2flt/common.rs crate/dec2flt/decimal.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/fpu.rs crate/dec2flt/lemire.rs crate/dec2flt/mod.rs crate/dec2flt/parse.rs crate/dec2flt/slow.rs crate/dec2flt/table.rs crate/lib.rs crate/num/imp/mod.rs crate/num/mod.rs crate/traits.rs upstream/dec2flt/common.rs upstream/dec2flt/decimal.rs upstream/dec2flt/decimal_seq.rs upstream/dec2flt/fpu.rs upstream/dec2flt/lemire.rs upstream/dec2flt/mod.rs upstream/dec2flt/parse.rs upstream/dec2flt/slow.rs upstream/dec2flt/table.rs upstream/traits.rs reference/model-evidence/binary64-probe.rs reference/model-evidence/binary64-negation-probe.rs reference/model-evidence/u64-shl-probe.rs reference/model-evidence/u64-shr-probe.rs Tablet/Binary64ModelDefault.lean Tablet/ModelF64Neg.lean Tablet/ModelU64BitAnd.lean Tablet/ModelU64BitOr.lean Tablet/ModelU64Shl.lean Tablet/ModelU64Shr.lean
EXIT: 0
STDOUT:
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
1a7d2eea7888b7bdb0421ed6bb96c5ee1e80afe8e788438cd30725f2120a2aea modeling-input/revision-from.json
10584b73664d42dc85fb009bb0783a616520c2cc05f3b0f8c64e5d5cb32e2905 crate/Cargo.toml
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
8dab550b59cec828a4ba436bc25ce9ad66547bdd7f55899b8cbf7e4f65389518 lakefile.lean
a5f9756cd42129193c0285127cddb734224e9c69686fc2de56de2c9d48ed0695 lake-manifest.json
d8fceb13f84ecbf5bf6e9fd7ecdcb061569cfabdb0079243e2eb1609d012ac02 trellis.config.json
749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e reference/model-evidence/binary64-boundary.txt
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b crate/lib.rs
df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1 crate/num/imp/mod.rs
d84067991b142196281bc0968d32634bdcdb9a3a41c2ce2fd3c344d0f61504af crate/num/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e reference/model-evidence/binary64-probe.rs
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8 reference/model-evidence/u64-shl-probe.rs
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee reference/model-evidence/u64-shr-probe.rs
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3 Tablet/Binary64ModelDefault.lean
9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2 Tablet/ModelF64Neg.lean
3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179 Tablet/ModelU64BitAnd.lean
aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f Tablet/ModelU64BitOr.lean
af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad Tablet/ModelU64Shl.lean
54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b Tablet/ModelU64Shr.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo /home/leanagent/pv_spike/tools/charon/bin/charon /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
EXIT: 0
STDOUT:
54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade /home/leanagent/pv_spike/tools/charon/bin/charon
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
STDERR:
(empty)
All installed tool hashes equal the current tool-identities.json pins.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
EXIT: 0
STDOUT:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print cfg --target x86_64-unknown-linux-gnu
EXIT: 0
STDOUT:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat crate/Cargo.toml modeling-input/extraction.json
EXIT: 0
STDOUT:
# Standalone extraction package for the supplied `core::num::dec2flt` slice.
# The package metadata and profiles select the configured environment; source
# correspondence and extraction adaptations are recorded in ../SETUP.md and
# local preservation comments.
[package]
name = "dec2flt-model"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
path = "lib.rs"
[features]
default = []
optimize_for_size = []
[profile.dev]
overflow-checks = true
[profile.release]
overflow-checks = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(target_has_reliable_f16)"] }
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
STDERR:
(empty)
Current effective tools:
{
"aeneas": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"cargo": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"charon": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"env": {
"LD_LIBRARY_PATH": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib",
"RUSTUP_TOOLCHAIN": "nightly-2026-06-01"
},
"lean": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"lean_paths": [
"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean"
],
"readonly": [
"/home/leanagent/pv_spike/tools",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages"
],
"timeouts": {
"aeneas": 3600,
"cargo": 600,
"charon": 600,
"lean": 3600
}
}
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
EXIT: 0
STDOUT:
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
EXIT: 0
STDOUT:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
100644 blob f8582928fe49a0ce75e143b46bb0a8826d7fddae backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
100644 blob d3eb5022efc22d1d6c3ac055965f612c7f2fbca9 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
100644 blob f7bc57109569cdd0fb0c3323021c73673dcfcd33 backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
100644 blob e5733a774268c8dee71bd4ba402240d151bb8cb8 backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
Predecessor pair and probe reuse checks
=======================================
Tablet/Binary64ModelDefault.lean: predecessor_sha256=03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3; whole Lean byte-identical.
Tablet/Binary64ModelDefault.tex: predecessor_sha256=57c6e9ed282cf2dd718f822c6a31255040c71b5c7531488f3951d9c4d4d8b822; ordinary NL definition byte-identical.
Tablet/ModelF64Neg.lean: predecessor_sha256=9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2; whole Lean byte-identical.
Tablet/ModelF64Neg.tex: predecessor_sha256=9d2811046df611e45e2637da57241bace75c3de5822e03126de5f1fc9faeb859; ordinary NL definition byte-identical.
Tablet/ModelU64BitAnd.lean: predecessor_sha256=3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179; whole Lean byte-identical.
Tablet/ModelU64BitAnd.tex: predecessor_sha256=db8a1445918e94fd1c11f92f1c5f218f165aec945ac2ebdeda3cc1675165f8fe; ordinary NL definition byte-identical.
Tablet/ModelU64BitOr.lean: predecessor_sha256=aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f; whole Lean byte-identical.
Tablet/ModelU64BitOr.tex: predecessor_sha256=fbbb37c3cfa81c5811869baf46671d93a6c457042f0a5bbb78ba32c26607dbe2; ordinary NL definition byte-identical.
Tablet/ModelU64Shl.lean: predecessor_sha256=af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad; whole Lean byte-identical.
Tablet/ModelU64Shl.tex: predecessor_sha256=725582880c20b16d00487e01aceb0552a39263616563280cee0d49635984beab; ordinary NL definition byte-identical.
Tablet/ModelU64Shr.lean: predecessor_sha256=54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b; whole Lean byte-identical.
Tablet/ModelU64Shr.tex: predecessor_sha256=3def4409d97d8316d4d77dc2fe01c4142219859ea9596b835ac40f83c3a18784; ordinary NL definition byte-identical.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-negation-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-negation-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shl-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shr-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
Current raw declarations and exact support bindings
===================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py inspect-native .
EXIT: 0
STDOUT:
{
"full_index": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json",
"declaration_count": 24,
"declarations": [
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 \u2192 Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 \u2192 Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 \u2192 Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 \u2192 Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 \u2192 Std.U64 \u2192 Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02"
}
],
"declarations_omitted": 9
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
EXIT: 0
STDOUT:
fbe3b76ef8fbb588841979e071c52eee0fc850472ac55da6f2ca2033e4a34cf4 /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
STDERR:
(empty)
RAW DECLARATION:
/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:
Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43
Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]
Visibility: public -/
@[rust_fun "core::clone::impls::{core::clone::Clone<f64>}::clone"]
axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dfbdb508142706b4c716f701e52a26d63d764f088dacfa461dd81c6df0b9bf0d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_DIGITS]
Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34
Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_DIGITS"]
axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 19dc0621c0c5c7d2a24f090dd7870ffa858de15fc4e1cc7bf57f16d64816c9bc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NAN]
Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22
Name pattern: [core::f64::{f64}::NAN]
Visibility: public -/
@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 75cd3ccca5992f42ef5afa9287573410d249d40f9bcc3120fae72389b2e2419d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27
Name pattern: [core::f64::{f64}::INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::INFINITY"]
axiom core.f64.F64.INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 9a5fb08a6bae926bafdba709d6da6aaad52b8f41c7dbf3e4b2a28b2bc0542716
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NEG_INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31
Name pattern: [core::f64::{f64}::NEG_INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::NEG_INFINITY"]
axiom core.f64.F64.NEG_INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f5d6435579e1da8caecfc1a3b0039a0ce4e250e7dc55c4c69f3edbdd2a5a10f6
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::EXPONENT_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32
Name pattern: [core::f64::{f64}::EXPONENT_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::EXPONENT_MASK"]
axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dcd87a62501dc8e76079204a4b43546a4750077e1f425f01dcd58c96bf31a865
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32
Name pattern: [core::f64::{f64}::MANTISSA_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_MASK"]
axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): cf1585ae2e94a7bf5bb6b5ff37a06a0677b7e8d81420c1e0ca7ee29eca8cfd4c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::classify]:
Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45
Name pattern: [core::f64::{f64}::classify]
Visibility: public -/
@[rust_fun "core::f64::{f64}::classify"]
axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
IDENTITY AND BINDING:
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 7cf497c5bfc31455d5490d5da75914d7eaf9e522aa2eccd14fe9935502b5127c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::to_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37
Name pattern: [core::f64::{f64}::to_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::to_bits"]
axiom core.f64.F64.to_bits : F64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b35203125fea8ba89df874b609344bbe8ad61a61fcb946a184a72c729a1e3364
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::from_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42
Name pattern: [core::f64::{f64}::from_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::from_bits"]
axiom core.f64.F64.from_bits : Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f819b0951f4f63943abf8d4787a2f9489ffd1137fa91529e0771a303bc8fcb94
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41
Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul"]
axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 4adead3b54aa85bfb81b7122b0e942b2c6f3d232d548d8361a2a2ca067be1e7f
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41
Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div"]
axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 62ca24414fa18ef9709d7c5703429d7262f27d017abc975ffb532ae284ba054a
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 945f30e7dbb62802e6ba5bb9d9445e100528b2a52d3b0b6a3a0629c939ff9860
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b66bd94c28f512804622c3717705dbe7ef5a3ced5beaac7435704d053038c36e
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 68909ba4060a48df31ea54bcf0510b089709a3a644c9c1b0770780a98d31f4cc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 5c0105f2c7ce3d255f053e0ccbefa65f73f65de1462832217571cf8cd4963e47
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f100256a450680392496fb74934592e9e2822a1648320153e27c1c0d100ff482
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5
Visibility: public -/
axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
: Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 0bb769d884e3d54d7aa94163fdf4c8fc589050ed84f4fa0d11f694cf599cdb8f
All four identity fields and full raw declaration equal predecessor; current binding matches.
Complete relevant call and wiring inventories
=============================================
This deliberately includes record wiring and scalar lowerings, not just direct external calls.
The four U64 external trait fields wire into Int; generic scalar notation in generated.lean
also lowers directly to the installed operations with the same full-domain meanings.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n 'F64\.Insts\.(CoreClone|CoreOpsArith)|core\.f64\.F64\.|U64\.Insts\.CoreOpsBit|coreops(bit|arith)|\.from_u64|\.pow10_fast_path|FloatInst\.(INFINITY|NEG_INFINITY|NAN|NEG_NAN|SIG_|EXP_|INFINITE_POWER)|&&&|\|\|\||<<<|>>>' generated.lean
EXIT: 0
STDOUT:
25:axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
31:def F64.Insts.CoreCloneClone : core.clone.Clone F64 := {
32: clone := F64.Insts.CoreCloneClone.clone
40: cloneInst := F64.Insts.CoreCloneClone
48:axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
54:@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
61:axiom core.f64.F64.INFINITY : Result F64
68:axiom core.f64.F64.NEG_INFINITY : Result F64
75:axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
82:axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
101:axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
108:axiom core.f64.F64.to_bits : F64 → Result Std.U64
115:axiom core.f64.F64.from_bits : Std.U64 → Result F64
138:axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
144:def F64.Insts.CoreOpsArithMulF64F64 : core.ops.arith.Mul F64 F64 F64 := {
145: mul := F64.Insts.CoreOpsArithMulF64F64.mul
162:axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
168:def F64.Insts.CoreOpsArithDivF64F64 : core.ops.arith.Div F64 F64 F64 := {
169: div := F64.Insts.CoreOpsArithDivF64F64.div
185:axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
191:def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
192: neg := F64.Insts.CoreOpsArithNegF64.neg
200:axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
207:def U64.Insts.CoreOpsBitBitAndU64U64 : core.ops.bit.BitAnd Std.U64 Std.U64
209: bitand := U64.Insts.CoreOpsBitBitAndU64U64.bitand
226:axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
233:def U64.Insts.CoreOpsBitBitOrU64U64 : core.ops.bit.BitOr Std.U64 Std.U64
235: bitor := U64.Insts.CoreOpsBitBitOrU64U64.bitor
252:axiom U64.Insts.CoreOpsBitShlU32U64.shl
259:def U64.Insts.CoreOpsBitShlU32U64 : core.ops.bit.Shl Std.U64 Std.U32 Std.U64
261: shl := U64.Insts.CoreOpsBitShlU32U64.shl
278:axiom U64.Insts.CoreOpsBitShrU32U64.shr
285:def U64.Insts.CoreOpsBitShrU32U64 : core.ops.bit.Shr Std.U64 Std.U32 Std.U64
287: shr := U64.Insts.CoreOpsBitShrU32U64.shr
393: let i ← lift (a ||| b)
394: let i1 ← lift (i &&& 9259542123273814144#u64)
635: coreopsbitShrSelfU32SelfInst : core.ops.bit.Shr Self Std.U32 Self
636: coreopsbitShlSelfU32SelfInst : core.ops.bit.Shl Self Std.U32 Self
637: coreopsbitBitAndInst : core.ops.bit.BitAnd Self Self Self
638: coreopsbitBitOrInst : core.ops.bit.BitOr Self Self Self
664: coreopsarithDivInst : core.ops.arith.Div Self Self Self
665: coreopsarithNegInst : core.ops.arith.Neg Self Self
666: coreopsarithMulInst : core.ops.arith.Mul Self Self Self
726: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
727: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
728: (coreopsarithNegInst : core.ops.arith.Neg F F)
739: let value ← LemireInst.from_u64 self.mantissa
746: let t ← LemireInst.pow10_fast_path i2
747: coreopsarithDivInst.div value t
751: let t ← LemireInst.pow10_fast_path i1
752: coreopsarithMulInst.mul value t
754: then let t ← coreopsarithNegInst.neg value1
769: let t ← LemireInst.from_u64 val
771: let t1 ← LemireInst.pow10_fast_path i4
772: let value ← coreopsarithMulInst.mul t t1
774: then let t2 ← coreopsarithNegInst.neg value
1018: let i5 ← lift (1#u8 &&& i4)
1219: let shift1 ← lift (shift &&& 63#usize)
1228: let i1 ← x_a >>> 11#i32
1230: let i2 ← lift (2047#u16 &&& x_a)
1232: let i3 ← lift (2047#u16 &&& x_b)
1264: let i2 ← i1 <<< shift
1370: let i ← n >>> shift
1400: let i ← n >>> shift
1451: let i1 ← n >>> shift
1453: let i2 ← lift (n &&& mask)
1490: let i ← n >>> shift
1492: let i1 ← lift (n &&& mask)
1544: let i4 ← 1#u64 <<< shift
1704: let i3 ← 1#i64 <<< 59#i32
2971: let i3 ← r >>> 64#i32
2990: then 18446744073709551615#u64 >>> precision
3000: let i4 ← lift (first_hi &&& mask)
3016: let i2 ← i1 >>> 16#i32
3028: let i ← traitsFloatInst.INFINITE_POWER
3045: let w1 ← w <<< lz
3046: let i5 ← traitsFloatInst.SIG_BITS
3058: let i8 ← hi >>> 63#i32
3064: let mantissa ← hi >>> i12
3070: let i18 ← traitsFloatInst.EXP_MIN
3081: let mantissa1 ← mantissa >>> i22
3082: let i23 ← lift (mantissa1 &&& 1#u64)
3084: let mantissa3 ← mantissa2 >>> 1#i32
3085: let i24 ← 1#u64 <<< i5
3102: let i24 ← lift (mantissa &&& 3#u64)
3108: let i28 ← mantissa <<< i27
3111: ok (mantissa &&& i29)
3117: let i20 ← lift (mantissa1 &&& 1#u64)
3119: let mantissa3 ← mantissa2 >>> 1#i32
3120: let i21 ← 2#u64 <<< i5
3125: let mantissa5 ← 1#u64 <<< i5
3129: let i22 ← 1#u64 <<< i5
3131: let mantissa5 ← lift (mantissa4 &&& i23)
3137: let i8 ← hi >>> 63#i32
3143: let mantissa ← hi >>> i12
3149: let i18 ← traitsFloatInst.EXP_MIN
3160: let mantissa1 ← mantissa >>> i22
3161: let i23 ← lift (mantissa1 &&& 1#u64)
3163: let mantissa3 ← mantissa2 >>> 1#i32
3164: let i24 ← 1#u64 <<< i5
3181: let i24 ← lift (mantissa &&& 3#u64)
3187: let i28 ← mantissa <<< i27
3190: ok (mantissa &&& i29)
3196: let i20 ← lift (mantissa1 &&& 1#u64)
3198: let mantissa3 ← mantissa2 >>> 1#i32
3199: let i21 ← 2#u64 <<< i5
3204: let mantissa5 ← 1#u64 <<< i5
3208: let i22 ← 1#u64 <<< i5
3210: let mantissa5 ← lift (mantissa4 &&& i23)
3232: let i ← LemireInst.traitsFloatExtInst.FloatInst.SIG_TOTAL_BITS
3233: 1#u64 <<< i
3240: let bits ← core.f64.F64.to_bits self
3241: let i ← bits >>> 63#i32
3245: let i1 ← core.f64.F64.EXPONENT_MASK
3246: let i2 ← lift (bits &&& i1)
3247: let i3 ← i2 >>> 52#i32
3253: let i4 ← core.f64.F64.MANTISSA_MASK
3254: let i5 ← lift (bits &&& i4)
3255: i5 <<< 1#i32
3258: let i4 ← core.f64.F64.MANTISSA_MASK
3259: let i5 ← lift (bits &&& i4)
3260: let i6 ← 1#u64 <<< 52#i32
3261: ok (i5 ||| i6)
3269:def F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3271: core.f64.F64.from_bits v
3278: core.f64.F64.classify self
3285: core.f64.F64.to_bits self
3324: core.f64.F64.MANTISSA_MASK
3331: core.f64.F64.EXPONENT_MASK
3339: core.f64.F64.MANTISSA_DIGITS
3352: core.f64.F64.from_bits 18444492273895866368#u64
3359: core.f64.F64.NAN
3366: core.f64.F64.NEG_INFINITY
3373: core.f64.F64.INFINITY
3381: let i ← FloatInst.EXP_BIAS
3392: let i ← FloatInst.EXP_SAT
3393: i >>> 1#i32
3402: let i ← FloatInst.EXP_SAT
3411: let i ← FloatInst.EXP_BITS
3412: let i1 ← 1#u32 <<< i
3422: let i1 ← FloatInst.SIG_BITS
3432: let i ← FloatInst.SIG_TOTAL_BITS
3471: coreopsbitShrSelfU32SelfInst := U64.Insts.CoreOpsBitShrU32U64
3472: coreopsbitShlSelfU32SelfInst := U64.Insts.CoreOpsBitShlU32U64
3473: coreopsbitBitAndInst := U64.Insts.CoreOpsBitBitAndU64U64
3474: coreopsbitBitOrInst := U64.Insts.CoreOpsBitBitOrU64U64
3512: coreopsarithDivInst := F64.Insts.CoreOpsArithDivF64F64
3513: coreopsarithNegInst := F64.Insts.CoreOpsArithNegF64
3514: coreopsarithMulInst := F64.Insts.CoreOpsArithMulF64F64
3529: from_u64_bits := F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3537:axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3543:def F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3545: let i ← lift (exponent &&& 31#usize)
3547: | 0 => core.f64.F64.from_bits 4607182418800017408#u64
3548: | 1 => core.f64.F64.from_bits 4621819117588971520#u64
3549: | 2 => core.f64.F64.from_bits 4636737291354636288#u64
3550: | 3 => core.f64.F64.from_bits 4652007308841189376#u64
3551: | 4 => core.f64.F64.from_bits 4666723172467343360#u64
3552: | 5 => core.f64.F64.from_bits 4681608360884174848#u64
3553: | 6 => core.f64.F64.from_bits 4696837146684686336#u64
3554: | 7 => core.f64.F64.from_bits 4711630319722168320#u64
3555: | 8 => core.f64.F64.from_bits 4726483295884279808#u64
3556: | 9 => core.f64.F64.from_bits 4741671816366391296#u64
3557: | 10 => core.f64.F64.from_bits 4756540486875873280#u64
3558: | 11 => core.f64.F64.from_bits 4771362005757984768#u64
3559: | 12 => core.f64.F64.from_bits 4786511204640096256#u64
3560: | 13 => core.f64.F64.from_bits 4801453603149578240#u64
3561: | 14 => core.f64.F64.from_bits 4816244402031689728#u64
3562: | 15 => core.f64.F64.from_bits 4831355200913801216#u64
3563: | 16 => core.f64.F64.from_bits 4846369599423283200#u64
3564: | 17 => core.f64.F64.from_bits 4861130398305394688#u64
3565: | 18 => core.f64.F64.from_bits 4876203697187506176#u64
3566: | 19 => core.f64.F64.from_bits 4891288408196988160#u64
3567: | 20 => core.f64.F64.from_bits 4906019910204099648#u64
3568: | 21 => core.f64.F64.from_bits 4921056587992461136#u64
3569: | 22 => core.f64.F64.from_bits 4936209963552724370#u64
3570: | _ => core.f64.F64.from_bits 0#u64
3606: F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3607: from_u64 := F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3643: let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
3644: let i2 ← i <<< i1
3645: let word ← lift (x.m ||| i2)
3646: traitsFloatExtInst.from_u64_bits word
3903: let i ← traitsFloatInst.EXP_MIN
3939: let i ← traitsFloatInst.INFINITE_POWER
3971: let i5 ← traitsFloatInst.EXP_MIN
3977: let i8 ← traitsFloatInst.SIG_BITS
3984: let i12 ← 1#u64 <<< i11
3999: let i16 ← 1#u64 <<< i8
4004: let i17 ← 1#u64 <<< i8
4006: let mantissa2 ← lift (mantissa1 &&& i18)
4011: let i14 ← 1#u64 <<< i8
4016: let i15 ← 1#u64 <<< i8
4018: let mantissa1 ← lift (mantissa &&& i16)
4035: let register1 ← lift (register &&& 16131858542891098079#u64)
4039: let float ← traitsFloatInst.INFINITY
4041: then let t ← traitsFloatInst.coreopsarithNegInst.neg float
4056: let i5 ← c <<< 16#i32
4057: let i6 ← b <<< 8#i32
4058: let i7 ← lift (i5 ||| i6)
4059: let register ← lift (i7 ||| a)
4060: let register1 ← lift (register &&& 16131858542891098079#u64)
4063: let float ← traitsFloatInst.INFINITY
4066: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4071: let float ← traitsFloatInst.NAN
4074: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4237: let i1 ← v1 >>> 8#i32
4239: let i2 ← lift (v2 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4243: let i3 ← v2 >>> 16#i32
4244: let i4 ← lift (i3 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4249: let i6 ← i5 >>> 32#i32
4561: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4562: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4563: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4611: coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
4656: let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
4657: let i2 ← i <<< i1
4658: let assembled_word ← lift (selected_pair.m ||| i2)
4664: let result ← coreopsarithNegInst.neg assembly_result
4731: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4732: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4733: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4737: num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
4738: coreopsarithMulInst coreopsarithNegInst s
STDERR:
(empty)
Rust inventory is a complete operation-syntax superset, including generic and scalar forms;
trait bounds, comments and non-U64 integer operations are included, not silently omitted.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n '<<|>>|[&|]|Neg::neg|Div::div|Mul::mul|from_u64|pow10_fast_path|SIG_BITS|SIG_TOTAL_BITS|F::NAN|F::INFINITY|Some\(-float\)' crate/traits.rs crate/dec2flt
EXIT: 0
STDOUT:
crate/traits.rs:95: const SIG_TOTAL_BITS: u32;
crate/traits.rs:101: const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
crate/traits.rs:104: const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
crate/traits.rs:110: const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
crate/traits.rs:116: const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
crate/traits.rs:137: /// (in the 32-bit case). In both cases,the power of five(5^|q|)
crate/traits.rs:172: fn from_u64_bits(v: u64) -> Self;
crate/traits.rs:177: /// exponent will be `-(EXP_BIAS + SIG_BITS)`, which is the minimum subnormal power. For
crate/traits.rs:178: /// infinity or NaN, the exponent will be `EXP_SAT - EXP_BIAS - SIG_BITS`.
crate/traits.rs:204: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:229: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:230: Self::from_bits((v & 0xFFFF) as u16)
crate/traits.rs:238: let sign = if bits >> 15 == 0 { 1 } else { -1 };
crate/traits.rs:239: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
crate/traits.rs:241: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:243: (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
crate/traits.rs:264: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:288: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:289: f32::from_bits((v & 0xFFFFFFFF) as u32)
crate/traits.rs:297: let sign = if bits >> 31 == 0 { 1 } else { -1 };
crate/traits.rs:298: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
crate/traits.rs:300: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:302: (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
crate/traits.rs:320: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:341: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:350: let sign = if bits >> 63 == 0 { 1 } else { -1 };
crate/traits.rs:351: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
crate/traits.rs:353: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:355: (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
crate/dec2flt/common.rs:10: fn read_u64(&self) -> u64;
crate/dec2flt/common.rs:13: fn write_u64(&mut self, value: u64);
crate/dec2flt/common.rs:16: fn offset_from(&self, other: &Self) -> isize;
crate/dec2flt/common.rs:22: fn read_u64(&self) -> u64 {
crate/dec2flt/common.rs:24: tmp.copy_from_slice(&self[..8]);
crate/dec2flt/common.rs:29: fn write_u64(&mut self, value: u64) {
crate/dec2flt/common.rs:30: self[..8].copy_from_slice(&value.to_le_bytes())
crate/dec2flt/common.rs:34: fn offset_from(&self, other: &Self) -> isize {
crate/dec2flt/common.rs:47: (a | b) & 0x8080_8080_8080_8080 == 0
crate/dec2flt/mod.rs:116: /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:120: /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:124: /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
crate/dec2flt/mod.rs:127: /// Maximum mantissa for the fast-path (`1 << 53` for f64).
crate/dec2flt/mod.rs:128: const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
crate/dec2flt/mod.rs:131: fn pow10_fast_path(exponent: usize) -> Self;
crate/dec2flt/mod.rs:137: fn from_u64(v: u64) -> Self;
crate/dec2flt/mod.rs:147: // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
crate/dec2flt/mod.rs:153: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:157: match exponent & 7 {
crate/dec2flt/mod.rs:172: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:183: // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
crate/dec2flt/mod.rs:187: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:190: match exponent & 15 {
crate/dec2flt/mod.rs:211: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:218: // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
crate/dec2flt/mod.rs:222: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:226: match exponent & 31 {
crate/dec2flt/mod.rs:263: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:284: word |= (x.p_biased as u64) << F::SIG_BITS;
crate/dec2flt/mod.rs:285: F::from_u64_bits(word)
crate/dec2flt/mod.rs:299: SignOnly { body: &'a [u8], negative: bool },
crate/dec2flt/mod.rs:302: body: &'a [u8],
crate/dec2flt/mod.rs:309: body: &'a [u8],
crate/dec2flt/mod.rs:317: body: &'a [u8],
crate/dec2flt/mod.rs:330: pub body: &'a [u8],
crate/dec2flt/mod.rs:362: s: &'a str,
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
crate/dec2flt/mod.rs:369: if c == b'-' || c == b'+' {
crate/dec2flt/mod.rs:370: body = &body[1..];
crate/dec2flt/mod.rs:431: // occur exactly when `many_digits && fp.p_biased >= 0`.
crate/dec2flt/mod.rs:432: let second_compute_guard = num.many_digits && fp.p_biased >= 0;
crate/dec2flt/mod.rs:468: let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
crate/dec2flt/mod.rs:472: core::ops::Neg::neg(assembly_result)
crate/dec2flt/mod.rs:514: s: &str,
crate/dec2flt/fpu.rs:31: /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
crate/dec2flt/fpu.rs:32: /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
crate/dec2flt/fpu.rs:33: /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
crate/dec2flt/fpu.rs:52: in(reg) &cw,
crate/dec2flt/fpu.rs:76: in(reg) &mut cw,
crate/dec2flt/fpu.rs:83: set_cw((cw & 0xFCFF) | cw_precision);
crate/dec2flt/fpu.rs:89: fn drop(&mut self) {
crate/dec2flt/decimal.rs:42: fn can_use_fast_path<F: Lemire>(&self) -> bool {
crate/dec2flt/decimal.rs:44: && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
crate/dec2flt/decimal.rs:45: && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
crate/dec2flt/decimal.rs:46: && !self.many_digits
crate/dec2flt/decimal.rs:65: &self,
crate/dec2flt/decimal.rs:84: let value = F::from_u64(self.mantissa);
crate/dec2flt/decimal.rs:88: core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
crate/dec2flt/decimal.rs:90: core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
crate/dec2flt/decimal.rs:99: core::ops::Mul::mul(
crate/dec2flt/decimal.rs:100: F::from_u64(mantissa),
crate/dec2flt/decimal.rs:101: F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
crate/dec2flt/decimal.rs:106: Some(core::ops::Neg::neg(value))
crate/dec2flt/decimal_seq.rs:74: pub(super) fn try_add_digit(&mut self, digit: u8) {
crate/dec2flt/decimal_seq.rs:83: pub fn trim(&mut self) {
crate/dec2flt/decimal_seq.rs:92: while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
crate/dec2flt/decimal_seq.rs:97: pub(super) fn round(&self) -> u64 {
crate/dec2flt/decimal_seq.rs:98: if self.num_digits == 0 || self.decimal_point < 0 {
crate/dec2flt/decimal_seq.rs:118: if self.digits[dp] == 5 && dp + 1 == self.num_digits {
crate/dec2flt/decimal_seq.rs:119: round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
crate/dec2flt/decimal_seq.rs:130: pub(super) fn left_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:142: n += (self.digits[read_index] as u64) << shift;
crate/dec2flt/decimal_seq.rs:176: pub(super) fn right_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:181: while (n >> shift) == 0 && !all_zero {
crate/dec2flt/decimal_seq.rs:191: while (n >> shift) == 0 {
crate/dec2flt/decimal_seq.rs:209: let mask = (1_u64 << shift) - 1;
crate/dec2flt/decimal_seq.rs:211: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:212: n = (10 * (n & mask)) + self.digits[read_index] as u64;
crate/dec2flt/decimal_seq.rs:218: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:219: n = 10 * (n & mask);
crate/dec2flt/decimal_seq.rs:236:fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
crate/dec2flt/decimal_seq.rs:240: while i != 0 && scanning {
crate/dec2flt/decimal_seq.rs:242: if c == b'0' || c == b'.' {
crate/dec2flt/decimal_seq.rs:254:// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
crate/dec2flt/decimal_seq.rs:257:fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
crate/dec2flt/decimal_seq.rs:259: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/decimal_seq.rs:264: &s[count..]
crate/dec2flt/decimal_seq.rs:288:pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
crate/dec2flt/decimal_seq.rs:296: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:297: s = &s[1..];
crate/dec2flt/decimal_seq.rs:300: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:302: if !s.is_empty() && s[0] == b'.' {
crate/dec2flt/decimal_seq.rs:303: s = &s[1..];
crate/dec2flt/decimal_seq.rs:309: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:310: s = &s[1..];
crate/dec2flt/decimal_seq.rs:313: while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
crate/dec2flt/decimal_seq.rs:320: s = &s[8..];
crate/dec2flt/decimal_seq.rs:322: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:350: if ch == b'e' || ch == b'E' {
crate/dec2flt/decimal_seq.rs:362: let mut exponent_suffix = &s[1..];
crate/dec2flt/decimal_seq.rs:363: explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
crate/dec2flt/decimal_seq.rs:375:fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
crate/dec2flt/decimal_seq.rs:433: shift &= 63;
crate/dec2flt/decimal_seq.rs:436: let num_new_digits = (x_a >> 11) as _;
crate/dec2flt/decimal_seq.rs:437: let pow5_a = (0x7FF & x_a) as usize;
crate/dec2flt/decimal_seq.rs:438: let pow5_b = (0x7FF & x_b) as usize;
crate/dec2flt/decimal_seq.rs:439: let pow5 = &TABLE_POW5[pow5_a..];
crate/dec2flt/decimal_seq.rs:441: for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
crate/dec2flt/lemire.rs:32: if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
crate/dec2flt/lemire.rs:39: w <<= lz;
crate/dec2flt/lemire.rs:40: let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
crate/dec2flt/lemire.rs:57: let inside_safe_exponent = (q >= -27) && (q <= 55);
crate/dec2flt/lemire.rs:62: let upperbit = (hi >> 63) as i32;
crate/dec2flt/lemire.rs:63: let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
crate/dec2flt/lemire.rs:71: mantissa >>= -power2 + 1;
crate/dec2flt/lemire.rs:72: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:73: mantissa >>= 1;
crate/dec2flt/lemire.rs:74: power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
crate/dec2flt/lemire.rs:89: && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:90: && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:91: && mantissa & 0b11 == 0b01
crate/dec2flt/lemire.rs:92: && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
crate/dec2flt/lemire.rs:95: mantissa &= !1_u64;
crate/dec2flt/lemire.rs:98: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:99: mantissa >>= 1;
crate/dec2flt/lemire.rs:100: if mantissa >= (2_u64 << F::SIG_BITS) {
crate/dec2flt/lemire.rs:104: mantissa = 1_u64 << F::SIG_BITS;
crate/dec2flt/lemire.rs:108: mantissa &= !(1_u64 << F::SIG_BITS);
crate/dec2flt/lemire.rs:122: (q.wrapping_mul(152_170 + 65536) >> 16) + 63
crate/dec2flt/lemire.rs:128: (r as u64, (r >> 64) as u64)
crate/dec2flt/lemire.rs:140: 0xFFFF_FFFF_FFFF_FFFF_u64 >> precision
crate/dec2flt/lemire.rs:155: if first_hi & mask == mask {
crate/dec2flt/slow.rs:27:pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
crate/dec2flt/slow.rs:33: let get_shift = |n| {
crate/dec2flt/slow.rs:43: if d.num_digits == 0 || d.decimal_point < -324 {
crate/dec2flt/slow.rs:51: while d.decimal_point > 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:69: while d.decimal_point <= 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:73: 0 | 1 => 2,
crate/dec2flt/slow.rs:107: d.left_shift(F::SIG_BITS as usize + 1);
crate/dec2flt/slow.rs:109: if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
crate/dec2flt/slow.rs:120: if mantissa < (1_u64 << F::SIG_BITS) {
crate/dec2flt/slow.rs:124: mantissa &= (1_u64 << F::SIG_BITS) - 1;
crate/dec2flt/parse.rs:23: v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
crate/dec2flt/parse.rs:24: let v1 = (v & MASK).wrapping_mul(MUL1);
crate/dec2flt/parse.rs:25: let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
crate/dec2flt/parse.rs:26: ((v1.wrapping_add(v2) >> 32) as u32) as u64
crate/dec2flt/parse.rs:30:fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
crate/dec2flt/parse.rs:40: s = &s[8..];
crate/dec2flt/parse.rs:50: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:55: s = &s[count..];
crate/dec2flt/parse.rs:61:fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
crate/dec2flt/parse.rs:86:fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
crate/dec2flt/parse.rs:89: while scan_index < start.len() && scanning {
crate/dec2flt/parse.rs:91: if c == b'.' || c == b'0' {
crate/dec2flt/parse.rs:104:fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
crate/dec2flt/parse.rs:107: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:111: s = &s[1..];
crate/dec2flt/parse.rs:113: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:121:pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:129: if c == b'-' || c == b'+' {
crate/dec2flt/parse.rs:137: if !s.is_empty() && s[0].is_ascii_digit() {
crate/dec2flt/parse.rs:145: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:147: if exponent < (1_i64 << 59) {
crate/dec2flt/parse.rs:152: *s_ref = &s[count..];
crate/dec2flt/parse.rs:164:fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:198: if c == b'e' || c == b'E' {
crate/dec2flt/parse.rs:201: exp_number = parse_scientific(&mut s)?;
crate/dec2flt/parse.rs:234:pub fn parse_number(s: &[u8]) -> Option<Decimal> {
crate/dec2flt/parse.rs:244:pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
crate/dec2flt/parse.rs:260: register = (c << 16) | (b << 8) | a;
crate/dec2flt/parse.rs:269: register &= 0xDFDFDFDFDFDFDFDF;
crate/dec2flt/parse.rs:280: (INF_3, 3) => F::INFINITY,
crate/dec2flt/parse.rs:281: (INF_8, 8) => F::INFINITY,
crate/dec2flt/parse.rs:282: (NAN, 3) => F::NAN,
crate/dec2flt/parse.rs:286: if negative { Some(-float) } else { Some(float) }
STDERR:
(empty)
Current guarded native body, exact f64 boundary and unrestricted assembler:
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 39,111p crate/dec2flt/decimal.rs
EXIT: 0
STDOUT:
impl Decimal {
/// Detect if the float can be accurately reconstructed from native floats.
#[inline]
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
/// Try turning the decimal into an exact float representation, using machine-sized integers
/// and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
/// can be exactly represented as a machine float, since IEE-754 guarantees
/// no rounding will occur.
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
pub fn try_fast_path<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
&self,
) -> Option<F> {
// `Lemire` already entails these three operator bounds through
// `Float`; spelling them directly changes no admitted type. Charon
// needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
// The `set_precision` function takes care of setting the precision on architectures which
// require setting it by changing the global state (like the control word of the x87 FPU).
let _cw = set_precision::<F>();
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 112,138p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
///
/// Not intended for use outside of the `dec2flt` module.
#[doc(hidden)]
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
/// Gets a small power-of-ten for fast-path multiplication.
fn pow10_fast_path(exponent: usize) -> Self;
/// Converts integer into float through an as cast.
/// This is only called in the fast-path algorithm, and therefore
/// will not lose precision, since the value will always have
/// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
fn from_u64(v: u64) -> Self;
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 217,286p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
impl Lemire for f64 {
// Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
#[inline]
pub(super) fn pfe_empty() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Empty }
}
// Used in unit tests, keep public.
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
#[inline]
pub fn pfe_invalid() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Invalid }
}
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 315,365p crate/traits.rs
EXIT: 0
STDOUT:
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
// Exact value of trunc(1024 / log2(10)) from the upstream default.
const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
// This is the upstream default after substituting `Self::Int = u64`;
// it preserves every decoded field while avoiding unsupported generic
// associated-integer operator resolution.
fn integer_decode(self) -> (u64, i16, i8) {
let bits = self.to_bits();
let sign = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
let mantissa = if exponent == 0 {
(bits & Self::MANTISSA_MASK) << 1
} else {
(bits & Self::MANTISSA_MASK) | (1_u64 << 52)
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 245,291p crate/dec2flt/parse.rs
EXIT: 0
STDOUT:
// Since a valid string has at most the length 8, we can load
// all relevant characters into a u64 and work from there.
// This also generates much better code.
let mut register;
let len: usize;
// All valid strings are either of length 8 or 3.
if s.len() == 8 {
register = s.read_u64();
len = 8;
} else if s.len() == 3 {
let a = s[0] as u64;
let b = s[1] as u64;
let c = s[2] as u64;
register = (c << 16) | (b << 8) | a;
len = 3;
} else {
return None;
}
// Clear out the bits which turn ASCII uppercase characters into
// lowercase characters. The resulting string is all uppercase.
// What happens to other characters is irrelevant.
register &= 0xDFDFDFDFDFDFDFDF;
// u64 values corresponding to relevant cases
const INF_3: u64 = 0x464E49; // "INF"
const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
const NAN: u64 = 0x4E414E; // "NAN"
// Match register value to constant to parse string.
// Also match on the string length to catch edge cases
// like "inf\0\0\0\0\0".
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
}
STDERR:
(empty)
Fresh constant and symbolic-negation reproduction
=================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C opt-level=0 reference/model-evidence/binary64-probe.rs -o .trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
; ModuleID = 'binary64_negation_probe.566fd6d762029c-cgu.0'
source_filename = "binary64_negation_probe.566fd6d762029c-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 7, !"uwtable", i32 2}
!3 = !{!"rustc version 1.98.0-nightly (14210df0e 2026-05-31)"}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
.file "binary64_negation_probe.566fd6d762029c-cgu.0"
.section .text.neg_f64_trait_bits,"ax",@progbits
.globl neg_f64_trait_bits
.p2align 4
.type neg_f64_trait_bits,@function
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
.Lfunc_end0:
.size neg_f64_trait_bits, .Lfunc_end0-neg_f64_trait_bits
.cfi_endproc
.ident "rustc version 1.98.0-nightly (14210df0e 2026-05-31)"
.section ".note.GNU-stack","",@progbits
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum .trellis/scratch/binary64-probe .trellis/scratch/binary64-negation-probe.ll .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322 .trellis/scratch/binary64-probe
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
STDERR:
(empty)
Fresh checked-shift reproduction and full dynamic-count MIR
===========================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shl-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir ../../reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shl-probe u64-shl-probe.mir
EXIT: 0
STDOUT:
1d8bda234272af0f20a360fe4ff631c8ed038f9aac02bfe539192fff86706d4c u64-shl-probe
1d05de9f3cfb93082c17a57d39f7fc0813c3fe0d3ebd0efe470b0885fba931b9 u64-shl-probe.mir
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shr-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir ../../reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shr-probe u64-shr-probe.mir
EXIT: 0
STDOUT:
1cceba3e03b755a37112c16ad347161a9732793944f34d0a740470584a08c9fc u64-shr-probe
9a72f1d018d926b3e5672c8fb473e2495a710cf4a252c7515e12d2e5009c134e u64-shr-probe.mir
STDERR:
(empty)
Interpretation and limits
=========================
The constant source really evaluates f64::NAN; its nan=7ff8000000000000 observation
fixes that pinned constant, not arbitrary arithmetic-NaN signs or payloads.
The arbitrary-u64 qualified Neg probe passes w in rdi; movabsq loads 2^63 in rax,
xorq combines them, retq returns rax, with no branch or NaN exception. Its XOR law
holds for all 2^64 words, including every signaling/quiet NaN payload.
The checked dynamic-count MIR establishes the whole U64 x U32 branch condition,
not merely seven runtime samples: counts <64 shift, counts >=64 fail, without masking.
AND/OR remain exact over all words. from_u64 still asserts <=2^53 before casting;
the ordinary source guard gives -22<=exponent<=22, mantissa<=2^53, !many_digits.
The disguised source arm checks its integer product and <=2^53 before the cast,
and uses fixed table index 22. Only then may conditional Binary64NativeCallDomain
supply finite non-NaN cast/table operands and a positive nonzero divisor.
Thus reached native arithmetic is exact; generic arithmetic NaNs retain permitted-choice
semantics, not universal exact-bit equivalence. Assembly admits every BiasedFp field pair.
Equal-target preservation retains both rounding relations to the same target, without
deriving uniqueness from vocabulary or assuming an unresolved GOAL conclusion.
All 32 original GOALs remain pursued with their own quantifiers, domains and polarity.
These source-facing checks are evidence, not preservation Sound certification or GOAL proofs.
Managed checks and final scope verification
===========================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py compose-native . --check
EXIT: 0
Selected raw result fields:
{
"full_result": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/compose-native-1791584636440554217.json",
"matches": true,
"changed": false,
"mismatched_files": [],
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
COMMAND: python3 .trellis/scripts/check.py model-support-check .
EXIT: 0
Raw result:
{"ok": true, "errors": []}
COMMAND: python3 .trellis/scripts/check.py tablet . --json
EXIT: 0
Structured projection from the final full managed JSON result:
{
"command": [
"python3",
".trellis/scripts/check.py",
"tablet",
".",
"--json"
],
"exit_status": 0,
"ok": true,
"errors": [],
"node_count": 340,
"all_nodes_compile": true,
"elaboration_failures": [],
"structure_failures": [],
"warning_count": 696,
"warning_examples": [
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:364:4: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:587:8: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/StringIter.lean:13:4: declaration uses `sorry`"
],
"raw_stdout_sha256": "15a1d03a085481d315bcc1a4716aa174475f03e72d8f452f5f33d45a71f5ed91",
"stderr_line_count": 340,
"raw_stderr_sha256": "50c8fde0aef24c1b87ce95c51d21794927d6abba46d90fd04a8d3a714bfed46e"
}
This final command was captured and summarized by
python3 .trellis/scratch/managed-tablet-summary.py (exit 0).
Two earlier identical whole-Tablet checks also exited 0; one jq projection
reported tablet_exit=0 jq_exit=0, node_count=340, failing_elaboration=[],
invalid_structure=[]. The first tool preview truncated its verbose JSON;
that truncation was not used as a proof-closure certificate. The retained
warnings include permitted principal GOAL sketches and installed Aeneas
Slice/StringIter sorry warnings. No definition was supplied with sorry.
These checks establish elaboration, structure and composition freshness,
not preservation Sound or proof closure of the pursued GOALs.
COMMAND: python3 .trellis/scratch/preservation-scope-check.py
EXIT: 0
Raw result:
{
"ok": true,
"owner_checks": [
{
"node": "Binary64ModelDefault",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "210652331cd53e0254aae45856663c01d0552fe992b69608fe243260022ccd79"
},
{
"node": "ModelF64Neg",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "f7d74d4558333c0754ccce8f6861d1409c049fd4dfd1825daad2fd2f441eb78f"
},
{
"node": "ModelU64BitAnd",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "b401e17a058ec2909fb7a58d01f07867f03a933c2901338efebda252692ca6ff"
},
{
"node": "ModelU64BitOr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "c53e3e5ad29cc4419d07c3f2a8913e0f4df87ecbcf4ac1567a9e699a2bd18e2d"
},
{
"node": "ModelU64Shl",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "ed68845da19138d7406e8022c5a9adb765ed70c2ed075f41aea7c190dea9909a"
},
{
"node": "ModelU64Shr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "04b6ec376e7ec490c64183f2a18be832ea574391d7f24d49db7ddc10019cd2f0"
}
],
"principal_goal_pairs": [
{
"node": "AssemblyCorrespondence",
"target": "assembly_correspondence",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationDeterminism",
"target": "classification_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationSignificandDigit",
"target": "classification_significand_digit",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationTotality",
"target": "classification_totality",
"paired_files_byte_unchanged": true
},
{
"node": "ExponentValueAgreement",
"target": "exponent_value_agreement",
"paired_files_byte_unchanged": true
},
{
"node": "IntegerCorrectOrDefer",
"target": "integer_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NativeCorrectOrDefer",
"target": "native_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAcceptance",
"target": "number_helper_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAccumulatedValue",
"target": "number_helper_accumulated_value",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRecordBounds",
"target": "number_helper_record_bounds",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRejection",
"target": "number_helper_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserAccumulatedRounding",
"target": "parser_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserEqualTargetRounding",
"target": "parser_equal_target_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserExactRounding",
"target": "parser_exact_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInfinity",
"target": "parser_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInvalidRejection",
"target": "parser_invalid_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNanAcceptance",
"target": "parser_nan_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNonNanResults",
"target": "parser_non_nan_results",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericAcceptance",
"target": "parser_numeric_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericSign",
"target": "parser_numeric_sign",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserSignedZero",
"target": "parser_signed_zero",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserTotality",
"target": "parser_totality",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_SlowAccumulatedRounding",
"target": "slow_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchAbstractComposition",
"target": "dispatch_abstract_composition",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchComponentCompliance",
"target": "dispatch_component_compliance",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedExponent",
"target": "parser_selected_exponent",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedMagnitudeSign",
"target": "parser_selected_magnitude_sign",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingDeterminism",
"target": "rounding_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingTotality",
"target": "rounding_totality",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperInfinity",
"target": "special_helper_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperNan",
"target": "special_helper_nan",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperRejection",
"target": "special_helper_rejection",
"paired_files_byte_unchanged": true
}
],
"new_nodes": [],
"evidence_consumers_for_current_Sound": [
"Binary64ModelDefault",
"DecimalGoalVocabularyDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"frozen_boundary_unchanged": true,
"pre_existing_config_delta_unchanged": true,
"changed_paths_in_assigned_scope": [
"Tablet/Binary64ModelDefault.tex",
"Tablet/ModelF64Neg.tex",
"Tablet/ModelU64BitAnd.tex",
"Tablet/ModelU64BitOr.tex",
"Tablet/ModelU64Shl.tex",
"Tablet/ModelU64Shr.tex",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
],
"completion_meaning_audit_still_required": true
}
Delivery, acceptance and certification status
============================================
The executed kernel task is task_id=11 (worker request 118), compiler=managed,
under trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91.
Submitted scope is exactly the six owners' preservation sections and ten
reserved evidence paths listed above. No acceptance/publication outcome is
available before worker delivery; the host's real receipt must supply it.
The raw-only worker validator and a Submitted marker mean delivery, not host
acceptance, publication, preservation Sound or Modeling completion.
Keep retry-binary64-preservation-exclusively live until actual publication,
and verify-published-preservation-and-meanings live until current certification.
After publication, request current Sound on all changed evidence consumers,
including DecimalGoalVocabularyDefault's u64-shl/u64-bitor citations, and
repaired support before parents whose named gaps remain open. Do not reset
Binary64ModelDefault's genuine VerifierFail based on these worker checks.
The independent all-32 original-GOAL meaning audit remains required before
Modeling completion; a byte-unchanged pair check is not that semantic audit.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-negation-probe.rs
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
reference/model-evidence/binary64-negation.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
Primary evidence for binary64 trait negation
============================================
Scope and conclusion
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction and the
nightly-2026-06-01 toolchain fixed by modeling-input/SETUP.md and
modeling-input/manifest.json. It establishes the following statement for the
specific extracted Rust operation bound to ModelF64Neg:
For every u64 word w, including every signaling or quiet NaN payload,
to_bits(<f64 as core::ops::Neg>::neg(f64::from_bits(w)))
equals w XOR 0x8000000000000000.
Thus precisely bit 63 is toggled and every other bit is preserved. This is a
universal symbolic result, not an inference from finitely many test inputs.
Pinned identities
-----------------
The following command was run from the repository root. RROOT is the source
tree installed with the configured compiler.
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
RROOT=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
sha256sum "$R" \
"$RROOT/core/src/ops/arith.rs" \
"$RROOT/core/src/primitive_docs.rs" \
crate/dec2flt/mod.rs upstream/dec2flt/mod.rs \
generated.lean Tablet/model-support.json \
modeling-input/tool-identities.json \
reference/model-evidence/binary64-negation-probe.rs
Raw output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
modeling-input/tool-identities.json records the same rustc path and SHA-256.
The compiler reports:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Concrete core implementation
----------------------------
The following exact excerpt is core/src/ops/arith.rs:709-728 in the source
whose SHA-256 is 596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0:
macro_rules! neg_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const Neg for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> $t { -self }
}
forward_ref_unop! { impl Neg, neg for $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
The macro invocation explicitly includes f64. Its expansion is therefore the
concrete `impl Neg for f64`, with `Output = f64`, whose method body is the
primitive expression `-self`.
Frozen parser statement and primitive guarantee
------------------------------------------------
The adapted frozen parser and supplied upstream parser have identical text at
dec2flt/mod.rs:20-22. Their complete-file hashes are pinned above. The exact
three lines are:
//! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
//! process and re-apply it at the very end. This is correct in all edge cases since IEEE
//! floats are symmetric around zero, negating one simply flips the first bit.
The installed primitive documentation is pinned above by SHA-256
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5.
At primitive_docs.rs:1369-1375 it identifies f64 as binary64 and directs the
reader to the f32 documentation for the common floating-point rules:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The exact common rule at primitive_docs.rs:1256-1260 is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
This rule expressly covers unary negation and bit conversion, and expressly
distinguishes them from arithmetic NaN production. It therefore preserves the
quiet/signaling bit and every payload bit for NaNs as well as all non-sign bits
for finite values, zeros, and infinities. The parser statement identifies the
permitted sign-bit change as an actual flip in all edge cases.
Extraction and support binding
------------------------------
The frozen generated.lean, pinned above, contains this exact declaration and
trait implementation record:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
/-- Trait implementation: [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}]
Source: '/rustc/library/core/src/ops/arith.rs', lines 713:8-713:29
Name pattern: [core::ops::arith::Neg<f64, f64>] -/
@[reducible, rust_trait_impl "core::ops::arith::Neg<f64, f64>"]
def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
neg := F64.Insts.CoreOpsArithNegF64.neg
}
Thus the extracted external is the same f64 macro expansion and method body
identified above, not an abstract or different negation operation. Running
`python3 .trellis/scripts/pv_modeling.py inspect-native "$PWD"` and selecting
that declaration gives the following raw inventory fields:
name: F64.Insts.CoreOpsArithNegF64.neg
extracted_signature: : F64 → Result F64
rust_symbol: core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
raw_declaration_sha256: bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0
The raw declaration hash is independently reproduced after that inspection by:
I=$(ls -1t .trellis/scratch/inspect-native-*.json | head -n 1)
jq -j '.. | objects | select(.name? == "F64.Insts.CoreOpsArithNegF64.neg") | .source_utf8' "$I" | sha256sum
Raw output:
bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0 -
Tablet/model-support.json, whose complete-file hash is pinned above, copies all
four identity fields unchanged and binds this external to the model definition:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
Symbolic same-toolchain probe
-----------------------------
The retained probe source is:
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
The argument is an arbitrary symbolic u64. The qualified call forces the same
`Neg for f64` trait method identified by the core source and extraction. The
following exact commands use the extraction's compiler and target and retain
both optimized LLVM IR and assembly in the worker scratch directory:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-negation-probe.rs
IR=.trellis/scratch/binary64-negation-probe.ll
ASM=.trellis/scratch/binary64-negation-probe.s
"$R" --version --verbose
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir "$P" -o "$IR"
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm "$P" -o "$ASM"
sha256sum "$R" "$P" "$IR" "$ASM"
cat "$IR"
cat "$ASM"
Raw hash output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
Raw optimized LLVM IR function:
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
Raw optimized x86_64 assembly function:
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
Under the selected x86_64 C ABI, the symbolic input w arrives in %rdi and the
u64 result is returned in %rax. The loaded signed decimal constant
-9223372036854775808 has u64 bit pattern 0x8000000000000000, with bit 63 set
and every other bit clear. The emitted `xorq %rdi, %rax` therefore returns
w XOR 0x8000000000000000. There is no branch, floating-point exceptional
case, or input precondition in the emitted function.
Universal preservation conclusion
---------------------------------
The core macro and f64 instantiation connect the trait method to primitive
unary `-`; generated.lean and model-support.json connect that exact method to
ModelF64Neg. The parser source says the operation flips the sign bit in all
edge cases, while the primitive guarantee says every non-sign bit is preserved,
including the quiet/signaling and payload bits of NaNs. Finally, the symbolic
same-compiler/same-target probe makes the exact transformation explicit as XOR
with the bit-63 mask for its arbitrary u64 argument.
Because f64::from_bits accepts every one of the 2^64 u64 words and to_bits
returns the resulting raw word, the symbolic input covers the entire modeled
F64 carrier. Consequently the source result for every word is exactly the
model package's `ok` result containing that word with bit 63 toggled. This
includes both signs of zero and infinity, every finite/subnormal word, and
every possible NaN payload without canonicalization or quieting.
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/u64-bitand.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitAnd preservation evidence
================================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitAnd. The commands below were run from the repository
root on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790258751442882118.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790258751442882118.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790258751442882118.json
The exact U64 BitAnd entry in that index is:
name: U64.Insts.CoreOpsBitBitAndU64U64.bitand
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
source: /rustc/library/core/src/ops/bit.rs, lines 178:12-178:42
raw_declaration_sha256: 36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitAndU64U64.bitand") | .source_utf8' \
.trellis/scratch/inspect-native-1790258751442882118.json | sha256sum
Output:
36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line ranges are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '170,187p'
The pinned source says at lines 170-179:
macro_rules! bitand_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitAnd for $t {
type Output = $t;
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
and line 187 instantiates that implementation for u64:
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 conjunction `self & rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
--------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 105-116 and theorem at line 274 are:
def UScalar.and {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv &&& y.bv ⟩
instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where
hAnd x y := UScalar.and x y
theorem UScalar.bv_and {ty} (x y : UScalar ty) :
(x &&& y).bv = x.bv &&& y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 148-153 prove, for every width and bit index:
theorem BitVec.getElem!_and {w} (x y : BitVec w) (i : Nat) :
(x &&& y)[i]! = (x[i]! && y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_and, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.and_self]
Therefore `x &&& y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean conjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-bitor.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitOr preservation evidence
===============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitOr. The commands below were run from the repository root
on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790259866184055823.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790259866184055823.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790259866184055823.json
The exact U64 BitOr entry in that index is:
name: U64.Insts.CoreOpsBitBitOrU64U64.bitor
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
source: /rustc/library/core/src/ops/bit.rs, lines 282:12-282:41
raw_declaration_sha256: 85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitOrU64U64.bitor") | .source_utf8' \
.trellis/scratch/inspect-native-1790259866184055823.json | sha256sum
Output:
85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line range are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '274,291p'
The pinned source says at lines 274-289:
macro_rules! bitor_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitOr for $t {
type Output = $t;
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
forward_ref_binop! { impl BitOr, bitor for $t, $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
and line 291 instantiates that implementation for u64:
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 disjunction `self | rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
-------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 118-126 and theorem at line 275 are:
def UScalar.or {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv ||| y.bv ⟩
instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where
hOr x y := UScalar.or x y
theorem UScalar.bv_or {ty} (x y : UScalar ty) :
(x ||| y).bv = x.bv ||| y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 141-146 prove, for every width and bit index:
theorem BitVec.getElem!_or {w} (x y : BitVec w) (i : Nat) :
(x ||| y)[i]! = (x[i]! || y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_or, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.or_self]
Therefore `x ||| y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean disjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-shl-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x << count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shl.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shl preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shl. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a bounded U64 shift, and all U32 counts at least
64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790260978718245524.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790260978718245524.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790260978718245524.json
The exact U64 Shl entry in that fresh index is:
name: U64.Insts.CoreOpsBitShlU32U64.shl
extracted_signature: : Std.U64 → Std.U32 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
source: /rustc/library/core/src/ops/bit.rs, lines 489:12-489:41
raw_declaration_sha256: e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShlU32U64.shl") | .source_utf8' \
.trellis/scratch/inspect-native-1790260978718245524.json | sha256sum
Output:
e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d -
Thus this boundary is specifically u64 shifted by u32, and its extracted
codomain is the Aeneas Result used below to distinguish normal return from
checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '479,520p'
Lines 479-498 define the implementation macro:
macro_rules! shl_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shl<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shl(self, other: $f) -> $t {
self << other
}
}
forward_ref_binop! { impl Shl, shl for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 500-518 apply `shl_impl! { $t, u32 }` to every type in
`shl_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shl_impl_all {
($($t:ty)*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
shl_impl! { $t, u64 }
shl_impl! { $t, u128 }
shl_impl! { $t, usize }
...
)*)
}
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shl<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self << other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shl-probe.rs
with SHA-256:
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8
It places the same primitive expression `x << count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
./u64-shl-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir \
../../reference/model-evidence/u64-shl-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shl` operation and returns its bounded 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with the
expected truncation to 64 bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 17-21 and 29-31 define:
def UScalar.shiftLeft {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.shiftLeft s ⟩
else fail .integerOverflow
def UScalar.shiftLeft_UScalar {ty tys} (x : UScalar ty) (s : UScalar tys) :
Result (UScalar ty) :=
x.shiftLeft s.val
Lines 81-82 resolve the notation used by Tablet/ModelU64Shl.lean:
instance {ty0 ty1} : HShiftLeft (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftLeft x y := UScalar.shiftLeft_UScalar x y
Consequently `x <<< y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the 64-bit vector shift; at least 64 it is
exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftLeft_spec`, lines 193-205, proves the successful
branch has both equivalent bounded descriptions:
theorem UScalar.ShiftLeft_spec ... (hy : y.val < ty0.numBits) ... :
(x <<< y) ⦃ z =>
z.val = (x.val <<< y.val) % size ∧
z.bv = x.bv <<< y.val ⦄
For U64, `size` is `2^64`; hence the returned natural value is the mathematical
left shift reduced modulo `2^64`, and the returned carrier is exactly the
corresponding 64-bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 248-266 give the bit-level characterization: every result bit below
the shift count (or outside the fixed width) is false, and every in-width bit at
or above the count equals the corresponding input bit at index `i - n`:
theorem BitVec.getElem!_shiftLeft_false ...
(h : i < n ∨ w ≤ i) : (v <<< n)[i]! = false
theorem BitVec.getElem!_shiftLeft_eq ...
(h : n ≤ i ∧ i < w) : (v <<< n)[i]! = v[i - n]!
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive U64 shift. The Aeneas branch condition also succeeds and returns
`ok` of `BitVec.shiftLeft n`. `UScalar.ShiftLeft_spec` and the BitVec lemmas
identify both results as the same 64-bit word, equivalently `(x * 2^n) mod
2^64`, with discarded high bits and zero-filled low bits.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shl preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
reference/model-evidence/u64-shr-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x >> count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shr.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shr preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shr. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a logical U64 right shift, and all U32 counts at
least 64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790262316075577976.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790262316075577976.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790262316075577976.json
The exact U64 Shr entry in that fresh index is:
name: U64.Insts.CoreOpsBitShrU32U64.shr
extracted_signature: : Std.U64 -> Std.U32 -> Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
source: /rustc/library/core/src/ops/bit.rs, lines 612:12-612:41
raw_declaration_sha256: 77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 -> Std.U32 -> Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShrU32U64.shr") | .source_utf8' \
.trellis/scratch/inspect-native-1790262316075577976.json | sha256sum
Output:
77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f -
Tablet/model-support.json binds precisely this indexed declaration and
signature to dec2flt_model.ModelU64Shr. Thus the boundary is specifically u64
shifted by u32, and its extracted codomain is the Aeneas Result used below to
distinguish normal return from checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '602,641p'
Lines 602-620 define the implementation macro:
macro_rules! shr_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shr<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shr(self, other: $f) -> $t {
self >> other
}
}
forward_ref_binop! { impl Shr, shr for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 623-641 apply `shr_impl! { $t, u32 }` to every type in
`shr_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shr_impl_all {
($($t:ty)*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
shr_impl! { $t, u64 }
shr_impl! { $t, u128 }
shr_impl! { $t, usize }
...
)*)
}
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shr<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self >> other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shr-probe.rs
with SHA-256:
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee
It places the same primitive expression `x >> count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
./u64-shr-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir \
../../reference/model-evidence/u64-shr-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shr` operation and returns its logical 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with
zero-filled high bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 23-35 define:
def UScalar.shiftRight {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.ushiftRight s ⟩
else fail .integerOverflow
def UScalar.shiftRight_UScalar {ty tys} (x : UScalar ty)
(s : UScalar tys) : Result (UScalar ty) :=
x.shiftRight s.val
Lines 93-94 resolve the notation used by Tablet/ModelU64Shr.lean:
instance {ty0 ty1} : HShiftRight (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftRight x y := UScalar.shiftRight_UScalar x y
Consequently `x >>> y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the unsigned 64-bit vector shift; at least
64 it is exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftRight_spec`, lines 166-174, proves the successful
branch has both equivalent logical-shift descriptions:
theorem UScalar.ShiftRight_spec ... (hy : y.val < ty0.numBits) :
(x >>> y) ⦃ z =>
z.val = x.val >>> y.val ∧
z.bv = x.bv >>> y.val ⦄
Here natural-number `>>>` is division by `2^y.val`, so the returned numeric
value is `floor(x.val / 2^y.val)`, and the returned carrier is exactly the
unsigned shift of the fixed-width bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 268-283 give the bit-level logical zero-fill characterization. For
every result position, the total bit lookup is the input bit at the offset
position; positions whose offset is outside the 64-bit input are false:
theorem BitVec.getElem!_shiftRight {w} (v : BitVec w) (n i : Nat) :
(v >>> n)[i]! = v[n + i]!
theorem BitVec.getElem_shiftRight_false {m n : Nat} (v : BitVec m)
(hm : i < m) (h : m <= n + i) :
(v >>> n)[i]'hm = false
Together with `BitVec.getElem_shiftRight_lt`, this states that every in-range
source bit moves downward by the count and every newly exposed high bit is
zero. Because the carrier is unsigned, there is no sign extension.
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive unsigned U64 right shift. The Aeneas branch condition also
succeeds and returns `ok` of `BitVec.ushiftRight n`. `UScalar.ShiftRight_spec`
and the BitVec lemmas identify both results as the same 64-bit word,
equivalently `floor(x / 2^n)`, with every newly exposed high bit filled by zero.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shr preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:c7bf907943f81d29c22db959e27e01167f6017f6da42fcd4d4e252ada7b295c5 |
| Preservation current fingerprint | preservation-v1:c7bf907943f81d29c22db959e27e01167f6017f6da42fcd4d4e252ada7b295c5 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","lean_semantic_closure":"bbcd776bcbece10394a6604d8dbf65a3358ba69df0a542ed3aebad167aa0eca9","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","lean_semantic_closure":"bbcd776bcbece10394a6604d8dbf65a3358ba69df0a542ed3aebad167aa0eca9","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "0b2e20bb1bba8db77d9379c8bd14d161bfa7d1889e1abd6a892046bfb54e5d18",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:c7bf907943f81d29c22db959e27e01167f6017f6da42fcd4d4e252ada7b295c5"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T2_current-applicability.txt",
"sha256": "aefdc935645f37c69a2c3f2e7c2fb00baad81970455148f3dbb591b0eeabced3",
"cited_by": [
"Tablet/ModelU64Shl.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation-probe.rs",
"sha256": "268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation.txt",
"sha256": "e19a2cd2283c8435f6d6107d06ccc798cbba4d63f0220b32b5216e43ad071aac",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/u64-bitand.txt",
"sha256": "6a48b1a79f8a52a27fb06a0b25cda9de24f68395d66ab668ecac721806883f54",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-bitor.txt",
"sha256": "f3dadaec6c4ebc98d0d3178bf29df7436e52998b6b97e8d108ca97a6f8092e70",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl-probe.rs",
"sha256": "a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8",
"cited_by": [
"Tablet/ModelU64Shl.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shl.txt"
]
},
{
"path": "reference/model-evidence/u64-shl.txt",
"sha256": "e4cacfd29333a91c1258524a520e849325a85a05cf50b0065ffbf91d7977f69c",
"cited_by": [
"Tablet/ModelU64Shl.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shr-probe.rs",
"sha256": "11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/u64-shr.txt",
"sha256": "c0295af2452a4748bc1a642580414acfc76285ba87b6203b6cbff7ff9924b6ad",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
}
]core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
Inspect related source (1)
- shr · core/src/ops/bit.rs:612 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr |
|---|---|
| Recorded source | /rustc/library/core/src/ops/bit.rs |
| Lines | 612:12–612:41 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Std.U64 → Std.U32 → Result Std.U64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelU64Shr]
def ModelU64Shr (x : Std.U64) (y : Std.U32) : Result Std.U64 :=
-- BODY
x >>> y
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
inspect-native result, exact declaration and binding identities,
complete relevant call inventory, checked compiler/library/configuration
identities, and reproduced checked probe and general MIR are in
reference/model-evidence/P89_T2_current-applicability.txt.
The restored source is directly retained at
reference/model-evidence/u64-shr-probe.rs.
That current inspection identifies this exact external as
Shr<u32> for u64, with signature
Std.U64 -> Std.U32 -> Result Std.U64, its Rust source span, and its
raw declaration hash. At that span the approved rust-src defines the method as
self >> other, instantiates it for u64/u32, and
marks it rustc_inherit_overflow_checks. The frozen Cargo profiles
enable overflow checks and use unwinding panics; a same-toolchain probe and MIR
show the general dynamic-count guard n < 64, followed by the logical
u64 right shift on success and the checked-overflow unwind edge
otherwise.Std.U64 and Std.U32 are
respectively 64- and 32-bit unsigned scalar carriers. The >>>
instance resolves through UScalar.shiftRight_UScalar to a branch on
the count's full unsigned value. Below 64 it returns ok of
BitVec.ushiftRight; the pinned scalar specification and bit-vector
lemmas identify its value as the mathematical unsigned right shift and its bits
as the exact lowward shift with zero-filled high bits. At 64 or above it
returns fail integerOverflow. Thus, case by case over every 32-bit
count, the binding and Rust both produce the same logical 64-bit result below
64, while the Rust checked-shift panic and the extracted Aeneas
integerOverflow failure correspond at 64 and above. No
source-reachability restriction is used.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelU64Shr · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T2_current-applicability.txt
Current applicability of reused binary64 and U64 preservation evidence
Task 11 / worker request 118; checked in the current private checkout.
All commands below ran in this assignment; EXIT records the command status.
Rust commands use LD_LIBRARY_PATH=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib
and RUSTUP_TOOLCHAIN=nightly-2026-06-01.
The managed Lean commands are recorded separately, not invoked by this script.
Reuse and scope
===============
Read-only predecessor: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002
The historical 45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
generated.lean hash belongs to that predecessor, never the current extraction.
The old primary evidence retains its original commands, raw identities and results.
Current checks below establish applicability; prior worker task 9 was rejected,
accepted=false, and its self-report is neither publication nor certification.
Only preservation sections of the six listed owners and ten reserved evidence paths
are submitted. No ordinary statement, Lean computation, GOAL pair, source, extraction,
provenance, Preamble, binding, dispatcher owner or existing config delta is edited.
No new node, route, under-model premise, GOAL decline or polarity change is proposed.
The new 2^59 exponent fold, final-point repair and A/B GOAL domains are not old semantics.
Unchanged primitive meanings are reused, not old parser correctness or old counterexamples.
{
"task_execution": {
"binding": {
"allowed_tasks": [
"ordinary",
"lean_closure"
],
"lightweight": false,
"max_timeout_seconds": 14400,
"model": "gpt-6.1-sol",
"provider": "codex",
"reasoning_effort": "xhigh",
"timeout_seconds": 14400
},
"compiler": "managed",
"profile": "sol-xhigh",
"task_id": 11,
"task_kind": "ordinary"
},
"acceptance_logic_identity": "trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91",
"parallel_scope": {
"exclusive": true,
"helper_prefixes": [
"P116_T1_"
],
"nodes": [
"Binary64ModelDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"shared_writes": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
]
}
}
Current file, compiler, configuration and library identities
============================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum GOAL.md generated.lean Tablet/model-support.json modeling-input/manifest.json modeling-input/extraction.json modeling-input/tool-identities.json modeling-input/SETUP.md modeling-input/revision-from.json crate/Cargo.toml crate/rust-toolchain.toml lean-toolchain lakefile.lean lake-manifest.json trellis.config.json reference/model-evidence/binary64-boundary.txt crate/dec2flt/common.rs crate/dec2flt/decimal.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/fpu.rs crate/dec2flt/lemire.rs crate/dec2flt/mod.rs crate/dec2flt/parse.rs crate/dec2flt/slow.rs crate/dec2flt/table.rs crate/lib.rs crate/num/imp/mod.rs crate/num/mod.rs crate/traits.rs upstream/dec2flt/common.rs upstream/dec2flt/decimal.rs upstream/dec2flt/decimal_seq.rs upstream/dec2flt/fpu.rs upstream/dec2flt/lemire.rs upstream/dec2flt/mod.rs upstream/dec2flt/parse.rs upstream/dec2flt/slow.rs upstream/dec2flt/table.rs upstream/traits.rs reference/model-evidence/binary64-probe.rs reference/model-evidence/binary64-negation-probe.rs reference/model-evidence/u64-shl-probe.rs reference/model-evidence/u64-shr-probe.rs Tablet/Binary64ModelDefault.lean Tablet/ModelF64Neg.lean Tablet/ModelU64BitAnd.lean Tablet/ModelU64BitOr.lean Tablet/ModelU64Shl.lean Tablet/ModelU64Shr.lean
EXIT: 0
STDOUT:
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
1a7d2eea7888b7bdb0421ed6bb96c5ee1e80afe8e788438cd30725f2120a2aea modeling-input/revision-from.json
10584b73664d42dc85fb009bb0783a616520c2cc05f3b0f8c64e5d5cb32e2905 crate/Cargo.toml
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
8dab550b59cec828a4ba436bc25ce9ad66547bdd7f55899b8cbf7e4f65389518 lakefile.lean
a5f9756cd42129193c0285127cddb734224e9c69686fc2de56de2c9d48ed0695 lake-manifest.json
d8fceb13f84ecbf5bf6e9fd7ecdcb061569cfabdb0079243e2eb1609d012ac02 trellis.config.json
749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e reference/model-evidence/binary64-boundary.txt
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b crate/lib.rs
df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1 crate/num/imp/mod.rs
d84067991b142196281bc0968d32634bdcdb9a3a41c2ce2fd3c344d0f61504af crate/num/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e reference/model-evidence/binary64-probe.rs
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8 reference/model-evidence/u64-shl-probe.rs
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee reference/model-evidence/u64-shr-probe.rs
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3 Tablet/Binary64ModelDefault.lean
9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2 Tablet/ModelF64Neg.lean
3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179 Tablet/ModelU64BitAnd.lean
aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f Tablet/ModelU64BitOr.lean
af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad Tablet/ModelU64Shl.lean
54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b Tablet/ModelU64Shr.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo /home/leanagent/pv_spike/tools/charon/bin/charon /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
EXIT: 0
STDOUT:
54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade /home/leanagent/pv_spike/tools/charon/bin/charon
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
STDERR:
(empty)
All installed tool hashes equal the current tool-identities.json pins.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
EXIT: 0
STDOUT:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print cfg --target x86_64-unknown-linux-gnu
EXIT: 0
STDOUT:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat crate/Cargo.toml modeling-input/extraction.json
EXIT: 0
STDOUT:
# Standalone extraction package for the supplied `core::num::dec2flt` slice.
# The package metadata and profiles select the configured environment; source
# correspondence and extraction adaptations are recorded in ../SETUP.md and
# local preservation comments.
[package]
name = "dec2flt-model"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
path = "lib.rs"
[features]
default = []
optimize_for_size = []
[profile.dev]
overflow-checks = true
[profile.release]
overflow-checks = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(target_has_reliable_f16)"] }
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
STDERR:
(empty)
Current effective tools:
{
"aeneas": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"cargo": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"charon": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"env": {
"LD_LIBRARY_PATH": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib",
"RUSTUP_TOOLCHAIN": "nightly-2026-06-01"
},
"lean": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"lean_paths": [
"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean"
],
"readonly": [
"/home/leanagent/pv_spike/tools",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages"
],
"timeouts": {
"aeneas": 3600,
"cargo": 600,
"charon": 600,
"lean": 3600
}
}
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
EXIT: 0
STDOUT:
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
EXIT: 0
STDOUT:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
100644 blob f8582928fe49a0ce75e143b46bb0a8826d7fddae backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
100644 blob d3eb5022efc22d1d6c3ac055965f612c7f2fbca9 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
100644 blob f7bc57109569cdd0fb0c3323021c73673dcfcd33 backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
100644 blob e5733a774268c8dee71bd4ba402240d151bb8cb8 backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
Predecessor pair and probe reuse checks
=======================================
Tablet/Binary64ModelDefault.lean: predecessor_sha256=03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3; whole Lean byte-identical.
Tablet/Binary64ModelDefault.tex: predecessor_sha256=57c6e9ed282cf2dd718f822c6a31255040c71b5c7531488f3951d9c4d4d8b822; ordinary NL definition byte-identical.
Tablet/ModelF64Neg.lean: predecessor_sha256=9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2; whole Lean byte-identical.
Tablet/ModelF64Neg.tex: predecessor_sha256=9d2811046df611e45e2637da57241bace75c3de5822e03126de5f1fc9faeb859; ordinary NL definition byte-identical.
Tablet/ModelU64BitAnd.lean: predecessor_sha256=3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179; whole Lean byte-identical.
Tablet/ModelU64BitAnd.tex: predecessor_sha256=db8a1445918e94fd1c11f92f1c5f218f165aec945ac2ebdeda3cc1675165f8fe; ordinary NL definition byte-identical.
Tablet/ModelU64BitOr.lean: predecessor_sha256=aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f; whole Lean byte-identical.
Tablet/ModelU64BitOr.tex: predecessor_sha256=fbbb37c3cfa81c5811869baf46671d93a6c457042f0a5bbb78ba32c26607dbe2; ordinary NL definition byte-identical.
Tablet/ModelU64Shl.lean: predecessor_sha256=af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad; whole Lean byte-identical.
Tablet/ModelU64Shl.tex: predecessor_sha256=725582880c20b16d00487e01aceb0552a39263616563280cee0d49635984beab; ordinary NL definition byte-identical.
Tablet/ModelU64Shr.lean: predecessor_sha256=54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b; whole Lean byte-identical.
Tablet/ModelU64Shr.tex: predecessor_sha256=3def4409d97d8316d4d77dc2fe01c4142219859ea9596b835ac40f83c3a18784; ordinary NL definition byte-identical.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-negation-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-negation-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shl-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shr-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
Current raw declarations and exact support bindings
===================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py inspect-native .
EXIT: 0
STDOUT:
{
"full_index": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json",
"declaration_count": 24,
"declarations": [
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 \u2192 Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 \u2192 Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 \u2192 Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 \u2192 Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 \u2192 Std.U64 \u2192 Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02"
}
],
"declarations_omitted": 9
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
EXIT: 0
STDOUT:
fbe3b76ef8fbb588841979e071c52eee0fc850472ac55da6f2ca2033e4a34cf4 /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
STDERR:
(empty)
RAW DECLARATION:
/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:
Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43
Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]
Visibility: public -/
@[rust_fun "core::clone::impls::{core::clone::Clone<f64>}::clone"]
axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dfbdb508142706b4c716f701e52a26d63d764f088dacfa461dd81c6df0b9bf0d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_DIGITS]
Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34
Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_DIGITS"]
axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 19dc0621c0c5c7d2a24f090dd7870ffa858de15fc4e1cc7bf57f16d64816c9bc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NAN]
Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22
Name pattern: [core::f64::{f64}::NAN]
Visibility: public -/
@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 75cd3ccca5992f42ef5afa9287573410d249d40f9bcc3120fae72389b2e2419d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27
Name pattern: [core::f64::{f64}::INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::INFINITY"]
axiom core.f64.F64.INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 9a5fb08a6bae926bafdba709d6da6aaad52b8f41c7dbf3e4b2a28b2bc0542716
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NEG_INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31
Name pattern: [core::f64::{f64}::NEG_INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::NEG_INFINITY"]
axiom core.f64.F64.NEG_INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f5d6435579e1da8caecfc1a3b0039a0ce4e250e7dc55c4c69f3edbdd2a5a10f6
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::EXPONENT_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32
Name pattern: [core::f64::{f64}::EXPONENT_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::EXPONENT_MASK"]
axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dcd87a62501dc8e76079204a4b43546a4750077e1f425f01dcd58c96bf31a865
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32
Name pattern: [core::f64::{f64}::MANTISSA_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_MASK"]
axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): cf1585ae2e94a7bf5bb6b5ff37a06a0677b7e8d81420c1e0ca7ee29eca8cfd4c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::classify]:
Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45
Name pattern: [core::f64::{f64}::classify]
Visibility: public -/
@[rust_fun "core::f64::{f64}::classify"]
axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
IDENTITY AND BINDING:
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 7cf497c5bfc31455d5490d5da75914d7eaf9e522aa2eccd14fe9935502b5127c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::to_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37
Name pattern: [core::f64::{f64}::to_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::to_bits"]
axiom core.f64.F64.to_bits : F64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b35203125fea8ba89df874b609344bbe8ad61a61fcb946a184a72c729a1e3364
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::from_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42
Name pattern: [core::f64::{f64}::from_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::from_bits"]
axiom core.f64.F64.from_bits : Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f819b0951f4f63943abf8d4787a2f9489ffd1137fa91529e0771a303bc8fcb94
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41
Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul"]
axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 4adead3b54aa85bfb81b7122b0e942b2c6f3d232d548d8361a2a2ca067be1e7f
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41
Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div"]
axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 62ca24414fa18ef9709d7c5703429d7262f27d017abc975ffb532ae284ba054a
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 945f30e7dbb62802e6ba5bb9d9445e100528b2a52d3b0b6a3a0629c939ff9860
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b66bd94c28f512804622c3717705dbe7ef5a3ced5beaac7435704d053038c36e
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 68909ba4060a48df31ea54bcf0510b089709a3a644c9c1b0770780a98d31f4cc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 5c0105f2c7ce3d255f053e0ccbefa65f73f65de1462832217571cf8cd4963e47
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f100256a450680392496fb74934592e9e2822a1648320153e27c1c0d100ff482
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5
Visibility: public -/
axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
: Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 0bb769d884e3d54d7aa94163fdf4c8fc589050ed84f4fa0d11f694cf599cdb8f
All four identity fields and full raw declaration equal predecessor; current binding matches.
Complete relevant call and wiring inventories
=============================================
This deliberately includes record wiring and scalar lowerings, not just direct external calls.
The four U64 external trait fields wire into Int; generic scalar notation in generated.lean
also lowers directly to the installed operations with the same full-domain meanings.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n 'F64\.Insts\.(CoreClone|CoreOpsArith)|core\.f64\.F64\.|U64\.Insts\.CoreOpsBit|coreops(bit|arith)|\.from_u64|\.pow10_fast_path|FloatInst\.(INFINITY|NEG_INFINITY|NAN|NEG_NAN|SIG_|EXP_|INFINITE_POWER)|&&&|\|\|\||<<<|>>>' generated.lean
EXIT: 0
STDOUT:
25:axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
31:def F64.Insts.CoreCloneClone : core.clone.Clone F64 := {
32: clone := F64.Insts.CoreCloneClone.clone
40: cloneInst := F64.Insts.CoreCloneClone
48:axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
54:@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
61:axiom core.f64.F64.INFINITY : Result F64
68:axiom core.f64.F64.NEG_INFINITY : Result F64
75:axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
82:axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
101:axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
108:axiom core.f64.F64.to_bits : F64 → Result Std.U64
115:axiom core.f64.F64.from_bits : Std.U64 → Result F64
138:axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
144:def F64.Insts.CoreOpsArithMulF64F64 : core.ops.arith.Mul F64 F64 F64 := {
145: mul := F64.Insts.CoreOpsArithMulF64F64.mul
162:axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
168:def F64.Insts.CoreOpsArithDivF64F64 : core.ops.arith.Div F64 F64 F64 := {
169: div := F64.Insts.CoreOpsArithDivF64F64.div
185:axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
191:def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
192: neg := F64.Insts.CoreOpsArithNegF64.neg
200:axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
207:def U64.Insts.CoreOpsBitBitAndU64U64 : core.ops.bit.BitAnd Std.U64 Std.U64
209: bitand := U64.Insts.CoreOpsBitBitAndU64U64.bitand
226:axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
233:def U64.Insts.CoreOpsBitBitOrU64U64 : core.ops.bit.BitOr Std.U64 Std.U64
235: bitor := U64.Insts.CoreOpsBitBitOrU64U64.bitor
252:axiom U64.Insts.CoreOpsBitShlU32U64.shl
259:def U64.Insts.CoreOpsBitShlU32U64 : core.ops.bit.Shl Std.U64 Std.U32 Std.U64
261: shl := U64.Insts.CoreOpsBitShlU32U64.shl
278:axiom U64.Insts.CoreOpsBitShrU32U64.shr
285:def U64.Insts.CoreOpsBitShrU32U64 : core.ops.bit.Shr Std.U64 Std.U32 Std.U64
287: shr := U64.Insts.CoreOpsBitShrU32U64.shr
393: let i ← lift (a ||| b)
394: let i1 ← lift (i &&& 9259542123273814144#u64)
635: coreopsbitShrSelfU32SelfInst : core.ops.bit.Shr Self Std.U32 Self
636: coreopsbitShlSelfU32SelfInst : core.ops.bit.Shl Self Std.U32 Self
637: coreopsbitBitAndInst : core.ops.bit.BitAnd Self Self Self
638: coreopsbitBitOrInst : core.ops.bit.BitOr Self Self Self
664: coreopsarithDivInst : core.ops.arith.Div Self Self Self
665: coreopsarithNegInst : core.ops.arith.Neg Self Self
666: coreopsarithMulInst : core.ops.arith.Mul Self Self Self
726: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
727: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
728: (coreopsarithNegInst : core.ops.arith.Neg F F)
739: let value ← LemireInst.from_u64 self.mantissa
746: let t ← LemireInst.pow10_fast_path i2
747: coreopsarithDivInst.div value t
751: let t ← LemireInst.pow10_fast_path i1
752: coreopsarithMulInst.mul value t
754: then let t ← coreopsarithNegInst.neg value1
769: let t ← LemireInst.from_u64 val
771: let t1 ← LemireInst.pow10_fast_path i4
772: let value ← coreopsarithMulInst.mul t t1
774: then let t2 ← coreopsarithNegInst.neg value
1018: let i5 ← lift (1#u8 &&& i4)
1219: let shift1 ← lift (shift &&& 63#usize)
1228: let i1 ← x_a >>> 11#i32
1230: let i2 ← lift (2047#u16 &&& x_a)
1232: let i3 ← lift (2047#u16 &&& x_b)
1264: let i2 ← i1 <<< shift
1370: let i ← n >>> shift
1400: let i ← n >>> shift
1451: let i1 ← n >>> shift
1453: let i2 ← lift (n &&& mask)
1490: let i ← n >>> shift
1492: let i1 ← lift (n &&& mask)
1544: let i4 ← 1#u64 <<< shift
1704: let i3 ← 1#i64 <<< 59#i32
2971: let i3 ← r >>> 64#i32
2990: then 18446744073709551615#u64 >>> precision
3000: let i4 ← lift (first_hi &&& mask)
3016: let i2 ← i1 >>> 16#i32
3028: let i ← traitsFloatInst.INFINITE_POWER
3045: let w1 ← w <<< lz
3046: let i5 ← traitsFloatInst.SIG_BITS
3058: let i8 ← hi >>> 63#i32
3064: let mantissa ← hi >>> i12
3070: let i18 ← traitsFloatInst.EXP_MIN
3081: let mantissa1 ← mantissa >>> i22
3082: let i23 ← lift (mantissa1 &&& 1#u64)
3084: let mantissa3 ← mantissa2 >>> 1#i32
3085: let i24 ← 1#u64 <<< i5
3102: let i24 ← lift (mantissa &&& 3#u64)
3108: let i28 ← mantissa <<< i27
3111: ok (mantissa &&& i29)
3117: let i20 ← lift (mantissa1 &&& 1#u64)
3119: let mantissa3 ← mantissa2 >>> 1#i32
3120: let i21 ← 2#u64 <<< i5
3125: let mantissa5 ← 1#u64 <<< i5
3129: let i22 ← 1#u64 <<< i5
3131: let mantissa5 ← lift (mantissa4 &&& i23)
3137: let i8 ← hi >>> 63#i32
3143: let mantissa ← hi >>> i12
3149: let i18 ← traitsFloatInst.EXP_MIN
3160: let mantissa1 ← mantissa >>> i22
3161: let i23 ← lift (mantissa1 &&& 1#u64)
3163: let mantissa3 ← mantissa2 >>> 1#i32
3164: let i24 ← 1#u64 <<< i5
3181: let i24 ← lift (mantissa &&& 3#u64)
3187: let i28 ← mantissa <<< i27
3190: ok (mantissa &&& i29)
3196: let i20 ← lift (mantissa1 &&& 1#u64)
3198: let mantissa3 ← mantissa2 >>> 1#i32
3199: let i21 ← 2#u64 <<< i5
3204: let mantissa5 ← 1#u64 <<< i5
3208: let i22 ← 1#u64 <<< i5
3210: let mantissa5 ← lift (mantissa4 &&& i23)
3232: let i ← LemireInst.traitsFloatExtInst.FloatInst.SIG_TOTAL_BITS
3233: 1#u64 <<< i
3240: let bits ← core.f64.F64.to_bits self
3241: let i ← bits >>> 63#i32
3245: let i1 ← core.f64.F64.EXPONENT_MASK
3246: let i2 ← lift (bits &&& i1)
3247: let i3 ← i2 >>> 52#i32
3253: let i4 ← core.f64.F64.MANTISSA_MASK
3254: let i5 ← lift (bits &&& i4)
3255: i5 <<< 1#i32
3258: let i4 ← core.f64.F64.MANTISSA_MASK
3259: let i5 ← lift (bits &&& i4)
3260: let i6 ← 1#u64 <<< 52#i32
3261: ok (i5 ||| i6)
3269:def F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3271: core.f64.F64.from_bits v
3278: core.f64.F64.classify self
3285: core.f64.F64.to_bits self
3324: core.f64.F64.MANTISSA_MASK
3331: core.f64.F64.EXPONENT_MASK
3339: core.f64.F64.MANTISSA_DIGITS
3352: core.f64.F64.from_bits 18444492273895866368#u64
3359: core.f64.F64.NAN
3366: core.f64.F64.NEG_INFINITY
3373: core.f64.F64.INFINITY
3381: let i ← FloatInst.EXP_BIAS
3392: let i ← FloatInst.EXP_SAT
3393: i >>> 1#i32
3402: let i ← FloatInst.EXP_SAT
3411: let i ← FloatInst.EXP_BITS
3412: let i1 ← 1#u32 <<< i
3422: let i1 ← FloatInst.SIG_BITS
3432: let i ← FloatInst.SIG_TOTAL_BITS
3471: coreopsbitShrSelfU32SelfInst := U64.Insts.CoreOpsBitShrU32U64
3472: coreopsbitShlSelfU32SelfInst := U64.Insts.CoreOpsBitShlU32U64
3473: coreopsbitBitAndInst := U64.Insts.CoreOpsBitBitAndU64U64
3474: coreopsbitBitOrInst := U64.Insts.CoreOpsBitBitOrU64U64
3512: coreopsarithDivInst := F64.Insts.CoreOpsArithDivF64F64
3513: coreopsarithNegInst := F64.Insts.CoreOpsArithNegF64
3514: coreopsarithMulInst := F64.Insts.CoreOpsArithMulF64F64
3529: from_u64_bits := F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3537:axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3543:def F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3545: let i ← lift (exponent &&& 31#usize)
3547: | 0 => core.f64.F64.from_bits 4607182418800017408#u64
3548: | 1 => core.f64.F64.from_bits 4621819117588971520#u64
3549: | 2 => core.f64.F64.from_bits 4636737291354636288#u64
3550: | 3 => core.f64.F64.from_bits 4652007308841189376#u64
3551: | 4 => core.f64.F64.from_bits 4666723172467343360#u64
3552: | 5 => core.f64.F64.from_bits 4681608360884174848#u64
3553: | 6 => core.f64.F64.from_bits 4696837146684686336#u64
3554: | 7 => core.f64.F64.from_bits 4711630319722168320#u64
3555: | 8 => core.f64.F64.from_bits 4726483295884279808#u64
3556: | 9 => core.f64.F64.from_bits 4741671816366391296#u64
3557: | 10 => core.f64.F64.from_bits 4756540486875873280#u64
3558: | 11 => core.f64.F64.from_bits 4771362005757984768#u64
3559: | 12 => core.f64.F64.from_bits 4786511204640096256#u64
3560: | 13 => core.f64.F64.from_bits 4801453603149578240#u64
3561: | 14 => core.f64.F64.from_bits 4816244402031689728#u64
3562: | 15 => core.f64.F64.from_bits 4831355200913801216#u64
3563: | 16 => core.f64.F64.from_bits 4846369599423283200#u64
3564: | 17 => core.f64.F64.from_bits 4861130398305394688#u64
3565: | 18 => core.f64.F64.from_bits 4876203697187506176#u64
3566: | 19 => core.f64.F64.from_bits 4891288408196988160#u64
3567: | 20 => core.f64.F64.from_bits 4906019910204099648#u64
3568: | 21 => core.f64.F64.from_bits 4921056587992461136#u64
3569: | 22 => core.f64.F64.from_bits 4936209963552724370#u64
3570: | _ => core.f64.F64.from_bits 0#u64
3606: F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3607: from_u64 := F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3643: let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
3644: let i2 ← i <<< i1
3645: let word ← lift (x.m ||| i2)
3646: traitsFloatExtInst.from_u64_bits word
3903: let i ← traitsFloatInst.EXP_MIN
3939: let i ← traitsFloatInst.INFINITE_POWER
3971: let i5 ← traitsFloatInst.EXP_MIN
3977: let i8 ← traitsFloatInst.SIG_BITS
3984: let i12 ← 1#u64 <<< i11
3999: let i16 ← 1#u64 <<< i8
4004: let i17 ← 1#u64 <<< i8
4006: let mantissa2 ← lift (mantissa1 &&& i18)
4011: let i14 ← 1#u64 <<< i8
4016: let i15 ← 1#u64 <<< i8
4018: let mantissa1 ← lift (mantissa &&& i16)
4035: let register1 ← lift (register &&& 16131858542891098079#u64)
4039: let float ← traitsFloatInst.INFINITY
4041: then let t ← traitsFloatInst.coreopsarithNegInst.neg float
4056: let i5 ← c <<< 16#i32
4057: let i6 ← b <<< 8#i32
4058: let i7 ← lift (i5 ||| i6)
4059: let register ← lift (i7 ||| a)
4060: let register1 ← lift (register &&& 16131858542891098079#u64)
4063: let float ← traitsFloatInst.INFINITY
4066: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4071: let float ← traitsFloatInst.NAN
4074: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4237: let i1 ← v1 >>> 8#i32
4239: let i2 ← lift (v2 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4243: let i3 ← v2 >>> 16#i32
4244: let i4 ← lift (i3 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4249: let i6 ← i5 >>> 32#i32
4561: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4562: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4563: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4611: coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
4656: let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
4657: let i2 ← i <<< i1
4658: let assembled_word ← lift (selected_pair.m ||| i2)
4664: let result ← coreopsarithNegInst.neg assembly_result
4731: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4732: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4733: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4737: num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
4738: coreopsarithMulInst coreopsarithNegInst s
STDERR:
(empty)
Rust inventory is a complete operation-syntax superset, including generic and scalar forms;
trait bounds, comments and non-U64 integer operations are included, not silently omitted.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n '<<|>>|[&|]|Neg::neg|Div::div|Mul::mul|from_u64|pow10_fast_path|SIG_BITS|SIG_TOTAL_BITS|F::NAN|F::INFINITY|Some\(-float\)' crate/traits.rs crate/dec2flt
EXIT: 0
STDOUT:
crate/traits.rs:95: const SIG_TOTAL_BITS: u32;
crate/traits.rs:101: const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
crate/traits.rs:104: const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
crate/traits.rs:110: const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
crate/traits.rs:116: const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
crate/traits.rs:137: /// (in the 32-bit case). In both cases,the power of five(5^|q|)
crate/traits.rs:172: fn from_u64_bits(v: u64) -> Self;
crate/traits.rs:177: /// exponent will be `-(EXP_BIAS + SIG_BITS)`, which is the minimum subnormal power. For
crate/traits.rs:178: /// infinity or NaN, the exponent will be `EXP_SAT - EXP_BIAS - SIG_BITS`.
crate/traits.rs:204: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:229: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:230: Self::from_bits((v & 0xFFFF) as u16)
crate/traits.rs:238: let sign = if bits >> 15 == 0 { 1 } else { -1 };
crate/traits.rs:239: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
crate/traits.rs:241: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:243: (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
crate/traits.rs:264: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:288: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:289: f32::from_bits((v & 0xFFFFFFFF) as u32)
crate/traits.rs:297: let sign = if bits >> 31 == 0 { 1 } else { -1 };
crate/traits.rs:298: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
crate/traits.rs:300: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:302: (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
crate/traits.rs:320: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:341: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:350: let sign = if bits >> 63 == 0 { 1 } else { -1 };
crate/traits.rs:351: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
crate/traits.rs:353: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:355: (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
crate/dec2flt/common.rs:10: fn read_u64(&self) -> u64;
crate/dec2flt/common.rs:13: fn write_u64(&mut self, value: u64);
crate/dec2flt/common.rs:16: fn offset_from(&self, other: &Self) -> isize;
crate/dec2flt/common.rs:22: fn read_u64(&self) -> u64 {
crate/dec2flt/common.rs:24: tmp.copy_from_slice(&self[..8]);
crate/dec2flt/common.rs:29: fn write_u64(&mut self, value: u64) {
crate/dec2flt/common.rs:30: self[..8].copy_from_slice(&value.to_le_bytes())
crate/dec2flt/common.rs:34: fn offset_from(&self, other: &Self) -> isize {
crate/dec2flt/common.rs:47: (a | b) & 0x8080_8080_8080_8080 == 0
crate/dec2flt/mod.rs:116: /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:120: /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:124: /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
crate/dec2flt/mod.rs:127: /// Maximum mantissa for the fast-path (`1 << 53` for f64).
crate/dec2flt/mod.rs:128: const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
crate/dec2flt/mod.rs:131: fn pow10_fast_path(exponent: usize) -> Self;
crate/dec2flt/mod.rs:137: fn from_u64(v: u64) -> Self;
crate/dec2flt/mod.rs:147: // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
crate/dec2flt/mod.rs:153: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:157: match exponent & 7 {
crate/dec2flt/mod.rs:172: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:183: // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
crate/dec2flt/mod.rs:187: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:190: match exponent & 15 {
crate/dec2flt/mod.rs:211: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:218: // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
crate/dec2flt/mod.rs:222: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:226: match exponent & 31 {
crate/dec2flt/mod.rs:263: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:284: word |= (x.p_biased as u64) << F::SIG_BITS;
crate/dec2flt/mod.rs:285: F::from_u64_bits(word)
crate/dec2flt/mod.rs:299: SignOnly { body: &'a [u8], negative: bool },
crate/dec2flt/mod.rs:302: body: &'a [u8],
crate/dec2flt/mod.rs:309: body: &'a [u8],
crate/dec2flt/mod.rs:317: body: &'a [u8],
crate/dec2flt/mod.rs:330: pub body: &'a [u8],
crate/dec2flt/mod.rs:362: s: &'a str,
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
crate/dec2flt/mod.rs:369: if c == b'-' || c == b'+' {
crate/dec2flt/mod.rs:370: body = &body[1..];
crate/dec2flt/mod.rs:431: // occur exactly when `many_digits && fp.p_biased >= 0`.
crate/dec2flt/mod.rs:432: let second_compute_guard = num.many_digits && fp.p_biased >= 0;
crate/dec2flt/mod.rs:468: let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
crate/dec2flt/mod.rs:472: core::ops::Neg::neg(assembly_result)
crate/dec2flt/mod.rs:514: s: &str,
crate/dec2flt/fpu.rs:31: /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
crate/dec2flt/fpu.rs:32: /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
crate/dec2flt/fpu.rs:33: /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
crate/dec2flt/fpu.rs:52: in(reg) &cw,
crate/dec2flt/fpu.rs:76: in(reg) &mut cw,
crate/dec2flt/fpu.rs:83: set_cw((cw & 0xFCFF) | cw_precision);
crate/dec2flt/fpu.rs:89: fn drop(&mut self) {
crate/dec2flt/decimal.rs:42: fn can_use_fast_path<F: Lemire>(&self) -> bool {
crate/dec2flt/decimal.rs:44: && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
crate/dec2flt/decimal.rs:45: && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
crate/dec2flt/decimal.rs:46: && !self.many_digits
crate/dec2flt/decimal.rs:65: &self,
crate/dec2flt/decimal.rs:84: let value = F::from_u64(self.mantissa);
crate/dec2flt/decimal.rs:88: core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
crate/dec2flt/decimal.rs:90: core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
crate/dec2flt/decimal.rs:99: core::ops::Mul::mul(
crate/dec2flt/decimal.rs:100: F::from_u64(mantissa),
crate/dec2flt/decimal.rs:101: F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
crate/dec2flt/decimal.rs:106: Some(core::ops::Neg::neg(value))
crate/dec2flt/decimal_seq.rs:74: pub(super) fn try_add_digit(&mut self, digit: u8) {
crate/dec2flt/decimal_seq.rs:83: pub fn trim(&mut self) {
crate/dec2flt/decimal_seq.rs:92: while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
crate/dec2flt/decimal_seq.rs:97: pub(super) fn round(&self) -> u64 {
crate/dec2flt/decimal_seq.rs:98: if self.num_digits == 0 || self.decimal_point < 0 {
crate/dec2flt/decimal_seq.rs:118: if self.digits[dp] == 5 && dp + 1 == self.num_digits {
crate/dec2flt/decimal_seq.rs:119: round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
crate/dec2flt/decimal_seq.rs:130: pub(super) fn left_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:142: n += (self.digits[read_index] as u64) << shift;
crate/dec2flt/decimal_seq.rs:176: pub(super) fn right_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:181: while (n >> shift) == 0 && !all_zero {
crate/dec2flt/decimal_seq.rs:191: while (n >> shift) == 0 {
crate/dec2flt/decimal_seq.rs:209: let mask = (1_u64 << shift) - 1;
crate/dec2flt/decimal_seq.rs:211: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:212: n = (10 * (n & mask)) + self.digits[read_index] as u64;
crate/dec2flt/decimal_seq.rs:218: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:219: n = 10 * (n & mask);
crate/dec2flt/decimal_seq.rs:236:fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
crate/dec2flt/decimal_seq.rs:240: while i != 0 && scanning {
crate/dec2flt/decimal_seq.rs:242: if c == b'0' || c == b'.' {
crate/dec2flt/decimal_seq.rs:254:// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
crate/dec2flt/decimal_seq.rs:257:fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
crate/dec2flt/decimal_seq.rs:259: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/decimal_seq.rs:264: &s[count..]
crate/dec2flt/decimal_seq.rs:288:pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
crate/dec2flt/decimal_seq.rs:296: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:297: s = &s[1..];
crate/dec2flt/decimal_seq.rs:300: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:302: if !s.is_empty() && s[0] == b'.' {
crate/dec2flt/decimal_seq.rs:303: s = &s[1..];
crate/dec2flt/decimal_seq.rs:309: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:310: s = &s[1..];
crate/dec2flt/decimal_seq.rs:313: while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
crate/dec2flt/decimal_seq.rs:320: s = &s[8..];
crate/dec2flt/decimal_seq.rs:322: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:350: if ch == b'e' || ch == b'E' {
crate/dec2flt/decimal_seq.rs:362: let mut exponent_suffix = &s[1..];
crate/dec2flt/decimal_seq.rs:363: explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
crate/dec2flt/decimal_seq.rs:375:fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
crate/dec2flt/decimal_seq.rs:433: shift &= 63;
crate/dec2flt/decimal_seq.rs:436: let num_new_digits = (x_a >> 11) as _;
crate/dec2flt/decimal_seq.rs:437: let pow5_a = (0x7FF & x_a) as usize;
crate/dec2flt/decimal_seq.rs:438: let pow5_b = (0x7FF & x_b) as usize;
crate/dec2flt/decimal_seq.rs:439: let pow5 = &TABLE_POW5[pow5_a..];
crate/dec2flt/decimal_seq.rs:441: for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
crate/dec2flt/lemire.rs:32: if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
crate/dec2flt/lemire.rs:39: w <<= lz;
crate/dec2flt/lemire.rs:40: let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
crate/dec2flt/lemire.rs:57: let inside_safe_exponent = (q >= -27) && (q <= 55);
crate/dec2flt/lemire.rs:62: let upperbit = (hi >> 63) as i32;
crate/dec2flt/lemire.rs:63: let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
crate/dec2flt/lemire.rs:71: mantissa >>= -power2 + 1;
crate/dec2flt/lemire.rs:72: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:73: mantissa >>= 1;
crate/dec2flt/lemire.rs:74: power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
crate/dec2flt/lemire.rs:89: && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:90: && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:91: && mantissa & 0b11 == 0b01
crate/dec2flt/lemire.rs:92: && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
crate/dec2flt/lemire.rs:95: mantissa &= !1_u64;
crate/dec2flt/lemire.rs:98: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:99: mantissa >>= 1;
crate/dec2flt/lemire.rs:100: if mantissa >= (2_u64 << F::SIG_BITS) {
crate/dec2flt/lemire.rs:104: mantissa = 1_u64 << F::SIG_BITS;
crate/dec2flt/lemire.rs:108: mantissa &= !(1_u64 << F::SIG_BITS);
crate/dec2flt/lemire.rs:122: (q.wrapping_mul(152_170 + 65536) >> 16) + 63
crate/dec2flt/lemire.rs:128: (r as u64, (r >> 64) as u64)
crate/dec2flt/lemire.rs:140: 0xFFFF_FFFF_FFFF_FFFF_u64 >> precision
crate/dec2flt/lemire.rs:155: if first_hi & mask == mask {
crate/dec2flt/slow.rs:27:pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
crate/dec2flt/slow.rs:33: let get_shift = |n| {
crate/dec2flt/slow.rs:43: if d.num_digits == 0 || d.decimal_point < -324 {
crate/dec2flt/slow.rs:51: while d.decimal_point > 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:69: while d.decimal_point <= 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:73: 0 | 1 => 2,
crate/dec2flt/slow.rs:107: d.left_shift(F::SIG_BITS as usize + 1);
crate/dec2flt/slow.rs:109: if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
crate/dec2flt/slow.rs:120: if mantissa < (1_u64 << F::SIG_BITS) {
crate/dec2flt/slow.rs:124: mantissa &= (1_u64 << F::SIG_BITS) - 1;
crate/dec2flt/parse.rs:23: v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
crate/dec2flt/parse.rs:24: let v1 = (v & MASK).wrapping_mul(MUL1);
crate/dec2flt/parse.rs:25: let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
crate/dec2flt/parse.rs:26: ((v1.wrapping_add(v2) >> 32) as u32) as u64
crate/dec2flt/parse.rs:30:fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
crate/dec2flt/parse.rs:40: s = &s[8..];
crate/dec2flt/parse.rs:50: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:55: s = &s[count..];
crate/dec2flt/parse.rs:61:fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
crate/dec2flt/parse.rs:86:fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
crate/dec2flt/parse.rs:89: while scan_index < start.len() && scanning {
crate/dec2flt/parse.rs:91: if c == b'.' || c == b'0' {
crate/dec2flt/parse.rs:104:fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
crate/dec2flt/parse.rs:107: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:111: s = &s[1..];
crate/dec2flt/parse.rs:113: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:121:pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:129: if c == b'-' || c == b'+' {
crate/dec2flt/parse.rs:137: if !s.is_empty() && s[0].is_ascii_digit() {
crate/dec2flt/parse.rs:145: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:147: if exponent < (1_i64 << 59) {
crate/dec2flt/parse.rs:152: *s_ref = &s[count..];
crate/dec2flt/parse.rs:164:fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:198: if c == b'e' || c == b'E' {
crate/dec2flt/parse.rs:201: exp_number = parse_scientific(&mut s)?;
crate/dec2flt/parse.rs:234:pub fn parse_number(s: &[u8]) -> Option<Decimal> {
crate/dec2flt/parse.rs:244:pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
crate/dec2flt/parse.rs:260: register = (c << 16) | (b << 8) | a;
crate/dec2flt/parse.rs:269: register &= 0xDFDFDFDFDFDFDFDF;
crate/dec2flt/parse.rs:280: (INF_3, 3) => F::INFINITY,
crate/dec2flt/parse.rs:281: (INF_8, 8) => F::INFINITY,
crate/dec2flt/parse.rs:282: (NAN, 3) => F::NAN,
crate/dec2flt/parse.rs:286: if negative { Some(-float) } else { Some(float) }
STDERR:
(empty)
Current guarded native body, exact f64 boundary and unrestricted assembler:
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 39,111p crate/dec2flt/decimal.rs
EXIT: 0
STDOUT:
impl Decimal {
/// Detect if the float can be accurately reconstructed from native floats.
#[inline]
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
/// Try turning the decimal into an exact float representation, using machine-sized integers
/// and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
/// can be exactly represented as a machine float, since IEE-754 guarantees
/// no rounding will occur.
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
pub fn try_fast_path<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
&self,
) -> Option<F> {
// `Lemire` already entails these three operator bounds through
// `Float`; spelling them directly changes no admitted type. Charon
// needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
// The `set_precision` function takes care of setting the precision on architectures which
// require setting it by changing the global state (like the control word of the x87 FPU).
let _cw = set_precision::<F>();
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 112,138p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
///
/// Not intended for use outside of the `dec2flt` module.
#[doc(hidden)]
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
/// Gets a small power-of-ten for fast-path multiplication.
fn pow10_fast_path(exponent: usize) -> Self;
/// Converts integer into float through an as cast.
/// This is only called in the fast-path algorithm, and therefore
/// will not lose precision, since the value will always have
/// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
fn from_u64(v: u64) -> Self;
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 217,286p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
impl Lemire for f64 {
// Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
#[inline]
pub(super) fn pfe_empty() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Empty }
}
// Used in unit tests, keep public.
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
#[inline]
pub fn pfe_invalid() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Invalid }
}
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 315,365p crate/traits.rs
EXIT: 0
STDOUT:
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
// Exact value of trunc(1024 / log2(10)) from the upstream default.
const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
// This is the upstream default after substituting `Self::Int = u64`;
// it preserves every decoded field while avoiding unsupported generic
// associated-integer operator resolution.
fn integer_decode(self) -> (u64, i16, i8) {
let bits = self.to_bits();
let sign = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
let mantissa = if exponent == 0 {
(bits & Self::MANTISSA_MASK) << 1
} else {
(bits & Self::MANTISSA_MASK) | (1_u64 << 52)
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 245,291p crate/dec2flt/parse.rs
EXIT: 0
STDOUT:
// Since a valid string has at most the length 8, we can load
// all relevant characters into a u64 and work from there.
// This also generates much better code.
let mut register;
let len: usize;
// All valid strings are either of length 8 or 3.
if s.len() == 8 {
register = s.read_u64();
len = 8;
} else if s.len() == 3 {
let a = s[0] as u64;
let b = s[1] as u64;
let c = s[2] as u64;
register = (c << 16) | (b << 8) | a;
len = 3;
} else {
return None;
}
// Clear out the bits which turn ASCII uppercase characters into
// lowercase characters. The resulting string is all uppercase.
// What happens to other characters is irrelevant.
register &= 0xDFDFDFDFDFDFDFDF;
// u64 values corresponding to relevant cases
const INF_3: u64 = 0x464E49; // "INF"
const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
const NAN: u64 = 0x4E414E; // "NAN"
// Match register value to constant to parse string.
// Also match on the string length to catch edge cases
// like "inf\0\0\0\0\0".
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
}
STDERR:
(empty)
Fresh constant and symbolic-negation reproduction
=================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C opt-level=0 reference/model-evidence/binary64-probe.rs -o .trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
; ModuleID = 'binary64_negation_probe.566fd6d762029c-cgu.0'
source_filename = "binary64_negation_probe.566fd6d762029c-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 7, !"uwtable", i32 2}
!3 = !{!"rustc version 1.98.0-nightly (14210df0e 2026-05-31)"}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
.file "binary64_negation_probe.566fd6d762029c-cgu.0"
.section .text.neg_f64_trait_bits,"ax",@progbits
.globl neg_f64_trait_bits
.p2align 4
.type neg_f64_trait_bits,@function
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
.Lfunc_end0:
.size neg_f64_trait_bits, .Lfunc_end0-neg_f64_trait_bits
.cfi_endproc
.ident "rustc version 1.98.0-nightly (14210df0e 2026-05-31)"
.section ".note.GNU-stack","",@progbits
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum .trellis/scratch/binary64-probe .trellis/scratch/binary64-negation-probe.ll .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322 .trellis/scratch/binary64-probe
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
STDERR:
(empty)
Fresh checked-shift reproduction and full dynamic-count MIR
===========================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shl-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir ../../reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shl-probe u64-shl-probe.mir
EXIT: 0
STDOUT:
1d8bda234272af0f20a360fe4ff631c8ed038f9aac02bfe539192fff86706d4c u64-shl-probe
1d05de9f3cfb93082c17a57d39f7fc0813c3fe0d3ebd0efe470b0885fba931b9 u64-shl-probe.mir
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shr-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir ../../reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shr-probe u64-shr-probe.mir
EXIT: 0
STDOUT:
1cceba3e03b755a37112c16ad347161a9732793944f34d0a740470584a08c9fc u64-shr-probe
9a72f1d018d926b3e5672c8fb473e2495a710cf4a252c7515e12d2e5009c134e u64-shr-probe.mir
STDERR:
(empty)
Interpretation and limits
=========================
The constant source really evaluates f64::NAN; its nan=7ff8000000000000 observation
fixes that pinned constant, not arbitrary arithmetic-NaN signs or payloads.
The arbitrary-u64 qualified Neg probe passes w in rdi; movabsq loads 2^63 in rax,
xorq combines them, retq returns rax, with no branch or NaN exception. Its XOR law
holds for all 2^64 words, including every signaling/quiet NaN payload.
The checked dynamic-count MIR establishes the whole U64 x U32 branch condition,
not merely seven runtime samples: counts <64 shift, counts >=64 fail, without masking.
AND/OR remain exact over all words. from_u64 still asserts <=2^53 before casting;
the ordinary source guard gives -22<=exponent<=22, mantissa<=2^53, !many_digits.
The disguised source arm checks its integer product and <=2^53 before the cast,
and uses fixed table index 22. Only then may conditional Binary64NativeCallDomain
supply finite non-NaN cast/table operands and a positive nonzero divisor.
Thus reached native arithmetic is exact; generic arithmetic NaNs retain permitted-choice
semantics, not universal exact-bit equivalence. Assembly admits every BiasedFp field pair.
Equal-target preservation retains both rounding relations to the same target, without
deriving uniqueness from vocabulary or assuming an unresolved GOAL conclusion.
All 32 original GOALs remain pursued with their own quantifiers, domains and polarity.
These source-facing checks are evidence, not preservation Sound certification or GOAL proofs.
Managed checks and final scope verification
===========================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py compose-native . --check
EXIT: 0
Selected raw result fields:
{
"full_result": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/compose-native-1791584636440554217.json",
"matches": true,
"changed": false,
"mismatched_files": [],
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
COMMAND: python3 .trellis/scripts/check.py model-support-check .
EXIT: 0
Raw result:
{"ok": true, "errors": []}
COMMAND: python3 .trellis/scripts/check.py tablet . --json
EXIT: 0
Structured projection from the final full managed JSON result:
{
"command": [
"python3",
".trellis/scripts/check.py",
"tablet",
".",
"--json"
],
"exit_status": 0,
"ok": true,
"errors": [],
"node_count": 340,
"all_nodes_compile": true,
"elaboration_failures": [],
"structure_failures": [],
"warning_count": 696,
"warning_examples": [
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:364:4: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:587:8: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/StringIter.lean:13:4: declaration uses `sorry`"
],
"raw_stdout_sha256": "15a1d03a085481d315bcc1a4716aa174475f03e72d8f452f5f33d45a71f5ed91",
"stderr_line_count": 340,
"raw_stderr_sha256": "50c8fde0aef24c1b87ce95c51d21794927d6abba46d90fd04a8d3a714bfed46e"
}
This final command was captured and summarized by
python3 .trellis/scratch/managed-tablet-summary.py (exit 0).
Two earlier identical whole-Tablet checks also exited 0; one jq projection
reported tablet_exit=0 jq_exit=0, node_count=340, failing_elaboration=[],
invalid_structure=[]. The first tool preview truncated its verbose JSON;
that truncation was not used as a proof-closure certificate. The retained
warnings include permitted principal GOAL sketches and installed Aeneas
Slice/StringIter sorry warnings. No definition was supplied with sorry.
These checks establish elaboration, structure and composition freshness,
not preservation Sound or proof closure of the pursued GOALs.
COMMAND: python3 .trellis/scratch/preservation-scope-check.py
EXIT: 0
Raw result:
{
"ok": true,
"owner_checks": [
{
"node": "Binary64ModelDefault",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "210652331cd53e0254aae45856663c01d0552fe992b69608fe243260022ccd79"
},
{
"node": "ModelF64Neg",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "f7d74d4558333c0754ccce8f6861d1409c049fd4dfd1825daad2fd2f441eb78f"
},
{
"node": "ModelU64BitAnd",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "b401e17a058ec2909fb7a58d01f07867f03a933c2901338efebda252692ca6ff"
},
{
"node": "ModelU64BitOr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "c53e3e5ad29cc4419d07c3f2a8913e0f4df87ecbcf4ac1567a9e699a2bd18e2d"
},
{
"node": "ModelU64Shl",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "ed68845da19138d7406e8022c5a9adb765ed70c2ed075f41aea7c190dea9909a"
},
{
"node": "ModelU64Shr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "04b6ec376e7ec490c64183f2a18be832ea574391d7f24d49db7ddc10019cd2f0"
}
],
"principal_goal_pairs": [
{
"node": "AssemblyCorrespondence",
"target": "assembly_correspondence",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationDeterminism",
"target": "classification_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationSignificandDigit",
"target": "classification_significand_digit",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationTotality",
"target": "classification_totality",
"paired_files_byte_unchanged": true
},
{
"node": "ExponentValueAgreement",
"target": "exponent_value_agreement",
"paired_files_byte_unchanged": true
},
{
"node": "IntegerCorrectOrDefer",
"target": "integer_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NativeCorrectOrDefer",
"target": "native_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAcceptance",
"target": "number_helper_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAccumulatedValue",
"target": "number_helper_accumulated_value",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRecordBounds",
"target": "number_helper_record_bounds",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRejection",
"target": "number_helper_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserAccumulatedRounding",
"target": "parser_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserEqualTargetRounding",
"target": "parser_equal_target_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserExactRounding",
"target": "parser_exact_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInfinity",
"target": "parser_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInvalidRejection",
"target": "parser_invalid_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNanAcceptance",
"target": "parser_nan_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNonNanResults",
"target": "parser_non_nan_results",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericAcceptance",
"target": "parser_numeric_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericSign",
"target": "parser_numeric_sign",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserSignedZero",
"target": "parser_signed_zero",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserTotality",
"target": "parser_totality",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_SlowAccumulatedRounding",
"target": "slow_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchAbstractComposition",
"target": "dispatch_abstract_composition",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchComponentCompliance",
"target": "dispatch_component_compliance",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedExponent",
"target": "parser_selected_exponent",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedMagnitudeSign",
"target": "parser_selected_magnitude_sign",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingDeterminism",
"target": "rounding_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingTotality",
"target": "rounding_totality",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperInfinity",
"target": "special_helper_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperNan",
"target": "special_helper_nan",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperRejection",
"target": "special_helper_rejection",
"paired_files_byte_unchanged": true
}
],
"new_nodes": [],
"evidence_consumers_for_current_Sound": [
"Binary64ModelDefault",
"DecimalGoalVocabularyDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"frozen_boundary_unchanged": true,
"pre_existing_config_delta_unchanged": true,
"changed_paths_in_assigned_scope": [
"Tablet/Binary64ModelDefault.tex",
"Tablet/ModelF64Neg.tex",
"Tablet/ModelU64BitAnd.tex",
"Tablet/ModelU64BitOr.tex",
"Tablet/ModelU64Shl.tex",
"Tablet/ModelU64Shr.tex",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
],
"completion_meaning_audit_still_required": true
}
Delivery, acceptance and certification status
============================================
The executed kernel task is task_id=11 (worker request 118), compiler=managed,
under trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91.
Submitted scope is exactly the six owners' preservation sections and ten
reserved evidence paths listed above. No acceptance/publication outcome is
available before worker delivery; the host's real receipt must supply it.
The raw-only worker validator and a Submitted marker mean delivery, not host
acceptance, publication, preservation Sound or Modeling completion.
Keep retry-binary64-preservation-exclusively live until actual publication,
and verify-published-preservation-and-meanings live until current certification.
After publication, request current Sound on all changed evidence consumers,
including DecimalGoalVocabularyDefault's u64-shl/u64-bitor citations, and
repaired support before parents whose named gaps remain open. Do not reset
Binary64ModelDefault's genuine VerifierFail based on these worker checks.
The independent all-32 original-GOAL meaning audit remains required before
Modeling completion; a byte-unchanged pair check is not that semantic audit.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-negation-probe.rs
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
reference/model-evidence/binary64-negation.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
Primary evidence for binary64 trait negation
============================================
Scope and conclusion
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction and the
nightly-2026-06-01 toolchain fixed by modeling-input/SETUP.md and
modeling-input/manifest.json. It establishes the following statement for the
specific extracted Rust operation bound to ModelF64Neg:
For every u64 word w, including every signaling or quiet NaN payload,
to_bits(<f64 as core::ops::Neg>::neg(f64::from_bits(w)))
equals w XOR 0x8000000000000000.
Thus precisely bit 63 is toggled and every other bit is preserved. This is a
universal symbolic result, not an inference from finitely many test inputs.
Pinned identities
-----------------
The following command was run from the repository root. RROOT is the source
tree installed with the configured compiler.
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
RROOT=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
sha256sum "$R" \
"$RROOT/core/src/ops/arith.rs" \
"$RROOT/core/src/primitive_docs.rs" \
crate/dec2flt/mod.rs upstream/dec2flt/mod.rs \
generated.lean Tablet/model-support.json \
modeling-input/tool-identities.json \
reference/model-evidence/binary64-negation-probe.rs
Raw output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
modeling-input/tool-identities.json records the same rustc path and SHA-256.
The compiler reports:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Concrete core implementation
----------------------------
The following exact excerpt is core/src/ops/arith.rs:709-728 in the source
whose SHA-256 is 596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0:
macro_rules! neg_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const Neg for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> $t { -self }
}
forward_ref_unop! { impl Neg, neg for $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
The macro invocation explicitly includes f64. Its expansion is therefore the
concrete `impl Neg for f64`, with `Output = f64`, whose method body is the
primitive expression `-self`.
Frozen parser statement and primitive guarantee
------------------------------------------------
The adapted frozen parser and supplied upstream parser have identical text at
dec2flt/mod.rs:20-22. Their complete-file hashes are pinned above. The exact
three lines are:
//! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
//! process and re-apply it at the very end. This is correct in all edge cases since IEEE
//! floats are symmetric around zero, negating one simply flips the first bit.
The installed primitive documentation is pinned above by SHA-256
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5.
At primitive_docs.rs:1369-1375 it identifies f64 as binary64 and directs the
reader to the f32 documentation for the common floating-point rules:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The exact common rule at primitive_docs.rs:1256-1260 is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
This rule expressly covers unary negation and bit conversion, and expressly
distinguishes them from arithmetic NaN production. It therefore preserves the
quiet/signaling bit and every payload bit for NaNs as well as all non-sign bits
for finite values, zeros, and infinities. The parser statement identifies the
permitted sign-bit change as an actual flip in all edge cases.
Extraction and support binding
------------------------------
The frozen generated.lean, pinned above, contains this exact declaration and
trait implementation record:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
/-- Trait implementation: [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}]
Source: '/rustc/library/core/src/ops/arith.rs', lines 713:8-713:29
Name pattern: [core::ops::arith::Neg<f64, f64>] -/
@[reducible, rust_trait_impl "core::ops::arith::Neg<f64, f64>"]
def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
neg := F64.Insts.CoreOpsArithNegF64.neg
}
Thus the extracted external is the same f64 macro expansion and method body
identified above, not an abstract or different negation operation. Running
`python3 .trellis/scripts/pv_modeling.py inspect-native "$PWD"` and selecting
that declaration gives the following raw inventory fields:
name: F64.Insts.CoreOpsArithNegF64.neg
extracted_signature: : F64 → Result F64
rust_symbol: core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
raw_declaration_sha256: bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0
The raw declaration hash is independently reproduced after that inspection by:
I=$(ls -1t .trellis/scratch/inspect-native-*.json | head -n 1)
jq -j '.. | objects | select(.name? == "F64.Insts.CoreOpsArithNegF64.neg") | .source_utf8' "$I" | sha256sum
Raw output:
bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0 -
Tablet/model-support.json, whose complete-file hash is pinned above, copies all
four identity fields unchanged and binds this external to the model definition:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
Symbolic same-toolchain probe
-----------------------------
The retained probe source is:
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
The argument is an arbitrary symbolic u64. The qualified call forces the same
`Neg for f64` trait method identified by the core source and extraction. The
following exact commands use the extraction's compiler and target and retain
both optimized LLVM IR and assembly in the worker scratch directory:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-negation-probe.rs
IR=.trellis/scratch/binary64-negation-probe.ll
ASM=.trellis/scratch/binary64-negation-probe.s
"$R" --version --verbose
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir "$P" -o "$IR"
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm "$P" -o "$ASM"
sha256sum "$R" "$P" "$IR" "$ASM"
cat "$IR"
cat "$ASM"
Raw hash output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
Raw optimized LLVM IR function:
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
Raw optimized x86_64 assembly function:
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
Under the selected x86_64 C ABI, the symbolic input w arrives in %rdi and the
u64 result is returned in %rax. The loaded signed decimal constant
-9223372036854775808 has u64 bit pattern 0x8000000000000000, with bit 63 set
and every other bit clear. The emitted `xorq %rdi, %rax` therefore returns
w XOR 0x8000000000000000. There is no branch, floating-point exceptional
case, or input precondition in the emitted function.
Universal preservation conclusion
---------------------------------
The core macro and f64 instantiation connect the trait method to primitive
unary `-`; generated.lean and model-support.json connect that exact method to
ModelF64Neg. The parser source says the operation flips the sign bit in all
edge cases, while the primitive guarantee says every non-sign bit is preserved,
including the quiet/signaling and payload bits of NaNs. Finally, the symbolic
same-compiler/same-target probe makes the exact transformation explicit as XOR
with the bit-63 mask for its arbitrary u64 argument.
Because f64::from_bits accepts every one of the 2^64 u64 words and to_bits
returns the resulting raw word, the symbolic input covers the entire modeled
F64 carrier. Consequently the source result for every word is exactly the
model package's `ok` result containing that word with bit 63 toggled. This
includes both signs of zero and infinity, every finite/subnormal word, and
every possible NaN payload without canonicalization or quieting.
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/u64-bitand.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitAnd preservation evidence
================================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitAnd. The commands below were run from the repository
root on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790258751442882118.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790258751442882118.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790258751442882118.json
The exact U64 BitAnd entry in that index is:
name: U64.Insts.CoreOpsBitBitAndU64U64.bitand
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
source: /rustc/library/core/src/ops/bit.rs, lines 178:12-178:42
raw_declaration_sha256: 36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitAndU64U64.bitand") | .source_utf8' \
.trellis/scratch/inspect-native-1790258751442882118.json | sha256sum
Output:
36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line ranges are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '170,187p'
The pinned source says at lines 170-179:
macro_rules! bitand_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitAnd for $t {
type Output = $t;
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
and line 187 instantiates that implementation for u64:
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 conjunction `self & rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
--------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 105-116 and theorem at line 274 are:
def UScalar.and {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv &&& y.bv ⟩
instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where
hAnd x y := UScalar.and x y
theorem UScalar.bv_and {ty} (x y : UScalar ty) :
(x &&& y).bv = x.bv &&& y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 148-153 prove, for every width and bit index:
theorem BitVec.getElem!_and {w} (x y : BitVec w) (i : Nat) :
(x &&& y)[i]! = (x[i]! && y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_and, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.and_self]
Therefore `x &&& y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean conjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-bitor.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitOr preservation evidence
===============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitOr. The commands below were run from the repository root
on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790259866184055823.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790259866184055823.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790259866184055823.json
The exact U64 BitOr entry in that index is:
name: U64.Insts.CoreOpsBitBitOrU64U64.bitor
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
source: /rustc/library/core/src/ops/bit.rs, lines 282:12-282:41
raw_declaration_sha256: 85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitOrU64U64.bitor") | .source_utf8' \
.trellis/scratch/inspect-native-1790259866184055823.json | sha256sum
Output:
85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line range are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '274,291p'
The pinned source says at lines 274-289:
macro_rules! bitor_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitOr for $t {
type Output = $t;
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
forward_ref_binop! { impl BitOr, bitor for $t, $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
and line 291 instantiates that implementation for u64:
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 disjunction `self | rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
-------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 118-126 and theorem at line 275 are:
def UScalar.or {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv ||| y.bv ⟩
instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where
hOr x y := UScalar.or x y
theorem UScalar.bv_or {ty} (x y : UScalar ty) :
(x ||| y).bv = x.bv ||| y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 141-146 prove, for every width and bit index:
theorem BitVec.getElem!_or {w} (x y : BitVec w) (i : Nat) :
(x ||| y)[i]! = (x[i]! || y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_or, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.or_self]
Therefore `x ||| y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean disjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-shl-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x << count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shl.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shl preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shl. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a bounded U64 shift, and all U32 counts at least
64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790260978718245524.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790260978718245524.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790260978718245524.json
The exact U64 Shl entry in that fresh index is:
name: U64.Insts.CoreOpsBitShlU32U64.shl
extracted_signature: : Std.U64 → Std.U32 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
source: /rustc/library/core/src/ops/bit.rs, lines 489:12-489:41
raw_declaration_sha256: e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShlU32U64.shl") | .source_utf8' \
.trellis/scratch/inspect-native-1790260978718245524.json | sha256sum
Output:
e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d -
Thus this boundary is specifically u64 shifted by u32, and its extracted
codomain is the Aeneas Result used below to distinguish normal return from
checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '479,520p'
Lines 479-498 define the implementation macro:
macro_rules! shl_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shl<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shl(self, other: $f) -> $t {
self << other
}
}
forward_ref_binop! { impl Shl, shl for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 500-518 apply `shl_impl! { $t, u32 }` to every type in
`shl_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shl_impl_all {
($($t:ty)*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
shl_impl! { $t, u64 }
shl_impl! { $t, u128 }
shl_impl! { $t, usize }
...
)*)
}
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shl<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self << other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shl-probe.rs
with SHA-256:
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8
It places the same primitive expression `x << count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
./u64-shl-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir \
../../reference/model-evidence/u64-shl-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shl` operation and returns its bounded 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with the
expected truncation to 64 bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 17-21 and 29-31 define:
def UScalar.shiftLeft {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.shiftLeft s ⟩
else fail .integerOverflow
def UScalar.shiftLeft_UScalar {ty tys} (x : UScalar ty) (s : UScalar tys) :
Result (UScalar ty) :=
x.shiftLeft s.val
Lines 81-82 resolve the notation used by Tablet/ModelU64Shl.lean:
instance {ty0 ty1} : HShiftLeft (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftLeft x y := UScalar.shiftLeft_UScalar x y
Consequently `x <<< y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the 64-bit vector shift; at least 64 it is
exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftLeft_spec`, lines 193-205, proves the successful
branch has both equivalent bounded descriptions:
theorem UScalar.ShiftLeft_spec ... (hy : y.val < ty0.numBits) ... :
(x <<< y) ⦃ z =>
z.val = (x.val <<< y.val) % size ∧
z.bv = x.bv <<< y.val ⦄
For U64, `size` is `2^64`; hence the returned natural value is the mathematical
left shift reduced modulo `2^64`, and the returned carrier is exactly the
corresponding 64-bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 248-266 give the bit-level characterization: every result bit below
the shift count (or outside the fixed width) is false, and every in-width bit at
or above the count equals the corresponding input bit at index `i - n`:
theorem BitVec.getElem!_shiftLeft_false ...
(h : i < n ∨ w ≤ i) : (v <<< n)[i]! = false
theorem BitVec.getElem!_shiftLeft_eq ...
(h : n ≤ i ∧ i < w) : (v <<< n)[i]! = v[i - n]!
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive U64 shift. The Aeneas branch condition also succeeds and returns
`ok` of `BitVec.shiftLeft n`. `UScalar.ShiftLeft_spec` and the BitVec lemmas
identify both results as the same 64-bit word, equivalently `(x * 2^n) mod
2^64`, with discarded high bits and zero-filled low bits.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shl preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
reference/model-evidence/u64-shr-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x >> count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shr.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shr preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shr. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a logical U64 right shift, and all U32 counts at
least 64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790262316075577976.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790262316075577976.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790262316075577976.json
The exact U64 Shr entry in that fresh index is:
name: U64.Insts.CoreOpsBitShrU32U64.shr
extracted_signature: : Std.U64 -> Std.U32 -> Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
source: /rustc/library/core/src/ops/bit.rs, lines 612:12-612:41
raw_declaration_sha256: 77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 -> Std.U32 -> Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShrU32U64.shr") | .source_utf8' \
.trellis/scratch/inspect-native-1790262316075577976.json | sha256sum
Output:
77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f -
Tablet/model-support.json binds precisely this indexed declaration and
signature to dec2flt_model.ModelU64Shr. Thus the boundary is specifically u64
shifted by u32, and its extracted codomain is the Aeneas Result used below to
distinguish normal return from checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '602,641p'
Lines 602-620 define the implementation macro:
macro_rules! shr_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shr<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shr(self, other: $f) -> $t {
self >> other
}
}
forward_ref_binop! { impl Shr, shr for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 623-641 apply `shr_impl! { $t, u32 }` to every type in
`shr_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shr_impl_all {
($($t:ty)*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
shr_impl! { $t, u64 }
shr_impl! { $t, u128 }
shr_impl! { $t, usize }
...
)*)
}
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shr<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self >> other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shr-probe.rs
with SHA-256:
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee
It places the same primitive expression `x >> count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
./u64-shr-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir \
../../reference/model-evidence/u64-shr-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shr` operation and returns its logical 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with
zero-filled high bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 23-35 define:
def UScalar.shiftRight {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.ushiftRight s ⟩
else fail .integerOverflow
def UScalar.shiftRight_UScalar {ty tys} (x : UScalar ty)
(s : UScalar tys) : Result (UScalar ty) :=
x.shiftRight s.val
Lines 93-94 resolve the notation used by Tablet/ModelU64Shr.lean:
instance {ty0 ty1} : HShiftRight (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftRight x y := UScalar.shiftRight_UScalar x y
Consequently `x >>> y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the unsigned 64-bit vector shift; at least
64 it is exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftRight_spec`, lines 166-174, proves the successful
branch has both equivalent logical-shift descriptions:
theorem UScalar.ShiftRight_spec ... (hy : y.val < ty0.numBits) :
(x >>> y) ⦃ z =>
z.val = x.val >>> y.val ∧
z.bv = x.bv >>> y.val ⦄
Here natural-number `>>>` is division by `2^y.val`, so the returned numeric
value is `floor(x.val / 2^y.val)`, and the returned carrier is exactly the
unsigned shift of the fixed-width bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 268-283 give the bit-level logical zero-fill characterization. For
every result position, the total bit lookup is the input bit at the offset
position; positions whose offset is outside the 64-bit input are false:
theorem BitVec.getElem!_shiftRight {w} (v : BitVec w) (n i : Nat) :
(v >>> n)[i]! = v[n + i]!
theorem BitVec.getElem_shiftRight_false {m n : Nat} (v : BitVec m)
(hm : i < m) (h : m <= n + i) :
(v >>> n)[i]'hm = false
Together with `BitVec.getElem_shiftRight_lt`, this states that every in-range
source bit moves downward by the count and every newly exposed high bit is
zero. Because the carrier is unsigned, there is no sign extension.
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive unsigned U64 right shift. The Aeneas branch condition also
succeeds and returns `ok` of `BitVec.ushiftRight n`. `UScalar.ShiftRight_spec`
and the BitVec lemmas identify both results as the same 64-bit word,
equivalently `floor(x / 2^n)`, with every newly exposed high bit filled by zero.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shr preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:6c2e2c27a287329080d8b3c95a010f2eaf244ac6500f09b4134707fafd8ba0e6 |
| Preservation current fingerprint | preservation-v1:6c2e2c27a287329080d8b3c95a010f2eaf244ac6500f09b4134707fafd8ba0e6 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","lean_semantic_closure":"9a6c17e6318e8cad264124e8cc76df4b6f714d16b74dd7bd880882b2428694bf","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","lean_semantic_closure":"9a6c17e6318e8cad264124e8cc76df4b6f714d16b74dd7bd880882b2428694bf","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "825a6748850893c4a1c8c99e6620a0763e9bcc16e4bea3052d64197d0b51531a",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:6c2e2c27a287329080d8b3c95a010f2eaf244ac6500f09b4134707fafd8ba0e6"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T2_current-applicability.txt",
"sha256": "aefdc935645f37c69a2c3f2e7c2fb00baad81970455148f3dbb591b0eeabced3",
"cited_by": [
"Tablet/ModelU64Shr.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation-probe.rs",
"sha256": "268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation.txt",
"sha256": "e19a2cd2283c8435f6d6107d06ccc798cbba4d63f0220b32b5216e43ad071aac",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/u64-bitand.txt",
"sha256": "6a48b1a79f8a52a27fb06a0b25cda9de24f68395d66ab668ecac721806883f54",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-bitor.txt",
"sha256": "f3dadaec6c4ebc98d0d3178bf29df7436e52998b6b97e8d108ca97a6f8092e70",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl-probe.rs",
"sha256": "a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shl.txt"
]
},
{
"path": "reference/model-evidence/u64-shl.txt",
"sha256": "e4cacfd29333a91c1258524a520e849325a85a05cf50b0065ffbf91d7977f69c",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shr-probe.rs",
"sha256": "11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee",
"cited_by": [
"Tablet/ModelU64Shr.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/u64-shr.txt",
"sha256": "c0295af2452a4748bc1a642580414acfc76285ba87b6203b6cbff7ff9924b6ad",
"cited_by": [
"Tablet/ModelU64Shr.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
}
]core::option::{impl core::ops::try_trait::Try for core::option::Option<T>}::branch
Inspect related source (1)
- branch · core/src/option.rs:2779 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::option::{impl core::ops::try_trait::Try for core::option::Option<T>}::branch |
|---|---|
| Recorded source | /rustc/library/core/src/option.rs |
| Lines | 2779:4–2779:64 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
{T : Type} : Option T → Result (core.ops.control_flow.ControlFlow (Option core.convert.Infallible) T)Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelOptionBranch]
def ModelOptionBranch {T : Type} (x : Option T) :
Result (core.ops.control_flow.ControlFlow
(Option core.convert.Infallible) T) :=
-- BODY
match x with
| some v => ok (.Continue v)
| none => ok (.Break none)
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelOptionBranch · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:78b79b33c07a37aeb7f1d66ca8cfd9dbbe45f2c2a4559ba102f473fa3df7d103 |
| Preservation current fingerprint | preservation-v1:78b79b33c07a37aeb7f1d66ca8cfd9dbbe45f2c2a4559ba102f473fa3df7d103 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","lean_semantic_closure":"a30d1280b20ea5a49f1544af33a49ddeead48555dbbbc00b6bdf09c6f463add2","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","lean_semantic_closure":"a30d1280b20ea5a49f1544af33a49ddeead48555dbbbc00b6bdf09c6f463add2","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "0cc05b1be6bad053dafb00ab9165583a995ba491666d66138947039af9c5a8b3",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:78b79b33c07a37aeb7f1d66ca8cfd9dbbe45f2c2a4559ba102f473fa3df7d103"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.option.Option.Insts.CoreOpsTry_traitTry.branch",
"extracted_signature": "{T : Type} : Option T → Result (core.ops.control_flow.ControlFlow (Option core.convert.Infallible) T)",
"rust_symbol": "core::option::{impl core::ops::try_trait::Try for core::option::Option<T>}::branch",
"raw_declaration_sha256": "0bf9b9d904111c7989cfc386f7bf22bbc7b1b9fd128306025fc6fe3916ef2bcf",
"node": "ModelOptionBranch",
"declaration": "dec2flt_model.ModelOptionBranch"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelOptionBranch.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::option::{impl core::ops::try_trait::FromResidual<core::option::Option<core::convert::Infallible>> for core::option::Option<T>}::from_residual
Inspect related source (1)
- from_residual · core/src/option.rs:2793 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::option::{impl core::ops::try_trait::FromResidual<core::option::Option<core::convert::Infallible>> for core::option::Option<T>}::from_residual |
|---|---|
| Recorded source | /rustc/library/core/src/option.rs |
| Lines | 2793:4–2793:67 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
(T : Type) : Option core.convert.Infallible → Result (Option T)Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelOptionFromResidual]
def ModelOptionFromResidual (T : Type)
(x : Option core.convert.Infallible) : Result (Option T) :=
-- BODY
match x with
| none => ok none
| some v => nomatch v
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelOptionFromResidual · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:b6303ca22ec7cbbd5ff72e80e13dbd291be983a507fd8b919438616b33c79ffc |
| Preservation current fingerprint | preservation-v1:b6303ca22ec7cbbd5ff72e80e13dbd291be983a507fd8b919438616b33c79ffc |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","lean_semantic_closure":"a92cc17aaf6bc78d97354592f0cdef183839d0e8d53ae8111bc07a81d1baa8c7","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","lean_semantic_closure":"a92cc17aaf6bc78d97354592f0cdef183839d0e8d53ae8111bc07a81d1baa8c7","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "a54e31e0c21a6e2bbeae25e3bcaae2bcdd6923480d85b21c203296fbec7205d2",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:b6303ca22ec7cbbd5ff72e80e13dbd291be983a507fd8b919438616b33c79ffc"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual",
"extracted_signature": "(T : Type) : Option core.convert.Infallible → Result (Option T)",
"rust_symbol": "core::option::{impl core::ops::try_trait::FromResidual<core::option::Option<core::convert::Infallible>> for core::option::Option<T>}::from_residual",
"raw_declaration_sha256": "4c10afcd703d980e458ca8e8ce2ecf1d0c415721467b76953e9223648ea5106c",
"node": "ModelOptionFromResidual",
"declaration": "dec2flt_model.ModelOptionFromResidual"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelOptionFromResidual.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]core::slice::{[T]}::first
Inspect related source (1)
- first · core/src/slice/mod.rs:155 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::slice::{[T]}::first |
|---|---|
| Recorded source | /rustc/library/core/src/slice/mod.rs |
| Lines | 155:4–155:43 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
{T : Type} : Slice T → Result (Option T)Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelSliceFirst]
def ModelSliceFirst {T : Type} (s : Slice T) : Result (Option T) :=
-- BODY
ok s.val.head?
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Slice Std.U8 satisfying
SourceValidByteSlice and representing a configured Rust
&[u8], this binding returns normally with ok none for the
empty slice and otherwise with ok (some x), where x is the
same first byte returned by the source's shared reference.
It leaves the complete ordered input unchanged and requires no UTF-8,
lexical-validity, A/B, or termination premise.Proof
[], the Rust body and ModelSliceFirst both return
None; on x :: xs, both return the identical head, by shared
reference in Rust and as the immutable value x in Aeneas.
Both cases return normally, do not change the input, and inspect no length
or content condition beyond the empty/head distinction.first call is
generated.lean:4568, in dec2flt_with_trace, immediately
after as_bytes at 4567;
its source counterpart is crate/dec2flt/mod.rs:365.
Here T = Std.U8 and the head is copied to test + and
-; no reference identity, lifetime, or mutation is observed.
The fixed dispatcher frame of DispatchFrame retains this
same first-byte operation
even with abstract helper components, as recorded in the current evidence.
On a Rust string, the complete UTF-8 bytes satisfy the slice length predicate
of SourceValidByteSlice; on arbitrary source-valid helper slices
the primitive claim needs no UTF-8 condition.
If a leading sign is consumed, the nonempty case justifies taking the tail,
whose length is no greater than the original slice's. The original complete
string length is not replaced by this shortened length in any GOAL premise.upstream/dec2flt/parse.rs:86 uses first in the scientific
digit-entry test. Its audited replacement at
crate/dec2flt/parse.rs:134-137 first tests nonemptiness and then
reads index zero for is_ascii_digit.
On an empty post-exponent-sign slice both tests are false and read no byte;
on x :: xs both test the same x. Index zero is in bounds
because 0<1+|\mathit{xs}|.
The current extraction at 1747-1753 therefore implements that
upstream first observation without calling this bound external.
The distinction also applies transitively through parse_number
and through the slow-to-decimal-to-scientific path recorded in the evidence.
This binding does not implement or remove their indexed tests; the already
audited adaptation remains fixed.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
i64/u64 input and
has no first callee. Its on-normal alternatives are unaffected.Requirement: native correct or defer
Decimal, including the
disguised path, and has no first callee. Its on-normal contract is unchanged.Requirement: number helper acceptance
Some.Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
None remain unchanged, including malformed
tails after exponent updates stop.Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Ok without panic remains required, not presumed.Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
None.Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelSliceFirst · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T1_PrimitiveApplicability.txt
Current first/split_first/as_bytes applicability
==============================================
This is CURRENT primary source/extraction inspection, not a parser execution
or a GOAL verdict. It was independently checked in request 99, task 10, from
/home/leanagent/math/dec2flt-r0003-runtime/dispatch/10/repo.
The prior task-8 candidate was accepted=false and is only advisory. All commands
in the fresh inspection transcript below exited 0; their unmodified outputs
are recorded separately from the historical predecessor records.
The predecessor records aeneas-slice-observations.txt and
aeneas-string-bytes.txt retain their original 45b5027c... extraction identity;
their old call locations are not used as current inventory.
1. Identities and unchanged library meanings
-------------------------------------------
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Raw output:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw output:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Raw output (path suffixes abbreviated only here):
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
These are the same executable/library/core-source identities as the historical
records. Slice.lean:22 still defines
def Slice (a : Type u) := { l : List a // l.length <= Usize.max }
(ASCII rendering of the Lean alpha and inequality). String.lean:6 defines
def Str := Slice U8
The overview:240 says shared borrows (&T) become plain T parameters, which may
be copied; its table:432 describes them as immutable. The actual pinned core
bodies (sed -n '155,157p' .../core/src/slice/mod.rs,
sed -n '198,200p' .../core/src/slice/mod.rs, and
sed -n '498,501p' .../core/src/str/mod.rs) are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
No primitive body or representation change is being introduced.
These are read-only inspections with no compiler invocation, new build setting
or extraction invocation. The audited manifest, toolchain, target and extraction
configuration remain fixed. The full paths and exact Unicode representations
are retained in the fresh inspection transcript below. The separate
source-valid-byte-slice.txt record supplies the target isize::MAX bound and
Rust str's UTF-8 condition; a general &[u8] does not require UTF-8.
2. Exact current externals and support reconciliation
----------------------------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
Result: declaration_count=24; full inventory retained at
.trellis/scratch/inspect-native-1791579714814493776.json
The three entries selected by their exact names have the following unchanged
signatures, Rust symbols and raw declaration SHA256 values. Unicode below is
retained to copy the exact inventory signatures.
name: core.slice.Slice.first
extracted_signature: {T : Type} : Slice T → Result (Option T)
rust_symbol: core::slice::{[T]}::first
raw_declaration_sha256: 221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105
name: core.slice.Slice.split_first
extracted_signature: {T : Type} : Slice T → Result (Option (T × (Slice T)))
rust_symbol: core::slice::{[T]}::split_first
raw_declaration_sha256: f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49
name: core.str.Str.as_bytes
extracted_signature: : Str → Result (Slice Std.U8)
rust_symbol: core::str::{str}::as_bytes
raw_declaration_sha256: 11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The corresponding complete raw declaration text is generated.lean:311-316,
318-324 and 326-331, respectively (sed -n for each range):
/-- [core::slice::{[T]}::first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43
Name pattern: [core::slice::{[@T]}::first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::first"]
axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
/-- [core::slice::{[T]}::split_first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57
Name pattern: [core::slice::{[@T]}::split_first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::split_first"]
axiom core.slice.Slice.split_first
{T : Type} : Slice T → Result (Option (T × (Slice T)))
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
Recomputing each declaration digest, including its final newline:
sed -n '311,316p' generated.lean | sha256sum
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
sed -n '318,324p' generated.lean | sha256sum
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
sed -n '326,331p' generated.lean | sha256sum
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
jq '.bindings[] | select(.node == "ModelSliceFirst" or .node == "ModelSliceSplitFirst" or .node == "ModelStrAsBytes")' Tablet/model-support.json
Each binding copies precisely the name, extracted_signature, rust_symbol and
raw_declaration_sha256 above. Its node/declaration pair is, respectively:
ModelSliceFirst / dec2flt_model.ModelSliceFirst
ModelSliceSplitFirst / dec2flt_model.ModelSliceSplitFirst
ModelStrAsBytes / dec2flt_model.ModelStrAsBytes
This reconciles the full raw declarations, not merely the identifier spelling.
In the current composed Preamble.lean:212,219,226 the externals are typed
references to exactly these principal definitions. Their bodies are, in order,
ok s.val.head?, empty/head-tail list matching (tail bound from s.property),
and ok s. No external axiom for these operations remains in the composition.
3. Complete current bound-call inventory
---------------------------------------
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Complete raw output:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Rust call / current extracted function and input:
crate/dec2flt/parse.rs:127 / parse_scientific:1732-1765, s_ref : Slice Std.U8
crate/dec2flt/parse.rs:65 / try_parse_19digits_loop.body:4087-4110, s : Slice Std.U8
crate/dec2flt/parse.rs:180 / parse_partial_number:4337-4364, s1 : Slice Std.U8
crate/dec2flt/parse.rs:197 / parse_partial_number:4369, s2 : Slice Std.U8
crate/dec2flt/mod.rs:364 / dec2flt_with_trace:4567, s : Str
crate/dec2flt/mod.rs:365 / dec2flt_with_trace:4568, body : Slice Std.U8
The s1 argument is returned by try_parse_digits; s2 is s1 or the returned
Std.U8 suffix after fractional scanning. Every bound slice call infers
T=Std.U8. Returned heads are copied/read, and tails are immutable next slices;
none of these calls observes pointer identity or mutates the returned borrow.
The dispatcher strips at most one leading sign after as_bytes and first.
The authored fixed frame mirrors these same two initial operations at
Tablet/P9_T1_DispatchFrame.lean:15-16. It uses the same bound as_bytes and
first definitions even with abstract helper components; it has no split_first
call of its own. These are authored frame uses, not additional call sites in
the raw generated module enumerated above.
4. Original observations versus audited indexed replacements
------------------------------------------------------------
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Complete raw output:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
The output ordering is the recorded rg ordering, not program evaluation order.
The original scientific digit-entry test at upstream/dec2flt/parse.rs:86
uses first(). Its audited replacement at crate/dec2flt/parse.rs:134-137 is:
// `matches!` with a guarded slice pattern triggers an Aeneas internal
// error. This short-circuit test reads the same first byte exactly when
// it exists and therefore preserves both acceptance and evaluation order.
if !s.is_empty() && s[0].is_ascii_digit() {
For [] both tests are false without a byte read; for x::xs both test the
identical x for is_ascii_digit. Therefore this original first observation
still exists semantically, but is not a call to the bound first external.
The extraction:1747-1753 uses is_empty, then index_usize 0, then the digit test.
Likewise original decimal-sequence split observations at upstream lines
244,250,255,291 become guarded indexing in crate lines 296,302,309,348-363;
the leading-dot/zero adjustment at upstream parse.rs:156 becomes
adjust_many_digit_count:86-99. Original common.rs:39-52 scans by split_first
and consumes a digit only when c.wrapping_sub(b'0')<10; the specialized
indexed scans retain that order and first-nondigit stop. These adaptations
are distinct from the four bound split calls. Their audited source comments
and Preamble preservation remain separate obligations, not claims proved by
absence from the external inventory.
5. Slow scientific path, residual and outer outcomes
---------------------------------------------------
The source call chain is crate/dec2flt/slow.rs:40 ->
crate/dec2flt/decimal_seq.rs:362-363 -> crate/dec2flt/parse.rs:127.
The extracted chain starts at generated.lean:3941:
let d <- num.imp.dec2flt.decimal_seq.parse_decimal_seq s
and reaches parse_scientific exponent_suffix in all eight e/E branches:
2084/2094, 2156/2166, 2224/2234, 2281/2292. The <- here is ASCII rendering;
the raw extraction uses Lean's left arrow. Inspect each branch with sed -n;
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
shows each call immediately followed by
ok (core.option.Option.unwrap_or o 0#i64)
The scientific call itself reaches the bound split_first at 1734. The
numeric parser also calls this same scientific function at 4412 and 4459,
but observes its returned residual in its consumed-length calculation;
crate/dec2flt/parse.rs:234-240 requires rest == s.len() for Some.
The source at crate/dec2flt/decimal_seq.rs:350-366 reads:
if ch == b'e' || ch == b'E' {
// [preservation comments at 351-361, retained in the pinned file]
let mut exponent_suffix = &s[1..];
explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
Counts have been saved before this call. The residual mutation is unobserved
only after the scientific call returns; the call is not elided. Original
upstream/dec2flt/decimal_seq.rs:291-295 likewise calls parse_scientific then
unwrap_or. The later generated.lean:3942 test for d.num_digits=0 is after
the bind at 3941, so zero-significand inputs do not bypass scientific parsing.
The unsigned numeric literal 1e-2 passes -2 as the exponent suffix, despite
having no leading sign. This is source inspection, not a newly run test.
The exact loop body at generated.lean:1692-1716 / crate/dec2flt/parse.rs:145-151
tests count<len and the byte's wrapping-sub digit predicate, updates E only
when E<2^59, then increments count regardless of whether E was updated.
The sign is taken from the scientific suffix (1735-1746), not the leading
literal sign. The residual is the slice starting at count (1758-1761).
With 0<=E<2^59 and 0<=digit<=9, an update is at most
10*2^59-1=5764607523034234879<i64::MAX. One update can overshoot 2^59;
this is not a clamp. Later exponent digits are still consumed, including
arbitrarily many zeroes/digits within a source-valid slice; the first nondigit
and everything after it remain in the residual. Empty/sign-only/nondigit
suffixes normally produce None with the exact post-sign residual.
The monadic distinction is independently checkable in the unchanged Aeneas
library. Commands:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Raw output (path suffixes abbreviated):
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 Aeneas/Std/Core/Core.lean
Primitives.lean:62-66 has Result.ok, Result.fail and Result.div. Its
117-121 bind is:
match x with
| ok v => f v
| fail v => fail v
| div => div
Core/Core.lean:100-104 unwrap_or takes an Option T, not a Result:
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Thus normal None becomes zero after the call; failure/divergence skips that
continuation and propagates outward. No Option Try/residual conversion is
used for the slow None-to-zero behavior. Equal head/tail observations preserve
this distinction without assuming termination or rounding of the slow helper.
Applicability conclusion
------------------------
The unchanged list representations, core bodies, exact declarations and
bindings justify reuse of the predecessor's immutable head/tail and byte-list
arguments, with this current inventory instead of predecessor call locations.
Primitive equivalence is extensional on every source-valid byte slice/string,
not conditioned on lexical acceptance, native/slow rounding, component package
inhabitability, A/B length bounds, or public reachability. A/B are used only
where the individual original GOAL requires them, and public bounds concern
the complete string before optional sign removal. The direct slow application
retains every source-valid unsigned numeric literal, with its independently
signed exponent and full significand, and is only on normal return. This
evidence supplies neither a GOAL proof nor a new model assumption.
Fresh request-99 inspection transcript
--------------------------------------
Each stdout block below is exact, without path abbreviations or ASCII
substitutions. Unicode occurs only where it is part of the inspected source or
inventory. Command exit status is reported separately.
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Exit status: 0
Raw stdout:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Exit status: 0
Raw stdout:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Command:
sed -n '311,316p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
Command:
sed -n '318,324p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
Command:
sed -n '326,331p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Exit status: 0
Raw stdout:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Exit status: 0
Raw stdout:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Command:
jq '.declarations[] | select(.name == "core.slice.Slice.first" or .name == "core.slice.Slice.split_first" or .name == "core.str.Str.as_bytes")' .trellis/scratch/inspect-native-1791579714814493776.json
Exit status: 0
Raw stdout:
{
"name": "core.slice.Slice.first",
"extracted_signature": "{T : Type} : Slice T → Result (Option T)",
"rust_symbol": "core::slice::{[T]}::first",
"raw_declaration_sha256": "221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105",
"source_utf8": "/-- [core::slice::{[T]}::first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43\n Name pattern: [core::slice::{[@T]}::first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::first\"]\naxiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)\n"
}
{
"name": "core.slice.Slice.split_first",
"extracted_signature": "{T : Type} : Slice T → Result (Option (T × (Slice T)))",
"rust_symbol": "core::slice::{[T]}::split_first",
"raw_declaration_sha256": "f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49",
"source_utf8": "/-- [core::slice::{[T]}::split_first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57\n Name pattern: [core::slice::{[@T]}::split_first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::split_first\"]\naxiom core.slice.Slice.split_first\n {T : Type} : Slice T → Result (Option (T × (Slice T)))\n"
}
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"source_utf8": "/-- [core::str::{str}::as_bytes]:\n Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41\n Name pattern: [core::str::{str}::as_bytes]\n Visibility: public -/\n@[rust_fun \"core::str::{str}::as_bytes\"]\naxiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)\n"
}
Command:
sed -n '155,157p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
Command:
sed -n '198,200p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Command:
sed -n '498,501p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
Command:
sed -n '18,24p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
Exit status: 0
Raw stdout:
/-!
# Slice
-/
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
/-- We need this to coerce slices to lists without marking `Slice` as reducible.
Command:
sed -n '1,9p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Exit status: 0
Raw stdout:
import Aeneas.Std.Scalar
import Aeneas.Std.Slice
namespace Aeneas.Std
def Str := Slice U8
instance : DecidableEq Str := inferInstanceAs (DecidableEq (Slice U8))
Command:
sed -n '237,244p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
- **Mutable reference parameters** become plain value parameters.
- **Returned mutable borrows** produce a tuple of (value, backward continuation).
- **Shared borrows (`&T`)** become plain `T` parameters (the value may be copied).
- **Pattern matching** maps directly to `match` in Lean.
- **Recursive functions** become Lean recursive functions (may require termination proofs).
- **Traits** are translated to Lean type classes.
Command:
sed -n '428,434p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
| Rust Concept | Lean Translation |
|--------------------------|--------------------------------------------------------------|
| `&mut T` parameter | `T` parameter (passed by value) |
| Returning `&'a mut T` | Returns `Result (T × (T → ...))` with backward continuation |
| `&T` (shared borrow) | `T` parameter (immutable, may be copied) |
| `panic!()` | `fail` in the `Result` monad |
| Integer overflow | `fail` (all arithmetic is checked) |
Command:
sed -n '60,67p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
open Error
inductive Result (α : Type u) where
| ok (v: α): Result α
| fail (e: Error): Result α
| div
deriving Repr, BEq
Command:
sed -n '115,122p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
-/
def bind {α : Type u} {β : Type v} (x: Result α) (f: α → Result β) : Result β :=
match x with
| ok v => f v
| fail v => fail v
| div => div
Command:
sed -n '97,105p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
unwrap x ⦃ v => x = some v ⦄ := by
simp only [unwrap, ofOption]; grind
@[step_pure_def, rust_fun "core::option::{core::option::Option<@T>}::unwrap_or" -canFail]
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Command:
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
Exit status: 0
Raw stdout:
2084: let (o, _) ← num.imp.dec2flt.parse.parse_scientific exponent_suffix
2085- ok (core.option.Option.unwrap_or o 0#i64)
--
2093: let (o, _) ←
2094: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2095- ok (core.option.Option.unwrap_or o 0#i64)
--
2155: let (o, _) ←
2156: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2157- ok (core.option.Option.unwrap_or o 0#i64)
--
2165: let (o, _) ←
2166: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2167- ok (core.option.Option.unwrap_or o 0#i64)
--
2223: let (o, _) ←
2224: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2225- ok (core.option.Option.unwrap_or o 0#i64)
--
2233: let (o, _) ←
2234: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2235- ok (core.option.Option.unwrap_or o 0#i64)
--
2280: let (o, _) ←
2281: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2282- ok (core.option.Option.unwrap_or o 0#i64)
--
2291: let (o, _) ←
2292: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2293- ok (core.option.Option.unwrap_or o 0#i64)
Command:
sed -n '27,46p' crate/dec2flt/slow.rs
Exit status: 0
Raw stdout:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
Command:
sed -n '244,260p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
s = s.parse_digits(|digit| d.try_add_digit(digit));
if let Some((b'.', s_next)) = s.split_first() {
s = s_next;
let first = s;
// Skip leading zeros.
if d.num_digits == 0 {
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
}
while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
let v = s.read_u64();
Command:
sed -n '287,300p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
}
}
let mut explicit = 0;
if let Some((&ch, s_next)) = s.split_first() {
if ch == b'e' || ch == b'E' {
s = s_next;
explicit = parse_scientific(&mut s).unwrap_or(0);
}
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
d.digits[i] = 0;
Command:
sed -n '39,52p' upstream/dec2flt/common.rs
Exit status: 0
Raw stdout:
fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
let mut s = self;
while let Some((c, rest)) = s.split_first() {
let c = c.wrapping_sub(b'0');
if c < 10 {
func(c);
s = rest;
} else {
break;
}
}
s
reference/model-evidence/aeneas-slice-observations.txt
Aeneas slice-observation evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout and executable used for the frozen extraction are:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328
At that commit, Aeneas/Std/Slice.lean:22 defines:
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
Thus an Aeneas Slice is an ordered List subtype. Its val field is the complete
ordered element list; the subtype property is the Usize.max length bound.
sha256sum /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7
At that commit, aeneas-overview.md:240 states the translation convention that
shared borrows (&T) become plain T parameters and that the value may be copied.
The summary table at line 432 additionally describes the resulting value as
immutable. Returned shared byte references therefore have no mutable backward
continuation or separately observable identity in the generated model.
The Rust source is the configured nightly-2026-06-01 core library:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
Its exact observation bodies at core/src/slice/mod.rs:155-156 and 198-199 are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
These bodies and the same core source hash are also pinned in
reference/model-evidence/binary64-boundary.txt. The complete configured Rust
&[u8] domain, including the isize::MAX byte-length condition, is independently
pinned in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module has this identity:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Its external signatures at generated.lean:316 and 323-324 are:
axiom core.slice.Slice.first {T : Type} :
Slice T → Result (Option T)
axiom core.slice.Slice.split_first {T : Type} :
Slice T → Result (Option (T × Slice T))
The following command enumerates every declaration or call occurrence:
rg -n 'core\.slice\.Slice\.(first|split_first)' generated.lean
Raw result:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
4290: let o ← core.slice.Slice.split_first s_ref
4338: let o ← core.slice.Slice.split_first s
4591: let o ← core.slice.Slice.split_first s1
4613: let o1 ← core.slice.Slice.split_first s2
4812: let o ← core.slice.Slice.first body
All five calls infer T = Std.U8:
* generated.lean:4288-4290 declares parse_scientific with
s_ref : Slice Std.U8 and calls split_first on s_ref.
* generated.lean:4332-4338 declares try_parse_19digits_loop.body with
s : Slice Std.U8 and calls split_first on s.
* generated.lean:4582-4591 declares parse_partial_number with
s : Slice Std.U8; try_parse_digits returns s1 : Slice Std.U8, which is the
first split_first argument.
* In the same parse_partial_number definition, every branch defining s2 returns
either s1 or the Std.U8 tail s_next. Hence the call on s2 at line 4613 also
has T = Std.U8.
* generated.lean:4803-4812 declares dec2flt_with_trace; body is returned by
core.str.Str.as_bytes, whose signature at line 330 is
Str → Result (Slice Std.U8), and first is called on body.
The adapted sources containing the corresponding calls are pinned by:
sha256sum crate/dec2flt/parse.rs crate/dec2flt/mod.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f crate/dec2flt/parse.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
The five exact Rust call sites are:
crate/dec2flt/parse.rs:65
if let Some((c, s_next)) = s.split_first() {
let digit = c.wrapping_sub(b'0');
...
s = s_next;
crate/dec2flt/parse.rs:127
if let Some((&c, s_next)) = s.split_first() {
negative = c == b'-';
if c == b'-' || c == b'+' { s = s_next; }
crate/dec2flt/parse.rs:177
if let Some((&b'.', s_next)) = s.split_first() {
s = s_next;
crate/dec2flt/parse.rs:194
if let Some((&c, s_next)) = s.split_first() {
if c == b'e' || c == b'E' { s = s_next; ... }
crate/dec2flt/mod.rs:365
let Some(&c) = body.first() else { ... };
Thus every call is on &[u8]. The call sites either destructure the shared byte
reference into a copied byte or invoke an immutable u8 method through it, and
they use the shared tail only as the next immutable slice. There is no mutation
through a returned reference and no pointer or lifetime identity observation.
Consequently, at every frozen GOAL-facing call site, erasing the
shared-reference lifetime/aliasing data retains the observed U8 value and, for
split_first, the same ordered suffix.
reference/model-evidence/aeneas-string-bytes.txt
Aeneas string/as_bytes evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout used for the frozen extraction is pinned by:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
The configured executable and its identity are pinned by:
jq -r '.effective_tools.aeneas' modeling-input/manifest.json
/home/leanagent/pv_spike/tools/aeneas/bin/aeneas
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
The Aeneas string definition at that commit is pinned by:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Its exact definition at Aeneas/Std/String.lean:6 is:
def Str := Slice U8
Thus Aeneas Str itself has only the Aeneas Slice U8 constraints; it does not by
itself impose Rust str's UTF-8 validity or isize::MAX byte-length restriction.
The ordered-list representation of Aeneas Slice, including its Usize.max bound,
is pinned separately in reference/model-evidence/aeneas-slice-observations.txt.
The configured Rust str validity and isize::MAX byte-length conditions are
pinned separately in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module and its string external are pinned by:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
The raw declaration at generated.lean:326-331 is:
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
The inspect-native raw declaration digest recorded in the support binding is:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The command
rg -n 'core\.str\.Str\.as_bytes' generated.lean
has the complete raw result:
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
4811: let body ← core.str.Str.as_bytes s
Consequently the only call in the frozen generated module is the first
operation in num.imp.dec2flt.dec2flt_with_trace, whose parameter and call at
generated.lean:4807-4811 are:
(coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
Result ((core.result.Result F num.float_parse.ParseFloatError) ×
(num.imp.dec2flt.Dec2FltTrace F))
:= do
let body ← core.str.Str.as_bytes s
The support manifest itself is pinned by:
sha256sum Tablet/model-support.json
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
Its exact binding at Tablet/model-support.json:183-190 is:
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"node": "ModelStrAsBytes",
"declaration": "dec2flt_model.ModelStrAsBytes"
}
The configured Rust core implementation is pinned by:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Its exact same-layout body at core/src/str/mod.rs:498-501 is:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
The frozen adapted dispatcher source and its sole source call are pinned by:
sha256sum crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
rg -n 'as_bytes' crate
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:362-365
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
The core body returns a shared byte slice by same-layout transmutation: it does
not change, reorder, add, or remove bytes and has no failure branch. The Aeneas
shared-borrow convention and the later immutable ordered-byte observations are
pinned in reference/model-evidence/aeneas-slice-observations.txt.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:aedbbbd4a7880b1356e415074ee4bd3935090ad3bbe1ef542efe4966b1047b47 |
| Preservation current fingerprint | preservation-v1:aedbbbd4a7880b1356e415074ee4bd3935090ad3bbe1ef542efe4966b1047b47 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"daa1d788720f27eca31e722db51d2d3e6e80bb4fb62e35d6bc6d9686e17ab381","lean_semantic_closure":"c02db9c8475e537013729680a2bfb86330285c45f141bc1a8a5f7fd0490e03d1","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"daa1d788720f27eca31e722db51d2d3e6e80bb4fb62e35d6bc6d9686e17ab381","lean_semantic_closure":"c02db9c8475e537013729680a2bfb86330285c45f141bc1a8a5f7fd0490e03d1","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "c739eeba81564a0d5f027687f674ce712a49d34f33aab4b51fb820e937227542",
"dep_statement_hashes": {
"P9_T1_DispatchFrame": "9c8534245e042036f0736480d142a007a6fd6a417572dd00c6c15eb95f8e0c98",
"SourceValidByteSlice": "52522ae5b8602c6279dde2af31f94e21db249400641f5d3e951f68a74c3c11e2"
},
"combined_sound_fp": "preservation-v1:aedbbbd4a7880b1356e415074ee4bd3935090ad3bbe1ef542efe4966b1047b47"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.slice.Slice.first",
"extracted_signature": "{T : Type} : Slice T → Result (Option T)",
"rust_symbol": "core::slice::{[T]}::first",
"raw_declaration_sha256": "221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105",
"node": "ModelSliceFirst",
"declaration": "dec2flt_model.ModelSliceFirst"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"sha256": "c525bf0a597763fba686f2fce551b436a16d406f2e10942a23665eadc676988b",
"cited_by": [
"Tablet/ModelSliceFirst.tex",
"Tablet/model-support.json",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/aeneas-slice-observations.txt",
"sha256": "566b151c7c5eee54bbc634b117f85b80c8adf7a0ba4362759a076caca6c61c38",
"cited_by": [
"Tablet/ModelSliceFirst.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/aeneas-string-bytes.txt",
"sha256": "132e19fa71c736d030b3e5cb788cf2bb1e99c60742ac19ad6860855f7ced21b6",
"cited_by": [
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/aeneas-slice-observations.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"Tablet/ModelSliceFirst.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
}
]core::slice::{[T]}::split_first
Inspect related source (1)
- split_first · core/src/slice/mod.rs:198 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::slice::{[T]}::split_first |
|---|---|
| Recorded source | /rustc/library/core/src/slice/mod.rs |
| Lines | 198:4–198:57 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
{T : Type} : Slice T → Result (Option (T × (Slice T)))Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelSliceSplitFirst]
def ModelSliceSplitFirst {T : Type}
(s : Slice T) : Result (Option (T × Slice T)) :=
-- BODY
match h : s.val with
| [] => ok none
| x :: xs => ok (some (x, ⟨xs, by
have p := s.property
rw [h] at p
have p' : 1 + xs.length ≤ Usize.max := by
simpa [Nat.add_comm] using p
exact Nat.le_trans (Nat.le_add_left xs.length 1) p'⟩))
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Slice Std.U8 satisfying
SourceValidByteSlice and representing a configured Rust
&[u8], this binding returns normally with ok none exactly
for the empty slice, and otherwise with ok (some (x, xs)).
Here x is the source's first byte and xs its complete ordered
tail, which again satisfies SourceValidByteSlice.
There is no UTF-8, lexical-validity, A/B, or public-reachability premise.
The binding preserves the immutable head/tail observation at every current
bound call, including scientific parsing reached through the slow helper.Proof
None on the empty slice and shared
references to precisely the head and tail on a nonempty slice.
Aeneas represents slices as complete ordered lists with a
\mathtt{Usize.max} length proof and immutable shared borrows as values.
Thus ModelSliceSplitFirst's two list cases give the identical option,
byte and suffix, with normal return and no memory change.x :: xs, the Lean tail constructor is legal because
|\mathit{xs}|\leq 1+|\mathit{xs}|=|\mathit{x::xs}|
\leq\mathtt{Usize.max}.
The source-domain hypothesis also gives
|\mathit{xs}|\leq|\mathit{x::xs}|\leq\mathtt{isize::MAX}, so that tail is
source-valid. Every current bound call infers T = Std.U8.
The calls copy/read the head and use the tail as another immutable slice;
none observes reference identity or mutates either returned borrow.
The four calls are scientific sign inspection at generated.lean:1734,
nineteen-digit scanning at 4094, and point/exponent-marker inspection
at 4347,4369, with source counterparts
crate/dec2flt/parse.rs:127,65,180,197.
Original upstream split observations rewritten to guarded indexing are
identified separately in the current evidence, not counted as bound calls.parse_scientific, the exact head sets negative precisely
when it is -; + or - consumes exactly the returned
tail, while any other head retains the original slice. Empty input retains
the empty slice and a false flag. This is the exponent's independent sign,
not a leading significand sign. The unchanged guarded digit-entry test reads
that same post-sign first byte only when it exists. The original
upstream/dec2flt/parse.rs:86 uses first; the audited
crate/dec2flt/parse.rs:134-137 uses nonemptiness then index zero.
Their empty and nonempty observations agree, but neither is an additional
current bound first call.i64), the source updates E to 10E+d only when the
pre-update E<T. Starting from zero, 0\leq E\leq10T-1 is maintained:
an updating state has E\leq T-1 and 0\leq d\leq9, so
10E+d\leq10T-1=5764607523034234879<\mathtt{i64::MAX}; otherwise E is
unchanged. The product, byte-to-i64 cast and sum fit, and negating
this final nonnegative magnitude fits as well.
One update may overshoot T; there is no clamp to T.
The count is incremented for every exponent digit even after updates
stop. At an increment, \mathit{count}<|s| implies
\mathit{count}+1\leq|s|\leq\mathtt{isize::MAX}<\mathtt{Usize.max}.
Guarded indexing and the final suffix starting at count are therefore in
bounds. The same maximal digit prefix is consumed, and the same first
nondigit and all later bytes remain in the residual. A normally returned
Some has the same signed accumulator and exact residual; a missing
digit, including an empty or sign-only suffix, normally gives None
and the same post-sign residual. No lexical acceptance or rounding result
is used in this argument.parse_long_mantissa:3941 to parse_decimal_seq,
whose eight e/E branches at
2084/2094,2156/2166,2224/2234,2281/2292 call this scientific parser,
and hence split-first at 1734.
Each exponent suffix is an ordered suffix of the original source-valid
slice; the claim applies without any A/B or dispatcher-reachability bound.
The slow caller ignores the residual only after the call and applies
unwrap_or(0) only to the normally returned option:
Some e contributes e, while normal None contributes zero.
As pinned in the current evidence, Result.bind propagates
fail and div; neither becomes zero, a normal None,
or a Rust parsing error. This is unwrap_or, not Option
Try/residual conversion. The later zero-significand test at 3942
cannot bypass the earlier scientific call.parse_number, parse_long_mantissa, or dispatch, and does
not assume an inhabited component package.
The following separate applications use only this extensional replacement.
Where the original GOAL imposes a bound, write
A=3458764513820540928 and B=576460752303421440 bytes;
public bounds concern the complete string before leading-sign removal.Authored arguments for individual requirements
Requirement: assembly correspondence
biased_fp_to_float subject takes a raw pair,
not a slice, and has no transitive bound split call in the current inventory.
Its required normal return and cast/shift/OR word equation are unaffected.Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
i64/u64 input and has no
split callee. Its on-normal deferral/rounding alternative is unchanged.Requirement: native correct or defer
Decimal, not a slice, and has no
split callee. Ordinary and disguised on-normal alternatives are unaffected.Requirement: number helper acceptance
Some is the GOAL's required conclusion, not a
premise of this preservation argument.Requirement: number helper accumulated value
many_digits
flag and represented value are unaltered; the exact/half-open interval laws
for the full significand remain to be established.Requirement: number helper record bounds
Requirement: number helper rejection
None, including with overflow checks, is not presumed.Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
None or the required normal signed-infinity result.Requirement: parser invalid rejection
Err without panic remains the conclusion.Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Ok
without panic is still required, not assumed.Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
None-to-zero occur only after the call;
outer failure/divergence propagates, even for a zero significand.
The complete significand and any normally returned raw pair are unchanged.
Only such normal results are the diagnostic's subjects; their accumulated-value
rounding is not assumed by primitive preservation.Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
None is not supplied by this binding.Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelSliceSplitFirst · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T1_PrimitiveApplicability.txt
Current first/split_first/as_bytes applicability
==============================================
This is CURRENT primary source/extraction inspection, not a parser execution
or a GOAL verdict. It was independently checked in request 99, task 10, from
/home/leanagent/math/dec2flt-r0003-runtime/dispatch/10/repo.
The prior task-8 candidate was accepted=false and is only advisory. All commands
in the fresh inspection transcript below exited 0; their unmodified outputs
are recorded separately from the historical predecessor records.
The predecessor records aeneas-slice-observations.txt and
aeneas-string-bytes.txt retain their original 45b5027c... extraction identity;
their old call locations are not used as current inventory.
1. Identities and unchanged library meanings
-------------------------------------------
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Raw output:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw output:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Raw output (path suffixes abbreviated only here):
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
These are the same executable/library/core-source identities as the historical
records. Slice.lean:22 still defines
def Slice (a : Type u) := { l : List a // l.length <= Usize.max }
(ASCII rendering of the Lean alpha and inequality). String.lean:6 defines
def Str := Slice U8
The overview:240 says shared borrows (&T) become plain T parameters, which may
be copied; its table:432 describes them as immutable. The actual pinned core
bodies (sed -n '155,157p' .../core/src/slice/mod.rs,
sed -n '198,200p' .../core/src/slice/mod.rs, and
sed -n '498,501p' .../core/src/str/mod.rs) are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
No primitive body or representation change is being introduced.
These are read-only inspections with no compiler invocation, new build setting
or extraction invocation. The audited manifest, toolchain, target and extraction
configuration remain fixed. The full paths and exact Unicode representations
are retained in the fresh inspection transcript below. The separate
source-valid-byte-slice.txt record supplies the target isize::MAX bound and
Rust str's UTF-8 condition; a general &[u8] does not require UTF-8.
2. Exact current externals and support reconciliation
----------------------------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
Result: declaration_count=24; full inventory retained at
.trellis/scratch/inspect-native-1791579714814493776.json
The three entries selected by their exact names have the following unchanged
signatures, Rust symbols and raw declaration SHA256 values. Unicode below is
retained to copy the exact inventory signatures.
name: core.slice.Slice.first
extracted_signature: {T : Type} : Slice T → Result (Option T)
rust_symbol: core::slice::{[T]}::first
raw_declaration_sha256: 221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105
name: core.slice.Slice.split_first
extracted_signature: {T : Type} : Slice T → Result (Option (T × (Slice T)))
rust_symbol: core::slice::{[T]}::split_first
raw_declaration_sha256: f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49
name: core.str.Str.as_bytes
extracted_signature: : Str → Result (Slice Std.U8)
rust_symbol: core::str::{str}::as_bytes
raw_declaration_sha256: 11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The corresponding complete raw declaration text is generated.lean:311-316,
318-324 and 326-331, respectively (sed -n for each range):
/-- [core::slice::{[T]}::first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43
Name pattern: [core::slice::{[@T]}::first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::first"]
axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
/-- [core::slice::{[T]}::split_first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57
Name pattern: [core::slice::{[@T]}::split_first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::split_first"]
axiom core.slice.Slice.split_first
{T : Type} : Slice T → Result (Option (T × (Slice T)))
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
Recomputing each declaration digest, including its final newline:
sed -n '311,316p' generated.lean | sha256sum
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
sed -n '318,324p' generated.lean | sha256sum
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
sed -n '326,331p' generated.lean | sha256sum
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
jq '.bindings[] | select(.node == "ModelSliceFirst" or .node == "ModelSliceSplitFirst" or .node == "ModelStrAsBytes")' Tablet/model-support.json
Each binding copies precisely the name, extracted_signature, rust_symbol and
raw_declaration_sha256 above. Its node/declaration pair is, respectively:
ModelSliceFirst / dec2flt_model.ModelSliceFirst
ModelSliceSplitFirst / dec2flt_model.ModelSliceSplitFirst
ModelStrAsBytes / dec2flt_model.ModelStrAsBytes
This reconciles the full raw declarations, not merely the identifier spelling.
In the current composed Preamble.lean:212,219,226 the externals are typed
references to exactly these principal definitions. Their bodies are, in order,
ok s.val.head?, empty/head-tail list matching (tail bound from s.property),
and ok s. No external axiom for these operations remains in the composition.
3. Complete current bound-call inventory
---------------------------------------
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Complete raw output:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Rust call / current extracted function and input:
crate/dec2flt/parse.rs:127 / parse_scientific:1732-1765, s_ref : Slice Std.U8
crate/dec2flt/parse.rs:65 / try_parse_19digits_loop.body:4087-4110, s : Slice Std.U8
crate/dec2flt/parse.rs:180 / parse_partial_number:4337-4364, s1 : Slice Std.U8
crate/dec2flt/parse.rs:197 / parse_partial_number:4369, s2 : Slice Std.U8
crate/dec2flt/mod.rs:364 / dec2flt_with_trace:4567, s : Str
crate/dec2flt/mod.rs:365 / dec2flt_with_trace:4568, body : Slice Std.U8
The s1 argument is returned by try_parse_digits; s2 is s1 or the returned
Std.U8 suffix after fractional scanning. Every bound slice call infers
T=Std.U8. Returned heads are copied/read, and tails are immutable next slices;
none of these calls observes pointer identity or mutates the returned borrow.
The dispatcher strips at most one leading sign after as_bytes and first.
The authored fixed frame mirrors these same two initial operations at
Tablet/P9_T1_DispatchFrame.lean:15-16. It uses the same bound as_bytes and
first definitions even with abstract helper components; it has no split_first
call of its own. These are authored frame uses, not additional call sites in
the raw generated module enumerated above.
4. Original observations versus audited indexed replacements
------------------------------------------------------------
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Complete raw output:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
The output ordering is the recorded rg ordering, not program evaluation order.
The original scientific digit-entry test at upstream/dec2flt/parse.rs:86
uses first(). Its audited replacement at crate/dec2flt/parse.rs:134-137 is:
// `matches!` with a guarded slice pattern triggers an Aeneas internal
// error. This short-circuit test reads the same first byte exactly when
// it exists and therefore preserves both acceptance and evaluation order.
if !s.is_empty() && s[0].is_ascii_digit() {
For [] both tests are false without a byte read; for x::xs both test the
identical x for is_ascii_digit. Therefore this original first observation
still exists semantically, but is not a call to the bound first external.
The extraction:1747-1753 uses is_empty, then index_usize 0, then the digit test.
Likewise original decimal-sequence split observations at upstream lines
244,250,255,291 become guarded indexing in crate lines 296,302,309,348-363;
the leading-dot/zero adjustment at upstream parse.rs:156 becomes
adjust_many_digit_count:86-99. Original common.rs:39-52 scans by split_first
and consumes a digit only when c.wrapping_sub(b'0')<10; the specialized
indexed scans retain that order and first-nondigit stop. These adaptations
are distinct from the four bound split calls. Their audited source comments
and Preamble preservation remain separate obligations, not claims proved by
absence from the external inventory.
5. Slow scientific path, residual and outer outcomes
---------------------------------------------------
The source call chain is crate/dec2flt/slow.rs:40 ->
crate/dec2flt/decimal_seq.rs:362-363 -> crate/dec2flt/parse.rs:127.
The extracted chain starts at generated.lean:3941:
let d <- num.imp.dec2flt.decimal_seq.parse_decimal_seq s
and reaches parse_scientific exponent_suffix in all eight e/E branches:
2084/2094, 2156/2166, 2224/2234, 2281/2292. The <- here is ASCII rendering;
the raw extraction uses Lean's left arrow. Inspect each branch with sed -n;
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
shows each call immediately followed by
ok (core.option.Option.unwrap_or o 0#i64)
The scientific call itself reaches the bound split_first at 1734. The
numeric parser also calls this same scientific function at 4412 and 4459,
but observes its returned residual in its consumed-length calculation;
crate/dec2flt/parse.rs:234-240 requires rest == s.len() for Some.
The source at crate/dec2flt/decimal_seq.rs:350-366 reads:
if ch == b'e' || ch == b'E' {
// [preservation comments at 351-361, retained in the pinned file]
let mut exponent_suffix = &s[1..];
explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
Counts have been saved before this call. The residual mutation is unobserved
only after the scientific call returns; the call is not elided. Original
upstream/dec2flt/decimal_seq.rs:291-295 likewise calls parse_scientific then
unwrap_or. The later generated.lean:3942 test for d.num_digits=0 is after
the bind at 3941, so zero-significand inputs do not bypass scientific parsing.
The unsigned numeric literal 1e-2 passes -2 as the exponent suffix, despite
having no leading sign. This is source inspection, not a newly run test.
The exact loop body at generated.lean:1692-1716 / crate/dec2flt/parse.rs:145-151
tests count<len and the byte's wrapping-sub digit predicate, updates E only
when E<2^59, then increments count regardless of whether E was updated.
The sign is taken from the scientific suffix (1735-1746), not the leading
literal sign. The residual is the slice starting at count (1758-1761).
With 0<=E<2^59 and 0<=digit<=9, an update is at most
10*2^59-1=5764607523034234879<i64::MAX. One update can overshoot 2^59;
this is not a clamp. Later exponent digits are still consumed, including
arbitrarily many zeroes/digits within a source-valid slice; the first nondigit
and everything after it remain in the residual. Empty/sign-only/nondigit
suffixes normally produce None with the exact post-sign residual.
The monadic distinction is independently checkable in the unchanged Aeneas
library. Commands:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Raw output (path suffixes abbreviated):
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 Aeneas/Std/Core/Core.lean
Primitives.lean:62-66 has Result.ok, Result.fail and Result.div. Its
117-121 bind is:
match x with
| ok v => f v
| fail v => fail v
| div => div
Core/Core.lean:100-104 unwrap_or takes an Option T, not a Result:
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Thus normal None becomes zero after the call; failure/divergence skips that
continuation and propagates outward. No Option Try/residual conversion is
used for the slow None-to-zero behavior. Equal head/tail observations preserve
this distinction without assuming termination or rounding of the slow helper.
Applicability conclusion
------------------------
The unchanged list representations, core bodies, exact declarations and
bindings justify reuse of the predecessor's immutable head/tail and byte-list
arguments, with this current inventory instead of predecessor call locations.
Primitive equivalence is extensional on every source-valid byte slice/string,
not conditioned on lexical acceptance, native/slow rounding, component package
inhabitability, A/B length bounds, or public reachability. A/B are used only
where the individual original GOAL requires them, and public bounds concern
the complete string before optional sign removal. The direct slow application
retains every source-valid unsigned numeric literal, with its independently
signed exponent and full significand, and is only on normal return. This
evidence supplies neither a GOAL proof nor a new model assumption.
Fresh request-99 inspection transcript
--------------------------------------
Each stdout block below is exact, without path abbreviations or ASCII
substitutions. Unicode occurs only where it is part of the inspected source or
inventory. Command exit status is reported separately.
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Exit status: 0
Raw stdout:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Exit status: 0
Raw stdout:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Command:
sed -n '311,316p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
Command:
sed -n '318,324p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
Command:
sed -n '326,331p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Exit status: 0
Raw stdout:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Exit status: 0
Raw stdout:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Command:
jq '.declarations[] | select(.name == "core.slice.Slice.first" or .name == "core.slice.Slice.split_first" or .name == "core.str.Str.as_bytes")' .trellis/scratch/inspect-native-1791579714814493776.json
Exit status: 0
Raw stdout:
{
"name": "core.slice.Slice.first",
"extracted_signature": "{T : Type} : Slice T → Result (Option T)",
"rust_symbol": "core::slice::{[T]}::first",
"raw_declaration_sha256": "221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105",
"source_utf8": "/-- [core::slice::{[T]}::first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43\n Name pattern: [core::slice::{[@T]}::first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::first\"]\naxiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)\n"
}
{
"name": "core.slice.Slice.split_first",
"extracted_signature": "{T : Type} : Slice T → Result (Option (T × (Slice T)))",
"rust_symbol": "core::slice::{[T]}::split_first",
"raw_declaration_sha256": "f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49",
"source_utf8": "/-- [core::slice::{[T]}::split_first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57\n Name pattern: [core::slice::{[@T]}::split_first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::split_first\"]\naxiom core.slice.Slice.split_first\n {T : Type} : Slice T → Result (Option (T × (Slice T)))\n"
}
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"source_utf8": "/-- [core::str::{str}::as_bytes]:\n Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41\n Name pattern: [core::str::{str}::as_bytes]\n Visibility: public -/\n@[rust_fun \"core::str::{str}::as_bytes\"]\naxiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)\n"
}
Command:
sed -n '155,157p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
Command:
sed -n '198,200p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Command:
sed -n '498,501p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
Command:
sed -n '18,24p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
Exit status: 0
Raw stdout:
/-!
# Slice
-/
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
/-- We need this to coerce slices to lists without marking `Slice` as reducible.
Command:
sed -n '1,9p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Exit status: 0
Raw stdout:
import Aeneas.Std.Scalar
import Aeneas.Std.Slice
namespace Aeneas.Std
def Str := Slice U8
instance : DecidableEq Str := inferInstanceAs (DecidableEq (Slice U8))
Command:
sed -n '237,244p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
- **Mutable reference parameters** become plain value parameters.
- **Returned mutable borrows** produce a tuple of (value, backward continuation).
- **Shared borrows (`&T`)** become plain `T` parameters (the value may be copied).
- **Pattern matching** maps directly to `match` in Lean.
- **Recursive functions** become Lean recursive functions (may require termination proofs).
- **Traits** are translated to Lean type classes.
Command:
sed -n '428,434p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
| Rust Concept | Lean Translation |
|--------------------------|--------------------------------------------------------------|
| `&mut T` parameter | `T` parameter (passed by value) |
| Returning `&'a mut T` | Returns `Result (T × (T → ...))` with backward continuation |
| `&T` (shared borrow) | `T` parameter (immutable, may be copied) |
| `panic!()` | `fail` in the `Result` monad |
| Integer overflow | `fail` (all arithmetic is checked) |
Command:
sed -n '60,67p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
open Error
inductive Result (α : Type u) where
| ok (v: α): Result α
| fail (e: Error): Result α
| div
deriving Repr, BEq
Command:
sed -n '115,122p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
-/
def bind {α : Type u} {β : Type v} (x: Result α) (f: α → Result β) : Result β :=
match x with
| ok v => f v
| fail v => fail v
| div => div
Command:
sed -n '97,105p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
unwrap x ⦃ v => x = some v ⦄ := by
simp only [unwrap, ofOption]; grind
@[step_pure_def, rust_fun "core::option::{core::option::Option<@T>}::unwrap_or" -canFail]
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Command:
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
Exit status: 0
Raw stdout:
2084: let (o, _) ← num.imp.dec2flt.parse.parse_scientific exponent_suffix
2085- ok (core.option.Option.unwrap_or o 0#i64)
--
2093: let (o, _) ←
2094: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2095- ok (core.option.Option.unwrap_or o 0#i64)
--
2155: let (o, _) ←
2156: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2157- ok (core.option.Option.unwrap_or o 0#i64)
--
2165: let (o, _) ←
2166: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2167- ok (core.option.Option.unwrap_or o 0#i64)
--
2223: let (o, _) ←
2224: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2225- ok (core.option.Option.unwrap_or o 0#i64)
--
2233: let (o, _) ←
2234: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2235- ok (core.option.Option.unwrap_or o 0#i64)
--
2280: let (o, _) ←
2281: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2282- ok (core.option.Option.unwrap_or o 0#i64)
--
2291: let (o, _) ←
2292: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2293- ok (core.option.Option.unwrap_or o 0#i64)
Command:
sed -n '27,46p' crate/dec2flt/slow.rs
Exit status: 0
Raw stdout:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
Command:
sed -n '244,260p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
s = s.parse_digits(|digit| d.try_add_digit(digit));
if let Some((b'.', s_next)) = s.split_first() {
s = s_next;
let first = s;
// Skip leading zeros.
if d.num_digits == 0 {
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
}
while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
let v = s.read_u64();
Command:
sed -n '287,300p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
}
}
let mut explicit = 0;
if let Some((&ch, s_next)) = s.split_first() {
if ch == b'e' || ch == b'E' {
s = s_next;
explicit = parse_scientific(&mut s).unwrap_or(0);
}
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
d.digits[i] = 0;
Command:
sed -n '39,52p' upstream/dec2flt/common.rs
Exit status: 0
Raw stdout:
fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
let mut s = self;
while let Some((c, rest)) = s.split_first() {
let c = c.wrapping_sub(b'0');
if c < 10 {
func(c);
s = rest;
} else {
break;
}
}
s
reference/model-evidence/aeneas-slice-observations.txt
Aeneas slice-observation evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout and executable used for the frozen extraction are:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328
At that commit, Aeneas/Std/Slice.lean:22 defines:
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
Thus an Aeneas Slice is an ordered List subtype. Its val field is the complete
ordered element list; the subtype property is the Usize.max length bound.
sha256sum /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7
At that commit, aeneas-overview.md:240 states the translation convention that
shared borrows (&T) become plain T parameters and that the value may be copied.
The summary table at line 432 additionally describes the resulting value as
immutable. Returned shared byte references therefore have no mutable backward
continuation or separately observable identity in the generated model.
The Rust source is the configured nightly-2026-06-01 core library:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
Its exact observation bodies at core/src/slice/mod.rs:155-156 and 198-199 are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
These bodies and the same core source hash are also pinned in
reference/model-evidence/binary64-boundary.txt. The complete configured Rust
&[u8] domain, including the isize::MAX byte-length condition, is independently
pinned in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module has this identity:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Its external signatures at generated.lean:316 and 323-324 are:
axiom core.slice.Slice.first {T : Type} :
Slice T → Result (Option T)
axiom core.slice.Slice.split_first {T : Type} :
Slice T → Result (Option (T × Slice T))
The following command enumerates every declaration or call occurrence:
rg -n 'core\.slice\.Slice\.(first|split_first)' generated.lean
Raw result:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
4290: let o ← core.slice.Slice.split_first s_ref
4338: let o ← core.slice.Slice.split_first s
4591: let o ← core.slice.Slice.split_first s1
4613: let o1 ← core.slice.Slice.split_first s2
4812: let o ← core.slice.Slice.first body
All five calls infer T = Std.U8:
* generated.lean:4288-4290 declares parse_scientific with
s_ref : Slice Std.U8 and calls split_first on s_ref.
* generated.lean:4332-4338 declares try_parse_19digits_loop.body with
s : Slice Std.U8 and calls split_first on s.
* generated.lean:4582-4591 declares parse_partial_number with
s : Slice Std.U8; try_parse_digits returns s1 : Slice Std.U8, which is the
first split_first argument.
* In the same parse_partial_number definition, every branch defining s2 returns
either s1 or the Std.U8 tail s_next. Hence the call on s2 at line 4613 also
has T = Std.U8.
* generated.lean:4803-4812 declares dec2flt_with_trace; body is returned by
core.str.Str.as_bytes, whose signature at line 330 is
Str → Result (Slice Std.U8), and first is called on body.
The adapted sources containing the corresponding calls are pinned by:
sha256sum crate/dec2flt/parse.rs crate/dec2flt/mod.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f crate/dec2flt/parse.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
The five exact Rust call sites are:
crate/dec2flt/parse.rs:65
if let Some((c, s_next)) = s.split_first() {
let digit = c.wrapping_sub(b'0');
...
s = s_next;
crate/dec2flt/parse.rs:127
if let Some((&c, s_next)) = s.split_first() {
negative = c == b'-';
if c == b'-' || c == b'+' { s = s_next; }
crate/dec2flt/parse.rs:177
if let Some((&b'.', s_next)) = s.split_first() {
s = s_next;
crate/dec2flt/parse.rs:194
if let Some((&c, s_next)) = s.split_first() {
if c == b'e' || c == b'E' { s = s_next; ... }
crate/dec2flt/mod.rs:365
let Some(&c) = body.first() else { ... };
Thus every call is on &[u8]. The call sites either destructure the shared byte
reference into a copied byte or invoke an immutable u8 method through it, and
they use the shared tail only as the next immutable slice. There is no mutation
through a returned reference and no pointer or lifetime identity observation.
Consequently, at every frozen GOAL-facing call site, erasing the
shared-reference lifetime/aliasing data retains the observed U8 value and, for
split_first, the same ordered suffix.
reference/model-evidence/aeneas-string-bytes.txt
Aeneas string/as_bytes evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout used for the frozen extraction is pinned by:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
The configured executable and its identity are pinned by:
jq -r '.effective_tools.aeneas' modeling-input/manifest.json
/home/leanagent/pv_spike/tools/aeneas/bin/aeneas
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
The Aeneas string definition at that commit is pinned by:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Its exact definition at Aeneas/Std/String.lean:6 is:
def Str := Slice U8
Thus Aeneas Str itself has only the Aeneas Slice U8 constraints; it does not by
itself impose Rust str's UTF-8 validity or isize::MAX byte-length restriction.
The ordered-list representation of Aeneas Slice, including its Usize.max bound,
is pinned separately in reference/model-evidence/aeneas-slice-observations.txt.
The configured Rust str validity and isize::MAX byte-length conditions are
pinned separately in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module and its string external are pinned by:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
The raw declaration at generated.lean:326-331 is:
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
The inspect-native raw declaration digest recorded in the support binding is:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The command
rg -n 'core\.str\.Str\.as_bytes' generated.lean
has the complete raw result:
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
4811: let body ← core.str.Str.as_bytes s
Consequently the only call in the frozen generated module is the first
operation in num.imp.dec2flt.dec2flt_with_trace, whose parameter and call at
generated.lean:4807-4811 are:
(coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
Result ((core.result.Result F num.float_parse.ParseFloatError) ×
(num.imp.dec2flt.Dec2FltTrace F))
:= do
let body ← core.str.Str.as_bytes s
The support manifest itself is pinned by:
sha256sum Tablet/model-support.json
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
Its exact binding at Tablet/model-support.json:183-190 is:
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"node": "ModelStrAsBytes",
"declaration": "dec2flt_model.ModelStrAsBytes"
}
The configured Rust core implementation is pinned by:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Its exact same-layout body at core/src/str/mod.rs:498-501 is:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
The frozen adapted dispatcher source and its sole source call are pinned by:
sha256sum crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
rg -n 'as_bytes' crate
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:362-365
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
The core body returns a shared byte slice by same-layout transmutation: it does
not change, reorder, add, or remove bytes and has no failure branch. The Aeneas
shared-borrow convention and the later immutable ordered-byte observations are
pinned in reference/model-evidence/aeneas-slice-observations.txt.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:f05a5cfad8eb1c5c3f09eb3958815c5bfd33ed8638cf924a1d78649befb3f783 |
| Preservation current fingerprint | preservation-v1:f05a5cfad8eb1c5c3f09eb3958815c5bfd33ed8638cf924a1d78649befb3f783 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","lean_semantic_closure":"f2d984413bfd9b1860de8e3d5e54d883a9edf8c6755551f3e6a7eec141a714e9","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","lean_semantic_closure":"f2d984413bfd9b1860de8e3d5e54d883a9edf8c6755551f3e6a7eec141a714e9","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "20136f282ae692e0da95089ce3c325a6c11ff5a79ec056cc87db5c2ddaea3ba7",
"dep_statement_hashes": {
"SourceValidByteSlice": "52522ae5b8602c6279dde2af31f94e21db249400641f5d3e951f68a74c3c11e2"
},
"combined_sound_fp": "preservation-v1:f05a5cfad8eb1c5c3f09eb3958815c5bfd33ed8638cf924a1d78649befb3f783"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.slice.Slice.split_first",
"extracted_signature": "{T : Type} : Slice T → Result (Option (T × (Slice T)))",
"rust_symbol": "core::slice::{[T]}::split_first",
"raw_declaration_sha256": "f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49",
"node": "ModelSliceSplitFirst",
"declaration": "dec2flt_model.ModelSliceSplitFirst"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"sha256": "c525bf0a597763fba686f2fce551b436a16d406f2e10942a23665eadc676988b",
"cited_by": [
"Tablet/ModelSliceSplitFirst.tex",
"Tablet/model-support.json",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/aeneas-slice-observations.txt",
"sha256": "566b151c7c5eee54bbc634b117f85b80c8adf7a0ba4362759a076caca6c61c38",
"cited_by": [
"Tablet/ModelSliceSplitFirst.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/aeneas-string-bytes.txt",
"sha256": "132e19fa71c736d030b3e5cb788cf2bb1e99c60742ac19ad6860855f7ced21b6",
"cited_by": [
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/aeneas-slice-observations.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"Tablet/ModelSliceSplitFirst.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
}
]core::str::{str}::as_bytes
Inspect related source (1)
- as_bytes · core/src/str/mod.rs:498 Rust library
Related source and models come from the extraction records and declared dependencies.
| Rust item | core::str::{str}::as_bytes |
|---|---|
| Recorded source | /rustc/library/core/src/str/mod.rs |
| Lines | 498:4–498:41 |
The related-source link includes this operation’s Rust standard-library implementation.
Opaque extraction signature
: Str → Result (Slice Std.U8)Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelStrAsBytes]
def ModelStrAsBytes (s : Str) : Result (Slice Std.U8) :=
-- BODY
ok s
end dec2flt_model
Why this model is faithful
Definition
Str byte slice s,
\mathsf{ModelStrAsBytes}(s) successfully returns s itself.Preservation argument
Claim
Str s satisfying
\mathsf{DecimalGoalVocabularyDefault.sourceString}(s), the configured Rust
str it represents has exactly those complete ordered UTF-8 bytes.
Source str::as_bytes returns normally with an immutable shared slice
of precisely those bytes, and ModelStrAsBytes returns
ok of the identical ordered Aeneas Slice U8 s.
No lexical-validity, A/B, acceptance, rounding, or termination premise is used.Proof
as_bytes body are
retained, explicitly as predecessor evidence, in
reference/model-evidence/aeneas-string-bytes.txt;
the historical slice and shared-borrow representation is in
reference/model-evidence/aeneas-slice-observations.txt.
Their current applicability, unchanged executable/library/core-source
identities, exact raw signatures and Rust symbols, declaration digests and
support bindings, and complete current call inventory are independently
checked in
reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
The current sole generated as_bytes call is
generated.lean:4567, at the beginning of
dec2flt_with_trace, corresponding to
crate/dec2flt/mod.rs:364. The fixed dispatcher frame of DispatchFrame retains the
same conversion, including when its helper components are abstract.Str := Slice U8, so its type alone overapproximates
Rust strings: it permits arbitrary bytes up to Usize.max.
The definition DecimalGoalVocabularyDefault restricts
sourceString to length at most
9223372036854775807=\mathtt{isize::MAX} and a witness Lean string whose
UTF-8 encoding is the entire byte list.
These are the configured Rust str representation conditions in
reference/model-evidence/source-valid-byte-slice.txt.
Consequently the claim covers every configured source string and no invalid
UTF-8 model string. A general source-valid Rust &[u8] needs only
the length bound of SourceValidByteSlice, not this UTF-8 witness.ok s;
its result retains the same list, length and subtype bound. In particular the
output is source-valid because the input already has the stricter
\mathtt{isize::MAX} bound. No pointer identity or mutation through the
returned borrow is observed at any subsequent dispatcher use.Result.bind cases recorded in the current evidence show, a
later failure/divergence is not turned into normal helper None or
Rust Err. Primitive infallibility is not complete-parser totality,
lexical acceptance, rounding correctness, or component inhabitability.
The claim makes no source preservation assertion for model Str
values outside sourceString, and imposes no UTF-8 premise on direct
helper GOALs that take byte slices rather than strings.
For the applications below the original constants are
A=3458764513820540928 and B=576460752303421440 bytes; public bounds
refer to the complete string before any sign stripping.Authored arguments for individual requirements
Requirement: assembly correspondence
BiasedFp,
not a string, and has no transitive string conversion. This binding is
noninterfering with its required normal return and cast/shift/OR word equation.Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
as_bytes call or
total-classification assumption is introduced.Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
i64/u64 operands, not a
string, and has no conversion callee. Its on-normal deferral/rounding
alternatives are unaffected.Requirement: native correct or defer
Decimal and has no string
conversion, including on the disguised path. Its on-normal None/
Some, sign and many_digits observations are unchanged.Requirement: number helper acceptance
Some, including with overflow checks, is not assumed.Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
None retain their original meaning.Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Err without panic is not presumed.Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Ok without panic remains required, not assumed.Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
None retain their meanings with no UTF-8 premise.Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelStrAsBytes · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T1_PrimitiveApplicability.txt
Current first/split_first/as_bytes applicability
==============================================
This is CURRENT primary source/extraction inspection, not a parser execution
or a GOAL verdict. It was independently checked in request 99, task 10, from
/home/leanagent/math/dec2flt-r0003-runtime/dispatch/10/repo.
The prior task-8 candidate was accepted=false and is only advisory. All commands
in the fresh inspection transcript below exited 0; their unmodified outputs
are recorded separately from the historical predecessor records.
The predecessor records aeneas-slice-observations.txt and
aeneas-string-bytes.txt retain their original 45b5027c... extraction identity;
their old call locations are not used as current inventory.
1. Identities and unchanged library meanings
-------------------------------------------
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Raw output:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw output:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Raw output (path suffixes abbreviated only here):
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
These are the same executable/library/core-source identities as the historical
records. Slice.lean:22 still defines
def Slice (a : Type u) := { l : List a // l.length <= Usize.max }
(ASCII rendering of the Lean alpha and inequality). String.lean:6 defines
def Str := Slice U8
The overview:240 says shared borrows (&T) become plain T parameters, which may
be copied; its table:432 describes them as immutable. The actual pinned core
bodies (sed -n '155,157p' .../core/src/slice/mod.rs,
sed -n '198,200p' .../core/src/slice/mod.rs, and
sed -n '498,501p' .../core/src/str/mod.rs) are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
No primitive body or representation change is being introduced.
These are read-only inspections with no compiler invocation, new build setting
or extraction invocation. The audited manifest, toolchain, target and extraction
configuration remain fixed. The full paths and exact Unicode representations
are retained in the fresh inspection transcript below. The separate
source-valid-byte-slice.txt record supplies the target isize::MAX bound and
Rust str's UTF-8 condition; a general &[u8] does not require UTF-8.
2. Exact current externals and support reconciliation
----------------------------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
Result: declaration_count=24; full inventory retained at
.trellis/scratch/inspect-native-1791579714814493776.json
The three entries selected by their exact names have the following unchanged
signatures, Rust symbols and raw declaration SHA256 values. Unicode below is
retained to copy the exact inventory signatures.
name: core.slice.Slice.first
extracted_signature: {T : Type} : Slice T → Result (Option T)
rust_symbol: core::slice::{[T]}::first
raw_declaration_sha256: 221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105
name: core.slice.Slice.split_first
extracted_signature: {T : Type} : Slice T → Result (Option (T × (Slice T)))
rust_symbol: core::slice::{[T]}::split_first
raw_declaration_sha256: f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49
name: core.str.Str.as_bytes
extracted_signature: : Str → Result (Slice Std.U8)
rust_symbol: core::str::{str}::as_bytes
raw_declaration_sha256: 11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The corresponding complete raw declaration text is generated.lean:311-316,
318-324 and 326-331, respectively (sed -n for each range):
/-- [core::slice::{[T]}::first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43
Name pattern: [core::slice::{[@T]}::first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::first"]
axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
/-- [core::slice::{[T]}::split_first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57
Name pattern: [core::slice::{[@T]}::split_first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::split_first"]
axiom core.slice.Slice.split_first
{T : Type} : Slice T → Result (Option (T × (Slice T)))
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
Recomputing each declaration digest, including its final newline:
sed -n '311,316p' generated.lean | sha256sum
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
sed -n '318,324p' generated.lean | sha256sum
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
sed -n '326,331p' generated.lean | sha256sum
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
jq '.bindings[] | select(.node == "ModelSliceFirst" or .node == "ModelSliceSplitFirst" or .node == "ModelStrAsBytes")' Tablet/model-support.json
Each binding copies precisely the name, extracted_signature, rust_symbol and
raw_declaration_sha256 above. Its node/declaration pair is, respectively:
ModelSliceFirst / dec2flt_model.ModelSliceFirst
ModelSliceSplitFirst / dec2flt_model.ModelSliceSplitFirst
ModelStrAsBytes / dec2flt_model.ModelStrAsBytes
This reconciles the full raw declarations, not merely the identifier spelling.
In the current composed Preamble.lean:212,219,226 the externals are typed
references to exactly these principal definitions. Their bodies are, in order,
ok s.val.head?, empty/head-tail list matching (tail bound from s.property),
and ok s. No external axiom for these operations remains in the composition.
3. Complete current bound-call inventory
---------------------------------------
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Complete raw output:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Rust call / current extracted function and input:
crate/dec2flt/parse.rs:127 / parse_scientific:1732-1765, s_ref : Slice Std.U8
crate/dec2flt/parse.rs:65 / try_parse_19digits_loop.body:4087-4110, s : Slice Std.U8
crate/dec2flt/parse.rs:180 / parse_partial_number:4337-4364, s1 : Slice Std.U8
crate/dec2flt/parse.rs:197 / parse_partial_number:4369, s2 : Slice Std.U8
crate/dec2flt/mod.rs:364 / dec2flt_with_trace:4567, s : Str
crate/dec2flt/mod.rs:365 / dec2flt_with_trace:4568, body : Slice Std.U8
The s1 argument is returned by try_parse_digits; s2 is s1 or the returned
Std.U8 suffix after fractional scanning. Every bound slice call infers
T=Std.U8. Returned heads are copied/read, and tails are immutable next slices;
none of these calls observes pointer identity or mutates the returned borrow.
The dispatcher strips at most one leading sign after as_bytes and first.
The authored fixed frame mirrors these same two initial operations at
Tablet/P9_T1_DispatchFrame.lean:15-16. It uses the same bound as_bytes and
first definitions even with abstract helper components; it has no split_first
call of its own. These are authored frame uses, not additional call sites in
the raw generated module enumerated above.
4. Original observations versus audited indexed replacements
------------------------------------------------------------
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Complete raw output:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
The output ordering is the recorded rg ordering, not program evaluation order.
The original scientific digit-entry test at upstream/dec2flt/parse.rs:86
uses first(). Its audited replacement at crate/dec2flt/parse.rs:134-137 is:
// `matches!` with a guarded slice pattern triggers an Aeneas internal
// error. This short-circuit test reads the same first byte exactly when
// it exists and therefore preserves both acceptance and evaluation order.
if !s.is_empty() && s[0].is_ascii_digit() {
For [] both tests are false without a byte read; for x::xs both test the
identical x for is_ascii_digit. Therefore this original first observation
still exists semantically, but is not a call to the bound first external.
The extraction:1747-1753 uses is_empty, then index_usize 0, then the digit test.
Likewise original decimal-sequence split observations at upstream lines
244,250,255,291 become guarded indexing in crate lines 296,302,309,348-363;
the leading-dot/zero adjustment at upstream parse.rs:156 becomes
adjust_many_digit_count:86-99. Original common.rs:39-52 scans by split_first
and consumes a digit only when c.wrapping_sub(b'0')<10; the specialized
indexed scans retain that order and first-nondigit stop. These adaptations
are distinct from the four bound split calls. Their audited source comments
and Preamble preservation remain separate obligations, not claims proved by
absence from the external inventory.
5. Slow scientific path, residual and outer outcomes
---------------------------------------------------
The source call chain is crate/dec2flt/slow.rs:40 ->
crate/dec2flt/decimal_seq.rs:362-363 -> crate/dec2flt/parse.rs:127.
The extracted chain starts at generated.lean:3941:
let d <- num.imp.dec2flt.decimal_seq.parse_decimal_seq s
and reaches parse_scientific exponent_suffix in all eight e/E branches:
2084/2094, 2156/2166, 2224/2234, 2281/2292. The <- here is ASCII rendering;
the raw extraction uses Lean's left arrow. Inspect each branch with sed -n;
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
shows each call immediately followed by
ok (core.option.Option.unwrap_or o 0#i64)
The scientific call itself reaches the bound split_first at 1734. The
numeric parser also calls this same scientific function at 4412 and 4459,
but observes its returned residual in its consumed-length calculation;
crate/dec2flt/parse.rs:234-240 requires rest == s.len() for Some.
The source at crate/dec2flt/decimal_seq.rs:350-366 reads:
if ch == b'e' || ch == b'E' {
// [preservation comments at 351-361, retained in the pinned file]
let mut exponent_suffix = &s[1..];
explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
Counts have been saved before this call. The residual mutation is unobserved
only after the scientific call returns; the call is not elided. Original
upstream/dec2flt/decimal_seq.rs:291-295 likewise calls parse_scientific then
unwrap_or. The later generated.lean:3942 test for d.num_digits=0 is after
the bind at 3941, so zero-significand inputs do not bypass scientific parsing.
The unsigned numeric literal 1e-2 passes -2 as the exponent suffix, despite
having no leading sign. This is source inspection, not a newly run test.
The exact loop body at generated.lean:1692-1716 / crate/dec2flt/parse.rs:145-151
tests count<len and the byte's wrapping-sub digit predicate, updates E only
when E<2^59, then increments count regardless of whether E was updated.
The sign is taken from the scientific suffix (1735-1746), not the leading
literal sign. The residual is the slice starting at count (1758-1761).
With 0<=E<2^59 and 0<=digit<=9, an update is at most
10*2^59-1=5764607523034234879<i64::MAX. One update can overshoot 2^59;
this is not a clamp. Later exponent digits are still consumed, including
arbitrarily many zeroes/digits within a source-valid slice; the first nondigit
and everything after it remain in the residual. Empty/sign-only/nondigit
suffixes normally produce None with the exact post-sign residual.
The monadic distinction is independently checkable in the unchanged Aeneas
library. Commands:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Raw output (path suffixes abbreviated):
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 Aeneas/Std/Core/Core.lean
Primitives.lean:62-66 has Result.ok, Result.fail and Result.div. Its
117-121 bind is:
match x with
| ok v => f v
| fail v => fail v
| div => div
Core/Core.lean:100-104 unwrap_or takes an Option T, not a Result:
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Thus normal None becomes zero after the call; failure/divergence skips that
continuation and propagates outward. No Option Try/residual conversion is
used for the slow None-to-zero behavior. Equal head/tail observations preserve
this distinction without assuming termination or rounding of the slow helper.
Applicability conclusion
------------------------
The unchanged list representations, core bodies, exact declarations and
bindings justify reuse of the predecessor's immutable head/tail and byte-list
arguments, with this current inventory instead of predecessor call locations.
Primitive equivalence is extensional on every source-valid byte slice/string,
not conditioned on lexical acceptance, native/slow rounding, component package
inhabitability, A/B length bounds, or public reachability. A/B are used only
where the individual original GOAL requires them, and public bounds concern
the complete string before optional sign removal. The direct slow application
retains every source-valid unsigned numeric literal, with its independently
signed exponent and full significand, and is only on normal return. This
evidence supplies neither a GOAL proof nor a new model assumption.
Fresh request-99 inspection transcript
--------------------------------------
Each stdout block below is exact, without path abbreviations or ASCII
substitutions. Unicode occurs only where it is part of the inspected source or
inventory. Command exit status is reported separately.
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Exit status: 0
Raw stdout:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Exit status: 0
Raw stdout:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Command:
sed -n '311,316p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
Command:
sed -n '318,324p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
Command:
sed -n '326,331p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Exit status: 0
Raw stdout:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Exit status: 0
Raw stdout:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Command:
jq '.declarations[] | select(.name == "core.slice.Slice.first" or .name == "core.slice.Slice.split_first" or .name == "core.str.Str.as_bytes")' .trellis/scratch/inspect-native-1791579714814493776.json
Exit status: 0
Raw stdout:
{
"name": "core.slice.Slice.first",
"extracted_signature": "{T : Type} : Slice T → Result (Option T)",
"rust_symbol": "core::slice::{[T]}::first",
"raw_declaration_sha256": "221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105",
"source_utf8": "/-- [core::slice::{[T]}::first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43\n Name pattern: [core::slice::{[@T]}::first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::first\"]\naxiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)\n"
}
{
"name": "core.slice.Slice.split_first",
"extracted_signature": "{T : Type} : Slice T → Result (Option (T × (Slice T)))",
"rust_symbol": "core::slice::{[T]}::split_first",
"raw_declaration_sha256": "f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49",
"source_utf8": "/-- [core::slice::{[T]}::split_first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57\n Name pattern: [core::slice::{[@T]}::split_first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::split_first\"]\naxiom core.slice.Slice.split_first\n {T : Type} : Slice T → Result (Option (T × (Slice T)))\n"
}
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"source_utf8": "/-- [core::str::{str}::as_bytes]:\n Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41\n Name pattern: [core::str::{str}::as_bytes]\n Visibility: public -/\n@[rust_fun \"core::str::{str}::as_bytes\"]\naxiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)\n"
}
Command:
sed -n '155,157p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
Command:
sed -n '198,200p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Command:
sed -n '498,501p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
Command:
sed -n '18,24p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
Exit status: 0
Raw stdout:
/-!
# Slice
-/
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
/-- We need this to coerce slices to lists without marking `Slice` as reducible.
Command:
sed -n '1,9p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Exit status: 0
Raw stdout:
import Aeneas.Std.Scalar
import Aeneas.Std.Slice
namespace Aeneas.Std
def Str := Slice U8
instance : DecidableEq Str := inferInstanceAs (DecidableEq (Slice U8))
Command:
sed -n '237,244p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
- **Mutable reference parameters** become plain value parameters.
- **Returned mutable borrows** produce a tuple of (value, backward continuation).
- **Shared borrows (`&T`)** become plain `T` parameters (the value may be copied).
- **Pattern matching** maps directly to `match` in Lean.
- **Recursive functions** become Lean recursive functions (may require termination proofs).
- **Traits** are translated to Lean type classes.
Command:
sed -n '428,434p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
| Rust Concept | Lean Translation |
|--------------------------|--------------------------------------------------------------|
| `&mut T` parameter | `T` parameter (passed by value) |
| Returning `&'a mut T` | Returns `Result (T × (T → ...))` with backward continuation |
| `&T` (shared borrow) | `T` parameter (immutable, may be copied) |
| `panic!()` | `fail` in the `Result` monad |
| Integer overflow | `fail` (all arithmetic is checked) |
Command:
sed -n '60,67p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
open Error
inductive Result (α : Type u) where
| ok (v: α): Result α
| fail (e: Error): Result α
| div
deriving Repr, BEq
Command:
sed -n '115,122p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
-/
def bind {α : Type u} {β : Type v} (x: Result α) (f: α → Result β) : Result β :=
match x with
| ok v => f v
| fail v => fail v
| div => div
Command:
sed -n '97,105p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
unwrap x ⦃ v => x = some v ⦄ := by
simp only [unwrap, ofOption]; grind
@[step_pure_def, rust_fun "core::option::{core::option::Option<@T>}::unwrap_or" -canFail]
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Command:
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
Exit status: 0
Raw stdout:
2084: let (o, _) ← num.imp.dec2flt.parse.parse_scientific exponent_suffix
2085- ok (core.option.Option.unwrap_or o 0#i64)
--
2093: let (o, _) ←
2094: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2095- ok (core.option.Option.unwrap_or o 0#i64)
--
2155: let (o, _) ←
2156: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2157- ok (core.option.Option.unwrap_or o 0#i64)
--
2165: let (o, _) ←
2166: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2167- ok (core.option.Option.unwrap_or o 0#i64)
--
2223: let (o, _) ←
2224: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2225- ok (core.option.Option.unwrap_or o 0#i64)
--
2233: let (o, _) ←
2234: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2235- ok (core.option.Option.unwrap_or o 0#i64)
--
2280: let (o, _) ←
2281: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2282- ok (core.option.Option.unwrap_or o 0#i64)
--
2291: let (o, _) ←
2292: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2293- ok (core.option.Option.unwrap_or o 0#i64)
Command:
sed -n '27,46p' crate/dec2flt/slow.rs
Exit status: 0
Raw stdout:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
Command:
sed -n '244,260p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
s = s.parse_digits(|digit| d.try_add_digit(digit));
if let Some((b'.', s_next)) = s.split_first() {
s = s_next;
let first = s;
// Skip leading zeros.
if d.num_digits == 0 {
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
}
while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
let v = s.read_u64();
Command:
sed -n '287,300p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
}
}
let mut explicit = 0;
if let Some((&ch, s_next)) = s.split_first() {
if ch == b'e' || ch == b'E' {
s = s_next;
explicit = parse_scientific(&mut s).unwrap_or(0);
}
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
d.digits[i] = 0;
Command:
sed -n '39,52p' upstream/dec2flt/common.rs
Exit status: 0
Raw stdout:
fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
let mut s = self;
while let Some((c, rest)) = s.split_first() {
let c = c.wrapping_sub(b'0');
if c < 10 {
func(c);
s = rest;
} else {
break;
}
}
s
reference/model-evidence/aeneas-slice-observations.txt
Aeneas slice-observation evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout and executable used for the frozen extraction are:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328
At that commit, Aeneas/Std/Slice.lean:22 defines:
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
Thus an Aeneas Slice is an ordered List subtype. Its val field is the complete
ordered element list; the subtype property is the Usize.max length bound.
sha256sum /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7
At that commit, aeneas-overview.md:240 states the translation convention that
shared borrows (&T) become plain T parameters and that the value may be copied.
The summary table at line 432 additionally describes the resulting value as
immutable. Returned shared byte references therefore have no mutable backward
continuation or separately observable identity in the generated model.
The Rust source is the configured nightly-2026-06-01 core library:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
Its exact observation bodies at core/src/slice/mod.rs:155-156 and 198-199 are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
These bodies and the same core source hash are also pinned in
reference/model-evidence/binary64-boundary.txt. The complete configured Rust
&[u8] domain, including the isize::MAX byte-length condition, is independently
pinned in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module has this identity:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Its external signatures at generated.lean:316 and 323-324 are:
axiom core.slice.Slice.first {T : Type} :
Slice T → Result (Option T)
axiom core.slice.Slice.split_first {T : Type} :
Slice T → Result (Option (T × Slice T))
The following command enumerates every declaration or call occurrence:
rg -n 'core\.slice\.Slice\.(first|split_first)' generated.lean
Raw result:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
4290: let o ← core.slice.Slice.split_first s_ref
4338: let o ← core.slice.Slice.split_first s
4591: let o ← core.slice.Slice.split_first s1
4613: let o1 ← core.slice.Slice.split_first s2
4812: let o ← core.slice.Slice.first body
All five calls infer T = Std.U8:
* generated.lean:4288-4290 declares parse_scientific with
s_ref : Slice Std.U8 and calls split_first on s_ref.
* generated.lean:4332-4338 declares try_parse_19digits_loop.body with
s : Slice Std.U8 and calls split_first on s.
* generated.lean:4582-4591 declares parse_partial_number with
s : Slice Std.U8; try_parse_digits returns s1 : Slice Std.U8, which is the
first split_first argument.
* In the same parse_partial_number definition, every branch defining s2 returns
either s1 or the Std.U8 tail s_next. Hence the call on s2 at line 4613 also
has T = Std.U8.
* generated.lean:4803-4812 declares dec2flt_with_trace; body is returned by
core.str.Str.as_bytes, whose signature at line 330 is
Str → Result (Slice Std.U8), and first is called on body.
The adapted sources containing the corresponding calls are pinned by:
sha256sum crate/dec2flt/parse.rs crate/dec2flt/mod.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f crate/dec2flt/parse.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
The five exact Rust call sites are:
crate/dec2flt/parse.rs:65
if let Some((c, s_next)) = s.split_first() {
let digit = c.wrapping_sub(b'0');
...
s = s_next;
crate/dec2flt/parse.rs:127
if let Some((&c, s_next)) = s.split_first() {
negative = c == b'-';
if c == b'-' || c == b'+' { s = s_next; }
crate/dec2flt/parse.rs:177
if let Some((&b'.', s_next)) = s.split_first() {
s = s_next;
crate/dec2flt/parse.rs:194
if let Some((&c, s_next)) = s.split_first() {
if c == b'e' || c == b'E' { s = s_next; ... }
crate/dec2flt/mod.rs:365
let Some(&c) = body.first() else { ... };
Thus every call is on &[u8]. The call sites either destructure the shared byte
reference into a copied byte or invoke an immutable u8 method through it, and
they use the shared tail only as the next immutable slice. There is no mutation
through a returned reference and no pointer or lifetime identity observation.
Consequently, at every frozen GOAL-facing call site, erasing the
shared-reference lifetime/aliasing data retains the observed U8 value and, for
split_first, the same ordered suffix.
reference/model-evidence/aeneas-string-bytes.txt
Aeneas string/as_bytes evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout used for the frozen extraction is pinned by:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
The configured executable and its identity are pinned by:
jq -r '.effective_tools.aeneas' modeling-input/manifest.json
/home/leanagent/pv_spike/tools/aeneas/bin/aeneas
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
The Aeneas string definition at that commit is pinned by:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Its exact definition at Aeneas/Std/String.lean:6 is:
def Str := Slice U8
Thus Aeneas Str itself has only the Aeneas Slice U8 constraints; it does not by
itself impose Rust str's UTF-8 validity or isize::MAX byte-length restriction.
The ordered-list representation of Aeneas Slice, including its Usize.max bound,
is pinned separately in reference/model-evidence/aeneas-slice-observations.txt.
The configured Rust str validity and isize::MAX byte-length conditions are
pinned separately in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module and its string external are pinned by:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
The raw declaration at generated.lean:326-331 is:
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
The inspect-native raw declaration digest recorded in the support binding is:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The command
rg -n 'core\.str\.Str\.as_bytes' generated.lean
has the complete raw result:
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
4811: let body ← core.str.Str.as_bytes s
Consequently the only call in the frozen generated module is the first
operation in num.imp.dec2flt.dec2flt_with_trace, whose parameter and call at
generated.lean:4807-4811 are:
(coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
Result ((core.result.Result F num.float_parse.ParseFloatError) ×
(num.imp.dec2flt.Dec2FltTrace F))
:= do
let body ← core.str.Str.as_bytes s
The support manifest itself is pinned by:
sha256sum Tablet/model-support.json
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
Its exact binding at Tablet/model-support.json:183-190 is:
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"node": "ModelStrAsBytes",
"declaration": "dec2flt_model.ModelStrAsBytes"
}
The configured Rust core implementation is pinned by:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Its exact same-layout body at core/src/str/mod.rs:498-501 is:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
The frozen adapted dispatcher source and its sole source call are pinned by:
sha256sum crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
rg -n 'as_bytes' crate
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:362-365
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
The core body returns a shared byte slice by same-layout transmutation: it does
not change, reorder, add, or remove bytes and has no failure branch. The Aeneas
shared-borrow convention and the later immutable ordered-byte observations are
pinned in reference/model-evidence/aeneas-slice-observations.txt.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:19a0abb42e685585efa526b41f112b4e06366bc0110ea62d4695dd60168fa4b8 |
| Preservation current fingerprint | preservation-v1:19a0abb42e685585efa526b41f112b4e06366bc0110ea62d4695dd60168fa4b8 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"7df2b5123e579ab4bfb5510ea39ca58bceb2387aa50af74f44127e51a1e7f281","lean_semantic_closure":"d53346dcad87db5a726f330ad015dd667460351ed0ca2ed56f7916a28b27ce6f","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"7df2b5123e579ab4bfb5510ea39ca58bceb2387aa50af74f44127e51a1e7f281","lean_semantic_closure":"d53346dcad87db5a726f330ad015dd667460351ed0ca2ed56f7916a28b27ce6f","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "f916e2fd66388d18e2456a303454fbcd6879a82707c07fef4c2308c5eb5397c4",
"dep_statement_hashes": {
"DecimalGoalVocabularyDefault": "32a84a43f71314245b7cbbbce3aefa2bde7d8120fb1fddb93ff7b90796f8a87b",
"P9_T1_DispatchFrame": "9c8534245e042036f0736480d142a007a6fd6a417572dd00c6c15eb95f8e0c98",
"SourceValidByteSlice": "52522ae5b8602c6279dde2af31f94e21db249400641f5d3e951f68a74c3c11e2"
},
"combined_sound_fp": "preservation-v1:19a0abb42e685585efa526b41f112b4e06366bc0110ea62d4695dd60168fa4b8"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"node": "ModelStrAsBytes",
"declaration": "dec2flt_model.ModelStrAsBytes"
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"sha256": "c525bf0a597763fba686f2fce551b436a16d406f2e10942a23665eadc676988b",
"cited_by": [
"Tablet/ModelStrAsBytes.tex",
"Tablet/model-support.json",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/aeneas-slice-observations.txt",
"sha256": "566b151c7c5eee54bbc634b117f85b80c8adf7a0ba4362759a076caca6c61c38",
"cited_by": [
"Tablet/ModelStrAsBytes.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/aeneas-string-bytes.txt",
"sha256": "132e19fa71c736d030b3e5cb788cf2bb1e99c60742ac19ad6860855f7ced21b6",
"cited_by": [
"Tablet/ModelStrAsBytes.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/aeneas-slice-observations.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"Tablet/ModelStrAsBytes.tex",
"Tablet/model-support.json",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
}
]dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64
Inspect related source (1)
- from_u64 · dec2flt/mod.rs:263 Program Rust
Related source and models come from the extraction records and declared dependencies.
| Rust item | dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64 |
|---|---|
| Recorded source | num/imp/../../dec2flt/mod.rs |
| Lines | 263:4–266:5 |
Opaque extraction signature
: Std.U64 → Result F64Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64ModelDefault
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelF64FromU64]
def ModelF64FromU64 : Std.U64 -> Result F64 :=
-- BODY
Binary64ModelDefault.fromU64
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
u64-to-f64 cast on its asserted domain and reports assertion failure outside it.Proof
Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ModelF64FromU64 · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | Tablet/model-support.json |
|---|---|
| Kind | opaque external binding |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:b4abbea9505062f1071a78eb8b774d97d4cc87f9a6735343deb62a084be65fdc |
| Preservation current fingerprint | preservation-v1:b4abbea9505062f1071a78eb8b774d97d4cc87f9a6735343deb62a084be65fdc |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","lean_semantic_closure":"6cbb08481544edb52e8b26d6bae4bca0cec628f574e86986141494017d56dac1","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","lean_semantic_closure":"6cbb08481544edb52e8b26d6bae4bca0cec628f574e86986141494017d56dac1","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "2b3e22384d51495eec1f6c370db049e6b9c5a91e87b7865542a6bc3037fe4dd7",
"dep_statement_hashes": {
"Binary64ModelDefault": "be5dcc4afe23616ca8fd1d15d30fbbe4ee2621d68be3341b8e74a66e6dcd736f"
},
"combined_sound_fp": "preservation-v1:b4abbea9505062f1071a78eb8b774d97d4cc87f9a6735343deb62a084be65fdc"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Exact source record
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}Captured evidence identities
[
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/ModelF64FromU64.tex",
"Tablet/model-support.json"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
}
]Specification vocabulary and authored definitions (17)
Assumptions
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
-- [PV UNDER-MODEL ASSUMPTIONS]
-- Worker-authored staged assumptions live between markers:
-- -- BEGIN UNDERMODEL ASSUMPTION <id>
-- axiom <name> : <type>
-- -- END UNDERMODEL ASSUMPTION <id>
-- BEGIN UNDERMODEL ASSUMPTION dec2flt-r0003-selected-x86_64-width-64
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
-- END UNDERMODEL ASSUMPTION dec2flt-r0003-selected-x86_64-width-64
Why this model is faithful
Definition
x86_64-unknown-linux-gnu extraction environment, the platform
parameter used by the installed Aeneas model satisfies
\mathtt{System.Platform.numBits}=64.Preservation argument
Claim
Usize and
Isize therefore represent, respectively, the unsigned and signed
64-bit Rust pointer-sized integers. Every configured source-valid byte
slice's contents and length remain representable, and Rust strings retain
their separate UTF-8 requirement. No source domain, A/B bound, source
operation, extracted declaration, or GOAL proposition is changed. The
binding is independent of whether a GOAL is proved or disproved.Proof
effective_tools,
resource_environment, and accepted setup audit select the pinned
nightly-2026-06-01 compiler and the x86_64 environment. The current
SETUP.md, under ``Package and extraction,'' explains that the
compiler host is the extraction target: extraction.json has empty
Cargo, Charon, and Aeneas argument lists, with no target override.
crate/rust-toolchain.toml records that channel and
x86_64-unknown-linux-gnu. The manifest also identifies the
installed Lean executable and the Aeneas library path. The current file
identities, exact record locators, and relevant excerpts are retained in the
``CURRENT selected-target width binding'' appendix of
reference/model-evidence/source-valid-byte-slice.txt.
This argument uses the current accepted environment, not a predecessor's
assumption or approval.usize
and isize have the platform pointer width; isize has signed
two's-complement interpretation. The pinned core documentation and Rust
Reference locators are in
reference/model-evidence/source-valid-byte-slice.txt.
Fresh managed invocations of the pinned compiler report host
x86_64-unknown-linux-gnu; both its default --print cfg
and explicit-target invocation report target_pointer_width="64".
Their complete raw outputs agree. The unchanged retained probe, freshly
compiled for that target with overflow checks and debug assertions enabled,
reports usize_bits=64,
isize_max=9223372036854775807, and u8_size=1; its raw
output agrees byte-for-byte with the retained output. These probes
corroborate the selected compiler environment; they neither sample parser
correctness nor establish a universal claim by testing.Scalar/Core.lean defines
UScalarTy.numBits .Usize and
IScalarTy.numBits .Isize to be exactly
System.Platform.numBits. It defines the carriers as bitvectors of
these widths, their observations as toNat and toInt, and
Usize and Isize as the corresponding scalar kinds. Thus
this primitive, rather than an independently authored parser predicate, is
the missing width parameter. Lean's installed Init/Prelude.lean
describes getNumBits as the current platform's word size, deliberately
opaque to kernel reduction, and defines numBits as its value.
Its type guarantees only the disjunction 32 or 64; the displayed default
inhabitant is not a proof of the selected equality. The manifest-selected
Lean executable is independently identified as ELF64 x86-64, consistent with
the selected Rust target. The exact installed sources, hashes, and executable
identity are in
reference/model-evidence/source-valid-byte-slice.txt.
Consequently binding this platform parameter to the already-selected
pointer width 64 is a source-environment correspondence premise, not a new
Rust language claim that every target has width 64 and not a kernel proof
obtained by native evaluation.usize/isize. Fixed-width scalar kinds have
literal widths in the same definitions, so none is changed by this binding.
The installed casts continue to truncate or extend bitvectors, and the
installed checked constructors continue to return integer-overflow failure
outside their scalar bounds. No cast is replaced by a rejecting operation
and no failure branch is removed. The appendix in
reference/model-evidence/source-valid-byte-slice.txt retains
these definitions as well as the source and pinned extraction of
ByteSlice.offset_from. For example, two source-valid byte-slice
lengths are in [0,2^{63}-1]; their unsigned-to-signed 64-bit casts preserve
the lengths, and their difference lies in
[-(2^{63}-1),2^{63}-1], within the signed range. This explains the
relevant source/model width agreement; it assumes no scan invariant or
parser return property.Slice is a list with length at most Usize.max, now
2^{64}-1. For any represented source-valid contents, the same list of
bytes supplies a model slice because
2^{63}-1\leq 2^{64}-1; its length and every element are unchanged.
Conversely the source-validity predicate still excludes lengths above
2^{63}-1 even though the model carrier permits them. This is coverage of
the abstract contents of valid references, not an assertion that every
such size can be physically allocated. Substrings and sign-stripped bodies
retain the same length bound; UTF-8 is neither added to arbitrary helper
byte slices nor removed from strings.Authored arguments for individual requirements
Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
Assumptions · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Assumptions / kernel axioms
- Dec2Flt.P340_T1_selected_target_numBits
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:d1865645ac1dcc7b90db7bef9faa271d843f88af4c6383f8cb1eebd06618f0fa |
| Preservation current fingerprint | preservation-v1:d1865645ac1dcc7b90db7bef9faa271d843f88af4c6383f8cb1eebd06618f0fa |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"703fdc039358040248be22e211f0cff38cda1684a6865f51bd10221184deba9c","lean_semantic_closure":"a3572769dcde737b3a270a374fc4956c83b05bc09fa47935f18065d1e6c86197","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"703fdc039358040248be22e211f0cff38cda1684a6865f51bd10221184deba9c","lean_semantic_closure":"a3572769dcde737b3a270a374fc4956c83b05bc09fa47935f18065d1e6c86197","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "50e87928bb932a44836175a65ab6fce05eb64417094d84c09fb548c48e4cac6d",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:d1865645ac1dcc7b90db7bef9faa271d843f88af4c6383f8cb1eebd06618f0fa"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"Tablet/Assumptions.tex",
"committed_node_kinds / pv_tablet.json"
]
}
]Binary64Model
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.F64
import Tablet.core_num_FpCategory
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: Binary64Model]
structure Binary64Model where
-- BODY
clone : F64 -> Result F64
mantissaDigits : Result Std.U32
nan : Result F64
infinity : Result F64
negInfinity : Result F64
exponentMask : Result Std.U64
mantissaMask : Result Std.U64
classify : F64 -> Result core.num.FpCategory
toBits : F64 -> Result Std.U64
fromBits : Std.U64 -> Result F64
mul : F64 -> F64 -> Result F64
div : F64 -> F64 -> Result F64
neg : F64 -> Result F64
fromU64 : Std.U64 -> Result F64
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
inspect-native records in
reference/model-evidence/native-boundary.txt give the following
field-to-external correspondence, with the same argument order and result
type in every row:
clone to F64.Insts.CoreCloneClone.clone;
mantissaDigits to core.f64.F64.MANTISSA_DIGITS;
nan to core.f64.F64.NAN;
infinity to core.f64.F64.INFINITY;
negInfinity to core.f64.F64.NEG_INFINITY;
exponentMask to core.f64.F64.EXPONENT_MASK;
mantissaMask to core.f64.F64.MANTISSA_MASK;
classify to core.f64.F64.classify;
toBits to core.f64.F64.to_bits;
fromBits to core.f64.F64.from_bits;
mul to F64.Insts.CoreOpsArithMulF64F64.mul;
div to F64.Insts.CoreOpsArithDivF64F64.div;
neg to F64.Insts.CoreOpsArithNegF64.neg; and
fromU64 to
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64.
The frozen declarations are axioms with precisely those signatures, and the
structure has only these data-valued or function-valued fields: it has no
proposition-valued field and states no equation about any field's result.
Thus this node packages the frozen call surface without constraining an
implementation. Behavioral preservation is a separate obligation of the
corresponding ModelF64Clone, ModelF64MantissaDigits,
ModelF64Nan, ModelF64Infinity,
ModelF64NegInfinity, ModelF64ExponentMask,
ModelF64MantissaMask, ModelF64Classify,
ModelF64ToBits, ModelF64FromBits, ModelF64Mul,
ModelF64Div, ModelF64Neg, and
ModelF64FromU64 binding nodes, not a premise of this claim.Authored arguments for individual requirements
Requirement: parser totality
f64
specialization is retained with its frozen signatures. This package adds no
behavioral premise or input-domain restriction; normal-return behavior, where
needed, belongs separately to the fourteen ModelF64 owners listed in
the proof.Requirement: parser numeric acceptance
ModelF64 owner listed above.Requirement: parser invalid rejection
Requirement: parser nan acceptance
NAN, conditionally invokes
neg for a negative lexical sign, and uses classification to support
the required NaN observation. This package retains those three signatures
without asserting their results or restricting their domains; their behavior
belongs to ModelF64Nan, ModelF64Neg, and
ModelF64Classify.Requirement: parser infinity
INFINITY and then invokes
neg exactly when the lexical sign is negative; it does not request
NEG_INFINITY. This package retains the two executed signatures
without asserting their results or restricting their domains; their behavior
belongs to ModelF64Infinity and ModelF64Neg.Requirement: parser non nan results
classify signatures in the fourteen-external
surface are retained, without asserting which words they return or restricting
their inputs. Result behavior belongs to the corresponding operation owner,
and classification behavior belongs to ModelF64Classify.Requirement: parser numeric sign
from_bits while constructing their
magnitudes and invoke neg when applying a negative lexical sign; they
do not request either signed-infinity constant or to_bits. This
package retains the executed signatures without asserting sign behavior or
restricting their domains; behavior belongs to ModelF64FromBits and
ModelF64Neg.Requirement: parser signed zero
from_bits while constructing a zero
magnitude and invoke neg when applying a negative lexical sign; they
do not invoke to_bits. This package retains the executed signatures
without asserting a zero encoding or restricting their domains; behavior
belongs to ModelF64FromBits and ModelF64Neg.Requirement: parser exact rounding
mul, div, from_u64, and
from_bits signatures used by magnitude-conversion paths, together
with the neg signature used for a negative lexical sign, are retained
without an accuracy premise or domain restriction. Their behavior belongs to
ModelF64Mul, ModelF64Div, ModelF64FromU64,
ModelF64FromBits, and ModelF64Neg.Requirement: parser selected exponent
from_bits signatures remain
available to the specialized dispatcher and assembly path. This interface
adds no range premise or domain restriction; the concrete owners are
ModelF64MantissaDigits, ModelF64ExponentMask,
ModelF64MantissaMask, and ModelF64FromBits.Requirement: parser selected magnitude sign
to_bits, and from_bits signatures remain
available to the specialized conversion and assembly paths. This interface
adds no sign-bit premise or domain restriction; behavior belongs to
ModelF64ExponentMask, ModelF64MantissaMask,
ModelF64ToBits, and ModelF64FromBits.Requirement: dispatch abstract composition
f64 specialization is
retained. Because the package states neither component contracts nor
equations and restricts no input, it adds no behavioral premise to the
abstract composition claim; concrete behavior belongs to the corresponding
fourteen ModelF64 owners listed above.Requirement: dispatch component compliance
f64 components are extracted is retained. This package adds no
component-compliance premise or domain restriction; compliance of each
operation is the separate responsibility of its corresponding
ModelF64 owner listed above.Requirement: parser accumulated rounding
mul, div, from_u64, and
from_bits signatures used by magnitude conversion, together with the
neg signature used for a negative lexical sign, are retained. This
interface asserts no rounding or sign behavior and restricts no input; that
behavior belongs to ModelF64Mul, ModelF64Div,
ModelF64FromU64, ModelF64FromBits, and
ModelF64Neg.Requirement: parser equal target rounding
mul, div, from_u64, and
from_bits signatures used by magnitude conversion, together with the
neg signature used for a negative lexical sign, are retained; the
numeric source routes do not invoke to_bits. This interface adds no
target-equality premise or domain restriction; behavior belongs to
ModelF64Mul, ModelF64Div, ModelF64FromU64,
ModelF64FromBits, and ModelF64Neg.Requirement: number helper acceptance
parse_number call surface contains none of these fourteen
binary64 externals. Packaging their signatures therefore adds no acceptance
premise and no restriction on byte-slice inputs.Requirement: number helper rejection
parse_number call surface contains none of these fourteen
binary64 externals. Packaging their signatures therefore adds no rejection
premise and no restriction on byte-slice inputs.Requirement: number helper record bounds
parse_number call surface contains none of these fourteen
binary64 externals. Packaging their signatures therefore adds no record-field
premise and no restriction on byte-slice inputs.Requirement: number helper accumulated value
parse_number call surface contains none of these fourteen
binary64 externals. Packaging their signatures therefore adds no numeric-value
premise and no restriction on byte-slice inputs.Requirement: special helper infinity
parse_inf_nan source route requests INFINITY and then
invokes neg exactly when its separate sign argument is true; it does
not request NEG_INFINITY. This package retains the two executed
signatures without asserting their results or restricting slice or sign
inputs; their behavior belongs to ModelF64Infinity and
ModelF64Neg.Requirement: special helper nan
parse_inf_nan source route requests NAN and invokes
neg when its separate sign argument is true; classification supports
the required NaN observation. This package retains those three signatures
without asserting their results or restricting slice or sign inputs; their
behavior belongs to ModelF64Nan, ModelF64Neg, and
ModelF64Classify.Requirement: special helper rejection
parse_inf_nan branches invoke none of the fourteen
binary64 externals. Packaging their signatures therefore adds no
keyword-recognition premise and no restriction on slice or sign inputs.Requirement: native correct or defer
from_u64, from_bits, mul,
div, and neg signatures used by the native shortcut are
retained. This interface adds no correctness, deferral, or range premise;
behavior belongs to ModelF64FromU64, ModelF64FromBits,
ModelF64Mul, ModelF64Div, and ModelF64Neg.Requirement: integer correct or defer
ModelF64MantissaDigits, ModelF64ExponentMask,
ModelF64MantissaMask, ModelF64ToBits, and
ModelF64FromBits.Requirement: slow accumulated rounding
from_bits signatures available to
the slow conversion and eventual assembly are retained. This interface adds
no rounding premise or domain restriction; behavior belongs to
ModelF64MantissaDigits, ModelF64ExponentMask,
ModelF64MantissaMask, and ModelF64FromBits.Requirement: assembly correspondence
from_bits signature used by final assembly is retained.
This interface asserts no assembly equation and restricts no raw word;
construction behavior belongs to ModelF64FromBits.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
Binary64Model · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/native-boundary.txt
Current native boundary reconciliation (2026-10-09)
=================================================
generated.lean SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Commands:
python3 .trellis/scripts/pv_modeling.py inspect-native .
python3 .trellis/scripts/pv_modeling.py compose-native . --check
python3 .trellis/scripts/check.py model-support-check .
The current inventory has 24 declarations and the current support manifest
has 24 bindings. Structured comparison of name, extracted_signature,
rust_symbol and raw_declaration_sha256 returned zero mismatches. Composition
matches with no generated-file changes. Exact current full inventory:
[
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"source_utf8": "/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:\n Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43\n Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]\n Visibility: public -/\n@[rust_fun \"core::clone::impls::{core::clone::Clone<f64>}::clone\"]\naxiom F64.Insts.CoreCloneClone.clone : F64 → Result F64\n"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"source_utf8": "/-- [core::f64::{f64}::MANTISSA_DIGITS]\n Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34\n Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::MANTISSA_DIGITS\"]\naxiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32\n"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"source_utf8": "/-- [core::f64::{f64}::NAN]\n Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22\n Name pattern: [core::f64::{f64}::NAN]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::NAN\"] axiom core.f64.F64.NAN : Result F64\n"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"source_utf8": "/-- [core::f64::{f64}::INFINITY]\n Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27\n Name pattern: [core::f64::{f64}::INFINITY]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::INFINITY\"]\naxiom core.f64.F64.INFINITY : Result F64\n"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"source_utf8": "/-- [core::f64::{f64}::NEG_INFINITY]\n Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31\n Name pattern: [core::f64::{f64}::NEG_INFINITY]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::NEG_INFINITY\"]\naxiom core.f64.F64.NEG_INFINITY : Result F64\n"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"source_utf8": "/-- [core::f64::{f64}::EXPONENT_MASK]\n Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32\n Name pattern: [core::f64::{f64}::EXPONENT_MASK]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::EXPONENT_MASK\"]\naxiom core.f64.F64.EXPONENT_MASK : Result Std.U64\n"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"source_utf8": "/-- [core::f64::{f64}::MANTISSA_MASK]\n Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32\n Name pattern: [core::f64::{f64}::MANTISSA_MASK]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::MANTISSA_MASK\"]\naxiom core.f64.F64.MANTISSA_MASK : Result Std.U64\n"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"source_utf8": "/-- [core::f64::{f64}::classify]:\n Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45\n Name pattern: [core::f64::{f64}::classify]\n Visibility: public -/\n@[rust_fun \"core::f64::{f64}::classify\"]\naxiom core.f64.F64.classify : F64 → Result core.num.FpCategory\n"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"source_utf8": "/-- [core::f64::{f64}::to_bits]:\n Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37\n Name pattern: [core::f64::{f64}::to_bits]\n Visibility: public -/\n@[rust_fun \"core::f64::{f64}::to_bits\"]\naxiom core.f64.F64.to_bits : F64 → Result Std.U64\n"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"source_utf8": "/-- [core::f64::{f64}::from_bits]:\n Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42\n Name pattern: [core::f64::{f64}::from_bits]\n Visibility: public -/\n@[rust_fun \"core::f64::{f64}::from_bits\"]\naxiom core.f64.F64.from_bits : Std.U64 → Result F64\n"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 → Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b",
"source_utf8": "/-- [core::num::{u8}::is_ascii_digit]:\n Source: '/rustc/library/core/src/num/mod.rs', lines 958:4-958:46\n Name pattern: [core::num::{u8}::is_ascii_digit]\n Visibility: public -/\n@[rust_fun \"core::num::{u8}::is_ascii_digit\"]\naxiom core.num.U8.is_ascii_digit : Std.U8 → Result Bool\n"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"source_utf8": "/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:\n Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41\n Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]\n Visibility: public -/\n@[rust_fun \"core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul\"]\naxiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64\n"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"source_utf8": "/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:\n Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41\n Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]\n Visibility: public -/\n@[rust_fun \"core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div\"]\naxiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64\n"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"source_utf8": "/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:\n Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30\n Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]\n Visibility: public -/\n@[rust_fun \"core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg\"]\naxiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64\n"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"source_utf8": "/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:\n Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42\n Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]\n Visibility: public -/\n@[rust_fun \"core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand\"]\naxiom U64.Insts.CoreOpsBitBitAndU64U64.bitand\n : Std.U64 → Std.U64 → Result Std.U64\n"
},
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"source_utf8": "/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:\n Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41\n Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]\n Visibility: public -/\n@[rust_fun \"core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor\"]\naxiom U64.Insts.CoreOpsBitBitOrU64U64.bitor\n : Std.U64 → Std.U64 → Result Std.U64\n"
},
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"source_utf8": "/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:\n Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41\n Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]\n Visibility: public -/\n@[rust_fun \"core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl\"]\naxiom U64.Insts.CoreOpsBitShlU32U64.shl\n : Std.U64 → Std.U32 → Result Std.U64\n"
},
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"source_utf8": "/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:\n Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41\n Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]\n Visibility: public -/\n@[rust_fun \"core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr\"]\naxiom U64.Insts.CoreOpsBitShrU32U64.shr\n : Std.U64 → Std.U32 → Result Std.U64\n"
},
{
"name": "core.option.Option.Insts.CoreOpsTry_traitTry.branch",
"extracted_signature": "{T : Type} : Option T → Result (core.ops.control_flow.ControlFlow (Option core.convert.Infallible) T)",
"rust_symbol": "core::option::{impl core::ops::try_trait::Try for core::option::Option<T>}::branch",
"raw_declaration_sha256": "0bf9b9d904111c7989cfc386f7bf22bbc7b1b9fd128306025fc6fe3916ef2bcf",
"source_utf8": "/-- [core::option::{impl core::ops::try_trait::Try for core::option::Option<T>}::branch]:\n Source: '/rustc/library/core/src/option.rs', lines 2779:4-2779:64\n Name pattern: [core::option::{core::ops::try_trait::Try<core::option::Option<@T>>}::branch]\n Visibility: public -/\n@[rust_fun\n \"core::option::{core::ops::try_trait::Try<core::option::Option<@T>>}::branch\"]\naxiom core.option.Option.Insts.CoreOpsTry_traitTry.branch\n {T : Type} :\n Option T → Result (core.ops.control_flow.ControlFlow (Option\n core.convert.Infallible) T)\n"
},
{
"name": "core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual",
"extracted_signature": "(T : Type) : Option core.convert.Infallible → Result (Option T)",
"rust_symbol": "core::option::{impl core::ops::try_trait::FromResidual<core::option::Option<core::convert::Infallible>> for core::option::Option<T>}::from_residual",
"raw_declaration_sha256": "4c10afcd703d980e458ca8e8ce2ecf1d0c415721467b76953e9223648ea5106c",
"source_utf8": "/-- [core::option::{impl core::ops::try_trait::FromResidual<core::option::Option<core::convert::Infallible>> for core::option::Option<T>}::from_residual]:\n Source: '/rustc/library/core/src/option.rs', lines 2793:4-2793:67\n Name pattern: [core::option::{core::ops::try_trait::FromResidual<core::option::Option<@T>, core::option::Option<core::convert::Infallible>>}::from_residual]\n Visibility: public -/\n@[rust_fun\n \"core::option::{core::ops::try_trait::FromResidual<core::option::Option<@T>, core::option::Option<core::convert::Infallible>>}::from_residual\"]\naxiom\n core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual\n (T : Type) : Option core.convert.Infallible → Result (Option T)\n"
},
{
"name": "core.slice.Slice.first",
"extracted_signature": "{T : Type} : Slice T → Result (Option T)",
"rust_symbol": "core::slice::{[T]}::first",
"raw_declaration_sha256": "221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105",
"source_utf8": "/-- [core::slice::{[T]}::first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43\n Name pattern: [core::slice::{[@T]}::first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::first\"]\naxiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)\n"
},
{
"name": "core.slice.Slice.split_first",
"extracted_signature": "{T : Type} : Slice T → Result (Option (T × (Slice T)))",
"rust_symbol": "core::slice::{[T]}::split_first",
"raw_declaration_sha256": "f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49",
"source_utf8": "/-- [core::slice::{[T]}::split_first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57\n Name pattern: [core::slice::{[@T]}::split_first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::split_first\"]\naxiom core.slice.Slice.split_first\n {T : Type} : Slice T → Result (Option (T × (Slice T)))\n"
},
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"source_utf8": "/-- [core::str::{str}::as_bytes]:\n Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41\n Name pattern: [core::str::{str}::as_bytes]\n Visibility: public -/\n@[rust_fun \"core::str::{str}::as_bytes\"]\naxiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)\n"
},
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"source_utf8": "/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:\n Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5\n Visibility: public -/\naxiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64\n : Std.U64 → Result F64\n"
}
]
Exact current support owner table:
[
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 → Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b",
"node": "ModelU8IsAsciiDigit",
"declaration": "dec2flt_model.ModelU8IsAsciiDigit"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
},
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
},
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
},
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
},
{
"name": "core.option.Option.Insts.CoreOpsTry_traitTry.branch",
"extracted_signature": "{T : Type} : Option T → Result (core.ops.control_flow.ControlFlow (Option core.convert.Infallible) T)",
"rust_symbol": "core::option::{impl core::ops::try_trait::Try for core::option::Option<T>}::branch",
"raw_declaration_sha256": "0bf9b9d904111c7989cfc386f7bf22bbc7b1b9fd128306025fc6fe3916ef2bcf",
"node": "ModelOptionBranch",
"declaration": "dec2flt_model.ModelOptionBranch"
},
{
"name": "core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual",
"extracted_signature": "(T : Type) : Option core.convert.Infallible → Result (Option T)",
"rust_symbol": "core::option::{impl core::ops::try_trait::FromResidual<core::option::Option<core::convert::Infallible>> for core::option::Option<T>}::from_residual",
"raw_declaration_sha256": "4c10afcd703d980e458ca8e8ce2ecf1d0c415721467b76953e9223648ea5106c",
"node": "ModelOptionFromResidual",
"declaration": "dec2flt_model.ModelOptionFromResidual"
},
{
"name": "core.slice.Slice.first",
"extracted_signature": "{T : Type} : Slice T → Result (Option T)",
"rust_symbol": "core::slice::{[T]}::first",
"raw_declaration_sha256": "221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105",
"node": "ModelSliceFirst",
"declaration": "dec2flt_model.ModelSliceFirst"
},
{
"name": "core.slice.Slice.split_first",
"extracted_signature": "{T : Type} : Slice T → Result (Option (T × (Slice T)))",
"rust_symbol": "core::slice::{[T]}::split_first",
"raw_declaration_sha256": "f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49",
"node": "ModelSliceSplitFirst",
"declaration": "dec2flt_model.ModelSliceSplitFirst"
},
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"node": "ModelStrAsBytes",
"declaration": "dec2flt_model.ModelStrAsBytes"
},
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
]
The following older boundary evidence is retained for reproducibility of
unchanged declaration/primitive meanings; the current identities above govern.
Native boundary inventory for Binary64Model
Reproduction command (repository root):
python3 .trellis/scripts/pv_modeling.py inspect-native .
Tool identity for this reproduction:
Python 3.14.4
.trellis/scripts/pv_modeling.py
sha256 915b29822cb4c47b70dabb1dc011514641deb2e428b62347fc31aa898de5e0d4
Top-level result:
declaration_count: 24
The complete raw inspect-native records for the fourteen F64 externals follow.
They are copied from the command's complete index; no scratch artifact is needed
to review them.
[
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"source_utf8": "/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:\n Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43\n Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]\n Visibility: public -/\n@[rust_fun \"core::clone::impls::{core::clone::Clone<f64>}::clone\"]\naxiom F64.Insts.CoreCloneClone.clone : F64 → Result F64\n"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"source_utf8": "/-- [core::f64::{f64}::MANTISSA_DIGITS]\n Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34\n Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::MANTISSA_DIGITS\"]\naxiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32\n"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"source_utf8": "/-- [core::f64::{f64}::NAN]\n Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22\n Name pattern: [core::f64::{f64}::NAN]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::NAN\"] axiom core.f64.F64.NAN : Result F64\n"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"source_utf8": "/-- [core::f64::{f64}::INFINITY]\n Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27\n Name pattern: [core::f64::{f64}::INFINITY]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::INFINITY\"]\naxiom core.f64.F64.INFINITY : Result F64\n"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"source_utf8": "/-- [core::f64::{f64}::NEG_INFINITY]\n Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31\n Name pattern: [core::f64::{f64}::NEG_INFINITY]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::NEG_INFINITY\"]\naxiom core.f64.F64.NEG_INFINITY : Result F64\n"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"source_utf8": "/-- [core::f64::{f64}::EXPONENT_MASK]\n Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32\n Name pattern: [core::f64::{f64}::EXPONENT_MASK]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::EXPONENT_MASK\"]\naxiom core.f64.F64.EXPONENT_MASK : Result Std.U64\n"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"source_utf8": "/-- [core::f64::{f64}::MANTISSA_MASK]\n Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32\n Name pattern: [core::f64::{f64}::MANTISSA_MASK]\n Visibility: public -/\n@[rust_const \"core::f64::{f64}::MANTISSA_MASK\"]\naxiom core.f64.F64.MANTISSA_MASK : Result Std.U64\n"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"source_utf8": "/-- [core::f64::{f64}::classify]:\n Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45\n Name pattern: [core::f64::{f64}::classify]\n Visibility: public -/\n@[rust_fun \"core::f64::{f64}::classify\"]\naxiom core.f64.F64.classify : F64 → Result core.num.FpCategory\n"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"source_utf8": "/-- [core::f64::{f64}::to_bits]:\n Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37\n Name pattern: [core::f64::{f64}::to_bits]\n Visibility: public -/\n@[rust_fun \"core::f64::{f64}::to_bits\"]\naxiom core.f64.F64.to_bits : F64 → Result Std.U64\n"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"source_utf8": "/-- [core::f64::{f64}::from_bits]:\n Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42\n Name pattern: [core::f64::{f64}::from_bits]\n Visibility: public -/\n@[rust_fun \"core::f64::{f64}::from_bits\"]\naxiom core.f64.F64.from_bits : Std.U64 → Result F64\n"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"source_utf8": "/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:\n Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41\n Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]\n Visibility: public -/\n@[rust_fun \"core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul\"]\naxiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64\n"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"source_utf8": "/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:\n Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41\n Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]\n Visibility: public -/\n@[rust_fun \"core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div\"]\naxiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64\n"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"source_utf8": "/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:\n Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30\n Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]\n Visibility: public -/\n@[rust_fun \"core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg\"]\naxiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64\n"
},
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"source_utf8": "/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:\n Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5\n Visibility: public -/\naxiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64\n : Std.U64 → Result F64\n"
}
]
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:60e424c526afc857f5042fa630ecd9ac3452f1fb64a1258de3ac1dc60009d9cc |
| Preservation current fingerprint | preservation-v1:60e424c526afc857f5042fa630ecd9ac3452f1fb64a1258de3ac1dc60009d9cc |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","lean_semantic_closure":"152e7ea8c8bb655433fccf89dbab1745cb5f3c97fe281f41f1bd44819985f50c","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","lean_semantic_closure":"152e7ea8c8bb655433fccf89dbab1745cb5f3c97fe281f41f1bd44819985f50c","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "712772e599ddeea35e5f3732ca8d9797e146b91d7498dd896788d45f617643f3",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:60e424c526afc857f5042fa630ecd9ac3452f1fb64a1258de3ac1dc60009d9cc"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/native-boundary.txt",
"sha256": "7b2fc9baa7df05ab14348d92ed1d9b5cc56891085326ab910755369ced180c2b",
"cited_by": [
"Tablet/Binary64Model.tex",
"committed_node_kinds / pv_tablet.json"
]
}
]Binary64ModelDefault
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.Binary64Model
import Mathlib.Data.Rat.Defs
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 4096
namespace dec2flt_model
-- [TABLET NODE: Binary64ModelDefault]
def Binary64ModelDefault : Binary64Model :=
-- BODY
let signBit : Nat := 2 ^ 63
let fractionUnit : Nat := 2 ^ 52
let infinityBits : Nat := 2047 * fractionUnit
let quietNanBits : Nat := infinityBits + 2 ^ 51
let word := fun n : Nat => (⟨BitVec.ofNat 64 n⟩ : Std.U64)
let sign := fun w : F64 => w.val / signBit
let magnitude := fun w : F64 => w.val % signBit
let exponent := fun w : F64 => magnitude w / fractionUnit
let fraction := fun w : F64 => magnitude w % fractionUnit
let categoryCode := fun w : F64 =>
if exponent w = 2047 then
if fraction w = 0 then 1 else 0
else if exponent w = 0 then
if fraction w = 0 then 2 else 3
else 4
let category := fun w : F64 =>
match categoryCode w with
| 0 => core.num.FpCategory.Nan
| 1 => core.num.FpCategory.Infinite
| 2 => core.num.FpCategory.Zero
| 3 => core.num.FpCategory.Subnormal
| _ => core.num.FpCategory.Normal
let finiteMagnitudeValue := fun bits : Nat =>
let e := bits / fractionUnit
let m := bits % fractionUnit
if e = 0 then
(m : Rat) / ((2 : Rat) ^ (1074 : Nat))
else if 1075 <= e then
((fractionUnit + m : Nat) : Rat) * ((2 : Rat) ^ (e - 1075))
else
((fractionUnit + m : Nat) : Rat) / ((2 : Rat) ^ (1075 - e))
let roundEvenNat := fun x : Rat =>
let q := x.num.natAbs / x.den
let r := x.num.natAbs % x.den
if x.den < 2 * r ∨ (x.den = 2 * r ∧ q % 2 = 1) then q + 1 else q
let normalExponent := fun x : Rat =>
(List.range 2046).foldl (fun (old : Nat) (i : Nat) =>
let e : Nat := i + 1
if ((2 : Rat) ^ ((e : Int) - 1023)) ≤ x then e else old) 1
let overflowThreshold : Rat :=
((2 : Rat) ^ (1024 : Nat)) - ((2 : Rat) ^ (970 : Nat))
let roundMagnitude := fun x : Rat =>
if overflowThreshold <= x then infinityBits
else if x < ((2 : Rat) ^ (-1022 : Int)) then
roundEvenNat (x * ((2 : Rat) ^ (1074 : Nat)))
else
let e := normalExponent x
let significand := roundEvenNat (x * ((2 : Rat) ^ ((1075 : Int) - (e : Int))))
if significand = 2 ^ 53 then (e + 1) * fractionUnit
else e * fractionUnit + (significand - fractionUnit)
let signedWord := fun negative : Bool => fun mag : Nat =>
word (mag + if negative then signBit else 0)
let negativeResult := fun a b : F64 => decide (sign a != sign b)
let mulImpl := fun a b : F64 =>
let ca := categoryCode a
let cb := categoryCode b
let negResult := negativeResult a b
if ca = 0 ∨ cb = 0 then ok (word quietNanBits)
else if (ca = 1 ∧ cb = 2) ∨ (ca = 2 ∧ cb = 1) then
ok (word quietNanBits)
else if ca = 1 ∨ cb = 1 then
ok (signedWord negResult infinityBits)
else
let x := finiteMagnitudeValue (magnitude a)
let y := finiteMagnitudeValue (magnitude b)
ok (signedWord negResult (roundMagnitude (x * y)))
let divImpl := fun a b : F64 =>
let ca := categoryCode a
let cb := categoryCode b
let negResult := negativeResult a b
if ca = 0 ∨ cb = 0 then ok (word quietNanBits)
else if (ca = 1 ∧ cb = 1) ∨ (ca = 2 ∧ cb = 2) then
ok (word quietNanBits)
else if ca = 1 ∨ cb = 2 then
ok (signedWord negResult infinityBits)
else if cb = 1 ∨ ca = 2 then
ok (signedWord negResult 0)
else
let x := finiteMagnitudeValue (magnitude a)
let y := finiteMagnitudeValue (magnitude b)
ok (signedWord negResult (roundMagnitude (x / y)))
{
clone := fun x => ok x
mantissaDigits := ok 53#u32
nan := ok (word quietNanBits)
infinity := ok (word infinityBits)
negInfinity := ok (word (signBit + infinityBits))
exponentMask := ok (word infinityBits)
mantissaMask := ok (word (fractionUnit - 1))
classify := fun x => ok (category x)
toBits := fun x => ok x
fromBits := fun x => ok x
mul := mulImpl
div := divImpl
neg := fun x => ok ⟨x.bv ^^^ BitVec.ofNat 64 signBit⟩
fromU64 := fun x =>
if x.val <= 2 ^ 53 then
ok (word (roundMagnitude (x.val : Rat)))
else fail .assertionFailure
}
end dec2flt_model
Why this model is faithful
Definition
u64 succeeds with this exact rounding when the input is at most
2^{53} and reports assertion failure otherwise.Preservation argument
Claim
from_u64 debug
assertion and its exact cast result on the asserted domain.Proof
word uses
BitVec.ofNat 64, so it takes the low 64 bits exactly. Division and
remainder by 2^{63} split bit 63 from the lower 63 bits. Division and
remainder of that magnitude by 2^{52} then split the eleven exponent bits
from the 52 fraction bits. Consequently exponent field 2047 with zero
fraction is infinity and with nonzero fraction is NaN; exponent zero with zero
fraction is zero and with nonzero fraction is subnormal; every other exponent
is normal. These are exactly the five arms of the pinned source
classify body.clone returns its input word. This is the exact frozen scalar
Clone::clone body, *self.
2. mantissaDigits returns 53, the pinned
f64::MANTISSA_DIGITS declaration.
3. nan returns \mathtt{0x7ff8000000000000}. The restored source
reference/model-evidence/binary64-probe.rs actually evaluates
bits("nan", f64::NAN), not a separately chosen NaN word.
Compilation with the pinned nightly-2026-06-01 rustc for
x86_64-unknown-linux-gnu at opt-level=0, and execution
of that binary, both exit zero and reproduce
nan=7ff8000000000000; the exact commands, compiler and source
hashes, full raw output, and current core.f64.F64.NAN binding are
in reference/model-evidence/P89_T2_current-applicability.txt.
The package therefore agrees exactly with this constant in the selected
environment. The arithmetic-NaN rules alone do not fix that constant's
sign, and no fixed bits are claimed for arbitrary arithmetic NaNs.
4. infinity returns \mathtt{0x7ff0000000000000}, exactly the probed
source constant.
5. negInfinity adds bit 63 to that word and therefore returns
\mathtt{0xfff0000000000000}, exactly the probed negative-infinity
constant.
6. exponentMask is the pinned eleven-bit mask
\mathtt{0x7ff0000000000000}.
7. mantissaMask is 2^{52}-1, namely the pinned mask
\mathtt{0x000fffffffffffff}.
8. By the initial field split, classify's nested tests are exactly
the five source match arms, for every one of the 2^{64} words.
9. toBits is the identity on the raw-word carrier, matching the
source transmutation for every word, including every NaN payload.
10. fromBits is the same identity in the other direction, matching
the inverse source transmutation and preserving every input bit.SIG_TOTAL_BITS to f64::MANTISSA_DIGITS, then derive
SIG_BITS as 53-1=52, EXP_BITS as 64-52-1=11,
EXP_SAT and INFINITE_POWER as 2047,
EXP_BIAS as 1023, and EXP_MIN as -1022. The
Lemire default similarly derives
MAX_MANTISSA_FAST_PATH as 1\ll53=2^{53}. Thus the same
preserved field fixes the precision, exponent, overflow, native-cast guard,
and final-assembly shift used by the frozen generic bodies.finiteMagnitudeValue's three exponent-sign cases.roundEvenNat's disjunction selects the
nearest integer, choosing the even integer on every tie. The r=0 case
returns q unchanged.overflowThreshold. Below
it, exponent 2046 rounds at most to the maximum finite significand. At the
boundary and above it, the pinned Rust round-to-even overflow rule specifies
infinity. Thus the explicit comparison implements the source rule on both
sides and at the midpoint.mul, let N, I, Z, and F denote NaN, infinity, zero, and
finite nonzero. If either operand is N, the exact result class is NaN.
I times Z (in either order) is also NaN. I times I or F is infinity.
Otherwise both operands are finite; the package multiplies their exact
nonnegative rational magnitudes and applies the proved encoder. This last
row includes Z times Z or F and hence returns zero. Every non-NaN row
applies the xor of operand sign bits, so infinity, ordinary results,
underflowed results, and zero all have the Rust-prescribed sign.
12. For div, either NaN operand gives NaN; I divided by I and Z
divided by Z give NaN. I divided by Z or F, and F divided by Z, give
signed infinity. F divided by F uses the exact rational quotient and the
proved encoder. F or Z divided by I, and Z divided by F, give signed
zero. These cases are exhaustive and occur in exactly the order of the
definition, so the denominator reaches rational division only in the
finite-nonzero row. Again every non-NaN row uses the xor sign.can_use_fast_path guard and call body in
reference/model-evidence/binary64-boundary.txt, with the field-2
derivation above, give the ordinary path a from_u64 argument at
most 2^{53} and a table index in 0\ldots22: a negative exponent lies in
-22\ldots-1 and is negated for the index, while a nonnegative exponent is at
most 22. On the disguised path the checked integer product must pass the
explicit \leq2^{53} test before from_u64, and the table index is
exactly 22. Only after deriving those hypotheses from the source guards do
we apply Binary64NativeCallDomain: each cast operand and table word
is finite and non-NaN, every table word is positive and nonzero, and hence an
executed division has a nonzero divisor. Therefore the actual native calls
use only fields 11 and 12's exact rational, signed-zero, or infinity rows.
The support theorem is conditional and is not itself cited as a source
reachability assertion.neg xors bit 63 and leaves all other 63 bits fixed. The concrete
pinned Neg for f64 implementation is -self, as recorded
in reference/model-evidence/binary64-negation.txt.
The restored qualified-trait source
reference/model-evidence/binary64-negation-probe.rs takes an
arbitrary u64 word w, applies that method to
f64::from_bits(w), and returns to_bits().
Its current reproduction and exact external binding are in
reference/model-evidence/P89_T2_current-applicability.txt.
In the emitted x86_64 C-ABI function, w arrives in rdi;
movabsq loads the bit-63 mask
\mathtt{0x8000000000000000} into rax; xorq combines
those words; and retq returns rax. There is no branch,
NaN exception, quieting, or input restriction. Thus the source operation
returns w\mathbin{\mathsf{xor}}2^{63} for every one of the 2^{64}
words, including every signaling and quiet NaN payload. This proves
actual sign toggling, not just preservation of non-sign bits, and agrees
with the package's ok xor result without borrowing another
owner's preservation proof.
14. Finally, fromU64 tests the exact source debug assertion
v\leq2^{53}. In that branch every integer is exactly representable, and
the proved encoder returns its exact cast word. Above the bound, both the
frozen debug build and the model report assertion failure before a cast.Authored arguments for individual requirements
Requirement: parser totality
from_u64
debug assertion. For an ordinary native call, the frozen guard gives the
original mantissa \leq2^{53}; for a disguised call, the checked product must
pass the same bound before the cast. Applying the conditional first clause of
Binary64NativeCallDomain then makes each actual cast succeed. Field
2 fixes both this bound and all precision constants used by the integer, slow,
and assembly routes, whose relevant operations are total at this boundary.
Thus this model introduces no additional panic or divergence into the source
executions quantified by the goal. This application concerns preservation,
not whether other source checked arithmetic makes the positive GOAL true.Requirement: parser numeric acceptance
Requirement: parser invalid rejection
parse_number on the unsigned body, and calls parse_inf_nan
only when parse_number returns None. If the special helper
also returns None, the dispatcher returns Err before any
native call, raw-pair production, from_bits, arithmetic, or negation.
On the two successful branches, fields 3--4 and 13 reproduce the special
constant and conditional negation, while fields 2 and 10--14 reproduce the
numeric boundary operations after dispatch. This establishes only
operation-level preservation along every dispatcher branch; it does not infer
the positive invalid-rejection conclusion from this package model.Requirement: parser nan acceptance
NAN and then conditionally applies
unary negation, as recorded in
reference/model-evidence/binary64-boundary.txt. Field 3 supplies
the pinned NaN word, field 13 changes only its sign bit, and field 8 recognizes
either word as NaN. No arithmetic-NaN bit claim is used.Requirement: parser infinity
INFINITY and conditionally
negates it; it does not select NEG_INFINITY directly. Fields 4 and
13 therefore give exactly the infinity with the lexical sign. The source
route is copied in
reference/model-evidence/binary64-boundary.txt.Requirement: parser non nan results
Requirement: parser numeric sign
from_u64, table from_bits, arithmetic,
and conditional negation in their source order. On the integer and slow
paths, field 2 fixes SIG_BITS, EXP_MIN, and
INFINITE_POWER while producing the raw pair; field 10 reproduces
from_bits on its unrestricted assembled word, and field 13 reproduces
the subsequent conditional sign-bit toggle. Those exact routes are recorded
in reference/model-evidence/binary64-boundary.txt. No field fact
shows that an integer- or slow-selected word already has a clear sign bit; that
is precisely the still-unresolved parser_selected_magnitude_sign
obligation, so it is not used here to conclude the positive numeric-sign GOAL.Requirement: parser signed zero
parser_selected_magnitude_sign. Accordingly this application does
not derive the positive signed-zero GOAL from boundary preservation alone.Requirement: parser exact rounding
compute_float
and parse_long_mantissa; their selected raw pair is assembled by
field 10 and optionally negated by field 13. This covers the boundary
operations on every route while leaving the source parser's positive exactness
claim unchanged; predecessor counterexamples are diagnostic evidence, not a
classification of this revised obligation.Requirement: parser selected exponent
BiasedFp. Before
that selection, compute_float and any invoked
parse_long_mantissa execute SIG_BITS,
EXP_MIN, and INFINITE_POWER; field 2 and the exact trait
defaults derive their values 52, -1022, and 2047. Field 10 then
interprets the selected pair's assembled word and field 13 may negate it.
These source bodies are copied in
reference/model-evidence/binary64-boundary.txt, so the model
preserves the constants that can affect the selected exponent without
assuming that the positive range claim holds.Requirement: parser selected magnitude sign
SIG_BITS value 52 before field 10 interprets the OR/shift word;
identity from_bits preserves its sign bit, and later lexical
negation is a separate field-13 operation. This ordering and the executed
constant uses are recorded in
reference/model-evidence/binary64-boundary.txt, so the model does
not assume that the selected magnitude is well formed. In particular, none of
these operation-equivalence facts proves that the selected pre-negation word's
sign bit is clear; that remains exactly the positive GOAL obligation.Requirement: dispatch abstract composition
Requirement: dispatch component compliance
MAX_MANTISSA_FAST_PATH for those guards and supplies
SIG_BITS, EXP_MIN, and INFINITE_POWER to both
the integer and slow pair producers. Field 2's shift value and field 10 cover
final assembly, followed by conditional field 13. Finally, the special
component selects field 3 or 4 for NAN or INFINITY and may
apply field 13, with field 8 preserving the resulting category observation.
Thus the package supplies the operation meanings for native,
integer, slow, assembly, and special components without assuming that the
broader positive compliance theorem is true.Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper returns an optional
Decimal; it has no type parameter or float operation, as recorded in
reference/model-evidence/binary64-boundary.txt. This entire
binary64 package is therefore noninterfering with helper acceptance.Requirement: number helper rejection
parse_number
performs no binary64 constant, conversion, classification, or arithmetic call.
The package cannot affect its None results, without implying that all
source-invalid slices return normally.Requirement: number helper record bounds
Decimal record before any dispatcher
float conversion. Its exact source boundary is recorded in
reference/model-evidence/binary64-boundary.txt; consequently no
field of this package can alter its Boolean, mantissa, or exponent fields.Requirement: number helper accumulated value
parse_number,
whose source boundary uses no float operation; see
reference/model-evidence/binary64-boundary.txt. Binary64
rounding occurs only after the helper returns, so this package is genuinely
noninterfering with the stated helper value relation.Requirement: special helper infinity
INFINITY and conditionally negates it.
Fields 4 and 13 reproduce those exact calls and bits for either sign argument;
the source excerpt is in
reference/model-evidence/binary64-boundary.txt.Requirement: special helper nan
NAN constant and conditionally negates
it. Fields 3, 13, and 8 ensure either returned word is classified NaN. This
uses the exact bitwise NaN rules, not an assertion about arithmetic NaN bits;
see reference/model-evidence/binary64-boundary.txt.Requirement: special helper rejection
None from its unmatched branch before selecting a
float constant or invoking negation. The exact match and return structure is
in reference/model-evidence/binary64-boundary.txt. Thus no field
of this package is invoked on that branch; this operation-level fact does not
itself characterize which byte slices reach the unmatched branch.Requirement: native correct or defer
MAX_MANTISSA_FAST_PATH as 2^{53}. On the ordinary path, the
guard bounds the original mantissa by that value and bounds the negated or
nonnegative exponent table index by 22. On the disguised path, checked
integer multiplication occurs first, the resulting mantissa must pass the
2^{53} comparison, and the table index is exactly 22. Applying the two
conditional clauses of Binary64NativeCallDomain after these source
derivations gives a successful finite cast, a finite nonzero table word, and
hence a nonzero divisor. Fields 14 and 10 then reproduce the cast and table
from_bits; fields 11 or 12 reproduce multiplication or division;
and field 13 reproduces the final optional negation. The exact guards and
calls are in reference/model-evidence/binary64-boundary.txt.Requirement: integer correct or defer
compute_float operation produces a raw
BiasedFp; it does not call from_u64, multiplication,
division, or negation, but it does execute SIG_BITS,
EXP_MIN, and INFINITE_POWER while computing that pair.
Field 2 plus the exact trait defaults give these constants as 52, -1022,
and 2047. If the pair is later assembled, the field-2-derived shift 52
forms its word and identity field 10 preserves the unrestricted result. The
exact body is recorded in
reference/model-evidence/binary64-boundary.txt; no false native
cast-domain claim is used for this GOAL.Requirement: slow accumulated rounding
parse_long_mantissa body uses
INFINITE_POWER, EXP_MIN, and SIG_BITS in its
overflow tests, scaling, rounding, and returned pair. Field 2 and the trait
defaults fix them as 2047, -1022, and 52. Final assembly uses the same
derived shift, then invokes field 10 on the unrestricted word and field 13 for
the conditional sign-bit toggle. These operations are copied in
reference/model-evidence/binary64-boundary.txt; this application
preserves their meanings without assuming a clear pre-negation sign bit or the
positive rounding conclusion.Requirement: assembly correspondence
F::SIG_BITS, ORs it with the mantissa, and passes the low-64-bit word
to from_bits. Field 2, SIG_TOTAL_BITS, and the exact
trait default derive this shift as 52; field 10 is the identity on every
word, with no field-validity precondition. The exact body in
reference/model-evidence/binary64-boundary.txt therefore agrees
with the goal's unrestricted Rust cast/shift/OR operation for all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Real. Neither that relation nor the principal theorem statement
calls this package's rational encoder. The model computation is
therefore noninterfering with the full real domain; the rational proof above is
not substituted for the GOAL.Requirement: rounding determinism
Requirement: exponent value agreement
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
Binary64ModelDefault · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T2_current-applicability.txt
Current applicability of reused binary64 and U64 preservation evidence
Task 11 / worker request 118; checked in the current private checkout.
All commands below ran in this assignment; EXIT records the command status.
Rust commands use LD_LIBRARY_PATH=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib
and RUSTUP_TOOLCHAIN=nightly-2026-06-01.
The managed Lean commands are recorded separately, not invoked by this script.
Reuse and scope
===============
Read-only predecessor: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002
The historical 45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
generated.lean hash belongs to that predecessor, never the current extraction.
The old primary evidence retains its original commands, raw identities and results.
Current checks below establish applicability; prior worker task 9 was rejected,
accepted=false, and its self-report is neither publication nor certification.
Only preservation sections of the six listed owners and ten reserved evidence paths
are submitted. No ordinary statement, Lean computation, GOAL pair, source, extraction,
provenance, Preamble, binding, dispatcher owner or existing config delta is edited.
No new node, route, under-model premise, GOAL decline or polarity change is proposed.
The new 2^59 exponent fold, final-point repair and A/B GOAL domains are not old semantics.
Unchanged primitive meanings are reused, not old parser correctness or old counterexamples.
{
"task_execution": {
"binding": {
"allowed_tasks": [
"ordinary",
"lean_closure"
],
"lightweight": false,
"max_timeout_seconds": 14400,
"model": "gpt-6.1-sol",
"provider": "codex",
"reasoning_effort": "xhigh",
"timeout_seconds": 14400
},
"compiler": "managed",
"profile": "sol-xhigh",
"task_id": 11,
"task_kind": "ordinary"
},
"acceptance_logic_identity": "trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91",
"parallel_scope": {
"exclusive": true,
"helper_prefixes": [
"P116_T1_"
],
"nodes": [
"Binary64ModelDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"shared_writes": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
]
}
}
Current file, compiler, configuration and library identities
============================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum GOAL.md generated.lean Tablet/model-support.json modeling-input/manifest.json modeling-input/extraction.json modeling-input/tool-identities.json modeling-input/SETUP.md modeling-input/revision-from.json crate/Cargo.toml crate/rust-toolchain.toml lean-toolchain lakefile.lean lake-manifest.json trellis.config.json reference/model-evidence/binary64-boundary.txt crate/dec2flt/common.rs crate/dec2flt/decimal.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/fpu.rs crate/dec2flt/lemire.rs crate/dec2flt/mod.rs crate/dec2flt/parse.rs crate/dec2flt/slow.rs crate/dec2flt/table.rs crate/lib.rs crate/num/imp/mod.rs crate/num/mod.rs crate/traits.rs upstream/dec2flt/common.rs upstream/dec2flt/decimal.rs upstream/dec2flt/decimal_seq.rs upstream/dec2flt/fpu.rs upstream/dec2flt/lemire.rs upstream/dec2flt/mod.rs upstream/dec2flt/parse.rs upstream/dec2flt/slow.rs upstream/dec2flt/table.rs upstream/traits.rs reference/model-evidence/binary64-probe.rs reference/model-evidence/binary64-negation-probe.rs reference/model-evidence/u64-shl-probe.rs reference/model-evidence/u64-shr-probe.rs Tablet/Binary64ModelDefault.lean Tablet/ModelF64Neg.lean Tablet/ModelU64BitAnd.lean Tablet/ModelU64BitOr.lean Tablet/ModelU64Shl.lean Tablet/ModelU64Shr.lean
EXIT: 0
STDOUT:
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
1a7d2eea7888b7bdb0421ed6bb96c5ee1e80afe8e788438cd30725f2120a2aea modeling-input/revision-from.json
10584b73664d42dc85fb009bb0783a616520c2cc05f3b0f8c64e5d5cb32e2905 crate/Cargo.toml
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
8dab550b59cec828a4ba436bc25ce9ad66547bdd7f55899b8cbf7e4f65389518 lakefile.lean
a5f9756cd42129193c0285127cddb734224e9c69686fc2de56de2c9d48ed0695 lake-manifest.json
d8fceb13f84ecbf5bf6e9fd7ecdcb061569cfabdb0079243e2eb1609d012ac02 trellis.config.json
749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e reference/model-evidence/binary64-boundary.txt
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b crate/lib.rs
df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1 crate/num/imp/mod.rs
d84067991b142196281bc0968d32634bdcdb9a3a41c2ce2fd3c344d0f61504af crate/num/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e reference/model-evidence/binary64-probe.rs
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8 reference/model-evidence/u64-shl-probe.rs
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee reference/model-evidence/u64-shr-probe.rs
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3 Tablet/Binary64ModelDefault.lean
9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2 Tablet/ModelF64Neg.lean
3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179 Tablet/ModelU64BitAnd.lean
aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f Tablet/ModelU64BitOr.lean
af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad Tablet/ModelU64Shl.lean
54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b Tablet/ModelU64Shr.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo /home/leanagent/pv_spike/tools/charon/bin/charon /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
EXIT: 0
STDOUT:
54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade /home/leanagent/pv_spike/tools/charon/bin/charon
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
STDERR:
(empty)
All installed tool hashes equal the current tool-identities.json pins.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
EXIT: 0
STDOUT:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print cfg --target x86_64-unknown-linux-gnu
EXIT: 0
STDOUT:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat crate/Cargo.toml modeling-input/extraction.json
EXIT: 0
STDOUT:
# Standalone extraction package for the supplied `core::num::dec2flt` slice.
# The package metadata and profiles select the configured environment; source
# correspondence and extraction adaptations are recorded in ../SETUP.md and
# local preservation comments.
[package]
name = "dec2flt-model"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
path = "lib.rs"
[features]
default = []
optimize_for_size = []
[profile.dev]
overflow-checks = true
[profile.release]
overflow-checks = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(target_has_reliable_f16)"] }
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
STDERR:
(empty)
Current effective tools:
{
"aeneas": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"cargo": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"charon": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"env": {
"LD_LIBRARY_PATH": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib",
"RUSTUP_TOOLCHAIN": "nightly-2026-06-01"
},
"lean": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"lean_paths": [
"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean"
],
"readonly": [
"/home/leanagent/pv_spike/tools",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages"
],
"timeouts": {
"aeneas": 3600,
"cargo": 600,
"charon": 600,
"lean": 3600
}
}
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
EXIT: 0
STDOUT:
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
EXIT: 0
STDOUT:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
100644 blob f8582928fe49a0ce75e143b46bb0a8826d7fddae backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
100644 blob d3eb5022efc22d1d6c3ac055965f612c7f2fbca9 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
100644 blob f7bc57109569cdd0fb0c3323021c73673dcfcd33 backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
100644 blob e5733a774268c8dee71bd4ba402240d151bb8cb8 backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
Predecessor pair and probe reuse checks
=======================================
Tablet/Binary64ModelDefault.lean: predecessor_sha256=03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3; whole Lean byte-identical.
Tablet/Binary64ModelDefault.tex: predecessor_sha256=57c6e9ed282cf2dd718f822c6a31255040c71b5c7531488f3951d9c4d4d8b822; ordinary NL definition byte-identical.
Tablet/ModelF64Neg.lean: predecessor_sha256=9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2; whole Lean byte-identical.
Tablet/ModelF64Neg.tex: predecessor_sha256=9d2811046df611e45e2637da57241bace75c3de5822e03126de5f1fc9faeb859; ordinary NL definition byte-identical.
Tablet/ModelU64BitAnd.lean: predecessor_sha256=3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179; whole Lean byte-identical.
Tablet/ModelU64BitAnd.tex: predecessor_sha256=db8a1445918e94fd1c11f92f1c5f218f165aec945ac2ebdeda3cc1675165f8fe; ordinary NL definition byte-identical.
Tablet/ModelU64BitOr.lean: predecessor_sha256=aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f; whole Lean byte-identical.
Tablet/ModelU64BitOr.tex: predecessor_sha256=fbbb37c3cfa81c5811869baf46671d93a6c457042f0a5bbb78ba32c26607dbe2; ordinary NL definition byte-identical.
Tablet/ModelU64Shl.lean: predecessor_sha256=af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad; whole Lean byte-identical.
Tablet/ModelU64Shl.tex: predecessor_sha256=725582880c20b16d00487e01aceb0552a39263616563280cee0d49635984beab; ordinary NL definition byte-identical.
Tablet/ModelU64Shr.lean: predecessor_sha256=54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b; whole Lean byte-identical.
Tablet/ModelU64Shr.tex: predecessor_sha256=3def4409d97d8316d4d77dc2fe01c4142219859ea9596b835ac40f83c3a18784; ordinary NL definition byte-identical.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-negation-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-negation-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shl-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shr-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
Current raw declarations and exact support bindings
===================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py inspect-native .
EXIT: 0
STDOUT:
{
"full_index": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json",
"declaration_count": 24,
"declarations": [
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 \u2192 Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 \u2192 Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 \u2192 Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 \u2192 Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 \u2192 Std.U64 \u2192 Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02"
}
],
"declarations_omitted": 9
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
EXIT: 0
STDOUT:
fbe3b76ef8fbb588841979e071c52eee0fc850472ac55da6f2ca2033e4a34cf4 /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
STDERR:
(empty)
RAW DECLARATION:
/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:
Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43
Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]
Visibility: public -/
@[rust_fun "core::clone::impls::{core::clone::Clone<f64>}::clone"]
axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dfbdb508142706b4c716f701e52a26d63d764f088dacfa461dd81c6df0b9bf0d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_DIGITS]
Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34
Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_DIGITS"]
axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 19dc0621c0c5c7d2a24f090dd7870ffa858de15fc4e1cc7bf57f16d64816c9bc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NAN]
Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22
Name pattern: [core::f64::{f64}::NAN]
Visibility: public -/
@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 75cd3ccca5992f42ef5afa9287573410d249d40f9bcc3120fae72389b2e2419d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27
Name pattern: [core::f64::{f64}::INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::INFINITY"]
axiom core.f64.F64.INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 9a5fb08a6bae926bafdba709d6da6aaad52b8f41c7dbf3e4b2a28b2bc0542716
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NEG_INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31
Name pattern: [core::f64::{f64}::NEG_INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::NEG_INFINITY"]
axiom core.f64.F64.NEG_INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f5d6435579e1da8caecfc1a3b0039a0ce4e250e7dc55c4c69f3edbdd2a5a10f6
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::EXPONENT_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32
Name pattern: [core::f64::{f64}::EXPONENT_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::EXPONENT_MASK"]
axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dcd87a62501dc8e76079204a4b43546a4750077e1f425f01dcd58c96bf31a865
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32
Name pattern: [core::f64::{f64}::MANTISSA_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_MASK"]
axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): cf1585ae2e94a7bf5bb6b5ff37a06a0677b7e8d81420c1e0ca7ee29eca8cfd4c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::classify]:
Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45
Name pattern: [core::f64::{f64}::classify]
Visibility: public -/
@[rust_fun "core::f64::{f64}::classify"]
axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
IDENTITY AND BINDING:
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 7cf497c5bfc31455d5490d5da75914d7eaf9e522aa2eccd14fe9935502b5127c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::to_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37
Name pattern: [core::f64::{f64}::to_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::to_bits"]
axiom core.f64.F64.to_bits : F64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b35203125fea8ba89df874b609344bbe8ad61a61fcb946a184a72c729a1e3364
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::from_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42
Name pattern: [core::f64::{f64}::from_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::from_bits"]
axiom core.f64.F64.from_bits : Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f819b0951f4f63943abf8d4787a2f9489ffd1137fa91529e0771a303bc8fcb94
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41
Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul"]
axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 4adead3b54aa85bfb81b7122b0e942b2c6f3d232d548d8361a2a2ca067be1e7f
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41
Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div"]
axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 62ca24414fa18ef9709d7c5703429d7262f27d017abc975ffb532ae284ba054a
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 945f30e7dbb62802e6ba5bb9d9445e100528b2a52d3b0b6a3a0629c939ff9860
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b66bd94c28f512804622c3717705dbe7ef5a3ced5beaac7435704d053038c36e
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 68909ba4060a48df31ea54bcf0510b089709a3a644c9c1b0770780a98d31f4cc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 5c0105f2c7ce3d255f053e0ccbefa65f73f65de1462832217571cf8cd4963e47
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f100256a450680392496fb74934592e9e2822a1648320153e27c1c0d100ff482
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5
Visibility: public -/
axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
: Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 0bb769d884e3d54d7aa94163fdf4c8fc589050ed84f4fa0d11f694cf599cdb8f
All four identity fields and full raw declaration equal predecessor; current binding matches.
Complete relevant call and wiring inventories
=============================================
This deliberately includes record wiring and scalar lowerings, not just direct external calls.
The four U64 external trait fields wire into Int; generic scalar notation in generated.lean
also lowers directly to the installed operations with the same full-domain meanings.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n 'F64\.Insts\.(CoreClone|CoreOpsArith)|core\.f64\.F64\.|U64\.Insts\.CoreOpsBit|coreops(bit|arith)|\.from_u64|\.pow10_fast_path|FloatInst\.(INFINITY|NEG_INFINITY|NAN|NEG_NAN|SIG_|EXP_|INFINITE_POWER)|&&&|\|\|\||<<<|>>>' generated.lean
EXIT: 0
STDOUT:
25:axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
31:def F64.Insts.CoreCloneClone : core.clone.Clone F64 := {
32: clone := F64.Insts.CoreCloneClone.clone
40: cloneInst := F64.Insts.CoreCloneClone
48:axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
54:@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
61:axiom core.f64.F64.INFINITY : Result F64
68:axiom core.f64.F64.NEG_INFINITY : Result F64
75:axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
82:axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
101:axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
108:axiom core.f64.F64.to_bits : F64 → Result Std.U64
115:axiom core.f64.F64.from_bits : Std.U64 → Result F64
138:axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
144:def F64.Insts.CoreOpsArithMulF64F64 : core.ops.arith.Mul F64 F64 F64 := {
145: mul := F64.Insts.CoreOpsArithMulF64F64.mul
162:axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
168:def F64.Insts.CoreOpsArithDivF64F64 : core.ops.arith.Div F64 F64 F64 := {
169: div := F64.Insts.CoreOpsArithDivF64F64.div
185:axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
191:def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
192: neg := F64.Insts.CoreOpsArithNegF64.neg
200:axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
207:def U64.Insts.CoreOpsBitBitAndU64U64 : core.ops.bit.BitAnd Std.U64 Std.U64
209: bitand := U64.Insts.CoreOpsBitBitAndU64U64.bitand
226:axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
233:def U64.Insts.CoreOpsBitBitOrU64U64 : core.ops.bit.BitOr Std.U64 Std.U64
235: bitor := U64.Insts.CoreOpsBitBitOrU64U64.bitor
252:axiom U64.Insts.CoreOpsBitShlU32U64.shl
259:def U64.Insts.CoreOpsBitShlU32U64 : core.ops.bit.Shl Std.U64 Std.U32 Std.U64
261: shl := U64.Insts.CoreOpsBitShlU32U64.shl
278:axiom U64.Insts.CoreOpsBitShrU32U64.shr
285:def U64.Insts.CoreOpsBitShrU32U64 : core.ops.bit.Shr Std.U64 Std.U32 Std.U64
287: shr := U64.Insts.CoreOpsBitShrU32U64.shr
393: let i ← lift (a ||| b)
394: let i1 ← lift (i &&& 9259542123273814144#u64)
635: coreopsbitShrSelfU32SelfInst : core.ops.bit.Shr Self Std.U32 Self
636: coreopsbitShlSelfU32SelfInst : core.ops.bit.Shl Self Std.U32 Self
637: coreopsbitBitAndInst : core.ops.bit.BitAnd Self Self Self
638: coreopsbitBitOrInst : core.ops.bit.BitOr Self Self Self
664: coreopsarithDivInst : core.ops.arith.Div Self Self Self
665: coreopsarithNegInst : core.ops.arith.Neg Self Self
666: coreopsarithMulInst : core.ops.arith.Mul Self Self Self
726: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
727: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
728: (coreopsarithNegInst : core.ops.arith.Neg F F)
739: let value ← LemireInst.from_u64 self.mantissa
746: let t ← LemireInst.pow10_fast_path i2
747: coreopsarithDivInst.div value t
751: let t ← LemireInst.pow10_fast_path i1
752: coreopsarithMulInst.mul value t
754: then let t ← coreopsarithNegInst.neg value1
769: let t ← LemireInst.from_u64 val
771: let t1 ← LemireInst.pow10_fast_path i4
772: let value ← coreopsarithMulInst.mul t t1
774: then let t2 ← coreopsarithNegInst.neg value
1018: let i5 ← lift (1#u8 &&& i4)
1219: let shift1 ← lift (shift &&& 63#usize)
1228: let i1 ← x_a >>> 11#i32
1230: let i2 ← lift (2047#u16 &&& x_a)
1232: let i3 ← lift (2047#u16 &&& x_b)
1264: let i2 ← i1 <<< shift
1370: let i ← n >>> shift
1400: let i ← n >>> shift
1451: let i1 ← n >>> shift
1453: let i2 ← lift (n &&& mask)
1490: let i ← n >>> shift
1492: let i1 ← lift (n &&& mask)
1544: let i4 ← 1#u64 <<< shift
1704: let i3 ← 1#i64 <<< 59#i32
2971: let i3 ← r >>> 64#i32
2990: then 18446744073709551615#u64 >>> precision
3000: let i4 ← lift (first_hi &&& mask)
3016: let i2 ← i1 >>> 16#i32
3028: let i ← traitsFloatInst.INFINITE_POWER
3045: let w1 ← w <<< lz
3046: let i5 ← traitsFloatInst.SIG_BITS
3058: let i8 ← hi >>> 63#i32
3064: let mantissa ← hi >>> i12
3070: let i18 ← traitsFloatInst.EXP_MIN
3081: let mantissa1 ← mantissa >>> i22
3082: let i23 ← lift (mantissa1 &&& 1#u64)
3084: let mantissa3 ← mantissa2 >>> 1#i32
3085: let i24 ← 1#u64 <<< i5
3102: let i24 ← lift (mantissa &&& 3#u64)
3108: let i28 ← mantissa <<< i27
3111: ok (mantissa &&& i29)
3117: let i20 ← lift (mantissa1 &&& 1#u64)
3119: let mantissa3 ← mantissa2 >>> 1#i32
3120: let i21 ← 2#u64 <<< i5
3125: let mantissa5 ← 1#u64 <<< i5
3129: let i22 ← 1#u64 <<< i5
3131: let mantissa5 ← lift (mantissa4 &&& i23)
3137: let i8 ← hi >>> 63#i32
3143: let mantissa ← hi >>> i12
3149: let i18 ← traitsFloatInst.EXP_MIN
3160: let mantissa1 ← mantissa >>> i22
3161: let i23 ← lift (mantissa1 &&& 1#u64)
3163: let mantissa3 ← mantissa2 >>> 1#i32
3164: let i24 ← 1#u64 <<< i5
3181: let i24 ← lift (mantissa &&& 3#u64)
3187: let i28 ← mantissa <<< i27
3190: ok (mantissa &&& i29)
3196: let i20 ← lift (mantissa1 &&& 1#u64)
3198: let mantissa3 ← mantissa2 >>> 1#i32
3199: let i21 ← 2#u64 <<< i5
3204: let mantissa5 ← 1#u64 <<< i5
3208: let i22 ← 1#u64 <<< i5
3210: let mantissa5 ← lift (mantissa4 &&& i23)
3232: let i ← LemireInst.traitsFloatExtInst.FloatInst.SIG_TOTAL_BITS
3233: 1#u64 <<< i
3240: let bits ← core.f64.F64.to_bits self
3241: let i ← bits >>> 63#i32
3245: let i1 ← core.f64.F64.EXPONENT_MASK
3246: let i2 ← lift (bits &&& i1)
3247: let i3 ← i2 >>> 52#i32
3253: let i4 ← core.f64.F64.MANTISSA_MASK
3254: let i5 ← lift (bits &&& i4)
3255: i5 <<< 1#i32
3258: let i4 ← core.f64.F64.MANTISSA_MASK
3259: let i5 ← lift (bits &&& i4)
3260: let i6 ← 1#u64 <<< 52#i32
3261: ok (i5 ||| i6)
3269:def F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3271: core.f64.F64.from_bits v
3278: core.f64.F64.classify self
3285: core.f64.F64.to_bits self
3324: core.f64.F64.MANTISSA_MASK
3331: core.f64.F64.EXPONENT_MASK
3339: core.f64.F64.MANTISSA_DIGITS
3352: core.f64.F64.from_bits 18444492273895866368#u64
3359: core.f64.F64.NAN
3366: core.f64.F64.NEG_INFINITY
3373: core.f64.F64.INFINITY
3381: let i ← FloatInst.EXP_BIAS
3392: let i ← FloatInst.EXP_SAT
3393: i >>> 1#i32
3402: let i ← FloatInst.EXP_SAT
3411: let i ← FloatInst.EXP_BITS
3412: let i1 ← 1#u32 <<< i
3422: let i1 ← FloatInst.SIG_BITS
3432: let i ← FloatInst.SIG_TOTAL_BITS
3471: coreopsbitShrSelfU32SelfInst := U64.Insts.CoreOpsBitShrU32U64
3472: coreopsbitShlSelfU32SelfInst := U64.Insts.CoreOpsBitShlU32U64
3473: coreopsbitBitAndInst := U64.Insts.CoreOpsBitBitAndU64U64
3474: coreopsbitBitOrInst := U64.Insts.CoreOpsBitBitOrU64U64
3512: coreopsarithDivInst := F64.Insts.CoreOpsArithDivF64F64
3513: coreopsarithNegInst := F64.Insts.CoreOpsArithNegF64
3514: coreopsarithMulInst := F64.Insts.CoreOpsArithMulF64F64
3529: from_u64_bits := F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3537:axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3543:def F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3545: let i ← lift (exponent &&& 31#usize)
3547: | 0 => core.f64.F64.from_bits 4607182418800017408#u64
3548: | 1 => core.f64.F64.from_bits 4621819117588971520#u64
3549: | 2 => core.f64.F64.from_bits 4636737291354636288#u64
3550: | 3 => core.f64.F64.from_bits 4652007308841189376#u64
3551: | 4 => core.f64.F64.from_bits 4666723172467343360#u64
3552: | 5 => core.f64.F64.from_bits 4681608360884174848#u64
3553: | 6 => core.f64.F64.from_bits 4696837146684686336#u64
3554: | 7 => core.f64.F64.from_bits 4711630319722168320#u64
3555: | 8 => core.f64.F64.from_bits 4726483295884279808#u64
3556: | 9 => core.f64.F64.from_bits 4741671816366391296#u64
3557: | 10 => core.f64.F64.from_bits 4756540486875873280#u64
3558: | 11 => core.f64.F64.from_bits 4771362005757984768#u64
3559: | 12 => core.f64.F64.from_bits 4786511204640096256#u64
3560: | 13 => core.f64.F64.from_bits 4801453603149578240#u64
3561: | 14 => core.f64.F64.from_bits 4816244402031689728#u64
3562: | 15 => core.f64.F64.from_bits 4831355200913801216#u64
3563: | 16 => core.f64.F64.from_bits 4846369599423283200#u64
3564: | 17 => core.f64.F64.from_bits 4861130398305394688#u64
3565: | 18 => core.f64.F64.from_bits 4876203697187506176#u64
3566: | 19 => core.f64.F64.from_bits 4891288408196988160#u64
3567: | 20 => core.f64.F64.from_bits 4906019910204099648#u64
3568: | 21 => core.f64.F64.from_bits 4921056587992461136#u64
3569: | 22 => core.f64.F64.from_bits 4936209963552724370#u64
3570: | _ => core.f64.F64.from_bits 0#u64
3606: F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3607: from_u64 := F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3643: let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
3644: let i2 ← i <<< i1
3645: let word ← lift (x.m ||| i2)
3646: traitsFloatExtInst.from_u64_bits word
3903: let i ← traitsFloatInst.EXP_MIN
3939: let i ← traitsFloatInst.INFINITE_POWER
3971: let i5 ← traitsFloatInst.EXP_MIN
3977: let i8 ← traitsFloatInst.SIG_BITS
3984: let i12 ← 1#u64 <<< i11
3999: let i16 ← 1#u64 <<< i8
4004: let i17 ← 1#u64 <<< i8
4006: let mantissa2 ← lift (mantissa1 &&& i18)
4011: let i14 ← 1#u64 <<< i8
4016: let i15 ← 1#u64 <<< i8
4018: let mantissa1 ← lift (mantissa &&& i16)
4035: let register1 ← lift (register &&& 16131858542891098079#u64)
4039: let float ← traitsFloatInst.INFINITY
4041: then let t ← traitsFloatInst.coreopsarithNegInst.neg float
4056: let i5 ← c <<< 16#i32
4057: let i6 ← b <<< 8#i32
4058: let i7 ← lift (i5 ||| i6)
4059: let register ← lift (i7 ||| a)
4060: let register1 ← lift (register &&& 16131858542891098079#u64)
4063: let float ← traitsFloatInst.INFINITY
4066: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4071: let float ← traitsFloatInst.NAN
4074: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4237: let i1 ← v1 >>> 8#i32
4239: let i2 ← lift (v2 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4243: let i3 ← v2 >>> 16#i32
4244: let i4 ← lift (i3 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4249: let i6 ← i5 >>> 32#i32
4561: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4562: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4563: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4611: coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
4656: let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
4657: let i2 ← i <<< i1
4658: let assembled_word ← lift (selected_pair.m ||| i2)
4664: let result ← coreopsarithNegInst.neg assembly_result
4731: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4732: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4733: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4737: num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
4738: coreopsarithMulInst coreopsarithNegInst s
STDERR:
(empty)
Rust inventory is a complete operation-syntax superset, including generic and scalar forms;
trait bounds, comments and non-U64 integer operations are included, not silently omitted.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n '<<|>>|[&|]|Neg::neg|Div::div|Mul::mul|from_u64|pow10_fast_path|SIG_BITS|SIG_TOTAL_BITS|F::NAN|F::INFINITY|Some\(-float\)' crate/traits.rs crate/dec2flt
EXIT: 0
STDOUT:
crate/traits.rs:95: const SIG_TOTAL_BITS: u32;
crate/traits.rs:101: const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
crate/traits.rs:104: const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
crate/traits.rs:110: const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
crate/traits.rs:116: const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
crate/traits.rs:137: /// (in the 32-bit case). In both cases,the power of five(5^|q|)
crate/traits.rs:172: fn from_u64_bits(v: u64) -> Self;
crate/traits.rs:177: /// exponent will be `-(EXP_BIAS + SIG_BITS)`, which is the minimum subnormal power. For
crate/traits.rs:178: /// infinity or NaN, the exponent will be `EXP_SAT - EXP_BIAS - SIG_BITS`.
crate/traits.rs:204: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:229: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:230: Self::from_bits((v & 0xFFFF) as u16)
crate/traits.rs:238: let sign = if bits >> 15 == 0 { 1 } else { -1 };
crate/traits.rs:239: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
crate/traits.rs:241: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:243: (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
crate/traits.rs:264: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:288: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:289: f32::from_bits((v & 0xFFFFFFFF) as u32)
crate/traits.rs:297: let sign = if bits >> 31 == 0 { 1 } else { -1 };
crate/traits.rs:298: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
crate/traits.rs:300: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:302: (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
crate/traits.rs:320: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:341: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:350: let sign = if bits >> 63 == 0 { 1 } else { -1 };
crate/traits.rs:351: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
crate/traits.rs:353: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:355: (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
crate/dec2flt/common.rs:10: fn read_u64(&self) -> u64;
crate/dec2flt/common.rs:13: fn write_u64(&mut self, value: u64);
crate/dec2flt/common.rs:16: fn offset_from(&self, other: &Self) -> isize;
crate/dec2flt/common.rs:22: fn read_u64(&self) -> u64 {
crate/dec2flt/common.rs:24: tmp.copy_from_slice(&self[..8]);
crate/dec2flt/common.rs:29: fn write_u64(&mut self, value: u64) {
crate/dec2flt/common.rs:30: self[..8].copy_from_slice(&value.to_le_bytes())
crate/dec2flt/common.rs:34: fn offset_from(&self, other: &Self) -> isize {
crate/dec2flt/common.rs:47: (a | b) & 0x8080_8080_8080_8080 == 0
crate/dec2flt/mod.rs:116: /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:120: /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:124: /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
crate/dec2flt/mod.rs:127: /// Maximum mantissa for the fast-path (`1 << 53` for f64).
crate/dec2flt/mod.rs:128: const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
crate/dec2flt/mod.rs:131: fn pow10_fast_path(exponent: usize) -> Self;
crate/dec2flt/mod.rs:137: fn from_u64(v: u64) -> Self;
crate/dec2flt/mod.rs:147: // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
crate/dec2flt/mod.rs:153: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:157: match exponent & 7 {
crate/dec2flt/mod.rs:172: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:183: // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
crate/dec2flt/mod.rs:187: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:190: match exponent & 15 {
crate/dec2flt/mod.rs:211: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:218: // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
crate/dec2flt/mod.rs:222: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:226: match exponent & 31 {
crate/dec2flt/mod.rs:263: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:284: word |= (x.p_biased as u64) << F::SIG_BITS;
crate/dec2flt/mod.rs:285: F::from_u64_bits(word)
crate/dec2flt/mod.rs:299: SignOnly { body: &'a [u8], negative: bool },
crate/dec2flt/mod.rs:302: body: &'a [u8],
crate/dec2flt/mod.rs:309: body: &'a [u8],
crate/dec2flt/mod.rs:317: body: &'a [u8],
crate/dec2flt/mod.rs:330: pub body: &'a [u8],
crate/dec2flt/mod.rs:362: s: &'a str,
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
crate/dec2flt/mod.rs:369: if c == b'-' || c == b'+' {
crate/dec2flt/mod.rs:370: body = &body[1..];
crate/dec2flt/mod.rs:431: // occur exactly when `many_digits && fp.p_biased >= 0`.
crate/dec2flt/mod.rs:432: let second_compute_guard = num.many_digits && fp.p_biased >= 0;
crate/dec2flt/mod.rs:468: let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
crate/dec2flt/mod.rs:472: core::ops::Neg::neg(assembly_result)
crate/dec2flt/mod.rs:514: s: &str,
crate/dec2flt/fpu.rs:31: /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
crate/dec2flt/fpu.rs:32: /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
crate/dec2flt/fpu.rs:33: /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
crate/dec2flt/fpu.rs:52: in(reg) &cw,
crate/dec2flt/fpu.rs:76: in(reg) &mut cw,
crate/dec2flt/fpu.rs:83: set_cw((cw & 0xFCFF) | cw_precision);
crate/dec2flt/fpu.rs:89: fn drop(&mut self) {
crate/dec2flt/decimal.rs:42: fn can_use_fast_path<F: Lemire>(&self) -> bool {
crate/dec2flt/decimal.rs:44: && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
crate/dec2flt/decimal.rs:45: && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
crate/dec2flt/decimal.rs:46: && !self.many_digits
crate/dec2flt/decimal.rs:65: &self,
crate/dec2flt/decimal.rs:84: let value = F::from_u64(self.mantissa);
crate/dec2flt/decimal.rs:88: core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
crate/dec2flt/decimal.rs:90: core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
crate/dec2flt/decimal.rs:99: core::ops::Mul::mul(
crate/dec2flt/decimal.rs:100: F::from_u64(mantissa),
crate/dec2flt/decimal.rs:101: F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
crate/dec2flt/decimal.rs:106: Some(core::ops::Neg::neg(value))
crate/dec2flt/decimal_seq.rs:74: pub(super) fn try_add_digit(&mut self, digit: u8) {
crate/dec2flt/decimal_seq.rs:83: pub fn trim(&mut self) {
crate/dec2flt/decimal_seq.rs:92: while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
crate/dec2flt/decimal_seq.rs:97: pub(super) fn round(&self) -> u64 {
crate/dec2flt/decimal_seq.rs:98: if self.num_digits == 0 || self.decimal_point < 0 {
crate/dec2flt/decimal_seq.rs:118: if self.digits[dp] == 5 && dp + 1 == self.num_digits {
crate/dec2flt/decimal_seq.rs:119: round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
crate/dec2flt/decimal_seq.rs:130: pub(super) fn left_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:142: n += (self.digits[read_index] as u64) << shift;
crate/dec2flt/decimal_seq.rs:176: pub(super) fn right_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:181: while (n >> shift) == 0 && !all_zero {
crate/dec2flt/decimal_seq.rs:191: while (n >> shift) == 0 {
crate/dec2flt/decimal_seq.rs:209: let mask = (1_u64 << shift) - 1;
crate/dec2flt/decimal_seq.rs:211: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:212: n = (10 * (n & mask)) + self.digits[read_index] as u64;
crate/dec2flt/decimal_seq.rs:218: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:219: n = 10 * (n & mask);
crate/dec2flt/decimal_seq.rs:236:fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
crate/dec2flt/decimal_seq.rs:240: while i != 0 && scanning {
crate/dec2flt/decimal_seq.rs:242: if c == b'0' || c == b'.' {
crate/dec2flt/decimal_seq.rs:254:// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
crate/dec2flt/decimal_seq.rs:257:fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
crate/dec2flt/decimal_seq.rs:259: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/decimal_seq.rs:264: &s[count..]
crate/dec2flt/decimal_seq.rs:288:pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
crate/dec2flt/decimal_seq.rs:296: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:297: s = &s[1..];
crate/dec2flt/decimal_seq.rs:300: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:302: if !s.is_empty() && s[0] == b'.' {
crate/dec2flt/decimal_seq.rs:303: s = &s[1..];
crate/dec2flt/decimal_seq.rs:309: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:310: s = &s[1..];
crate/dec2flt/decimal_seq.rs:313: while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
crate/dec2flt/decimal_seq.rs:320: s = &s[8..];
crate/dec2flt/decimal_seq.rs:322: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:350: if ch == b'e' || ch == b'E' {
crate/dec2flt/decimal_seq.rs:362: let mut exponent_suffix = &s[1..];
crate/dec2flt/decimal_seq.rs:363: explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
crate/dec2flt/decimal_seq.rs:375:fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
crate/dec2flt/decimal_seq.rs:433: shift &= 63;
crate/dec2flt/decimal_seq.rs:436: let num_new_digits = (x_a >> 11) as _;
crate/dec2flt/decimal_seq.rs:437: let pow5_a = (0x7FF & x_a) as usize;
crate/dec2flt/decimal_seq.rs:438: let pow5_b = (0x7FF & x_b) as usize;
crate/dec2flt/decimal_seq.rs:439: let pow5 = &TABLE_POW5[pow5_a..];
crate/dec2flt/decimal_seq.rs:441: for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
crate/dec2flt/lemire.rs:32: if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
crate/dec2flt/lemire.rs:39: w <<= lz;
crate/dec2flt/lemire.rs:40: let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
crate/dec2flt/lemire.rs:57: let inside_safe_exponent = (q >= -27) && (q <= 55);
crate/dec2flt/lemire.rs:62: let upperbit = (hi >> 63) as i32;
crate/dec2flt/lemire.rs:63: let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
crate/dec2flt/lemire.rs:71: mantissa >>= -power2 + 1;
crate/dec2flt/lemire.rs:72: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:73: mantissa >>= 1;
crate/dec2flt/lemire.rs:74: power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
crate/dec2flt/lemire.rs:89: && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:90: && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:91: && mantissa & 0b11 == 0b01
crate/dec2flt/lemire.rs:92: && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
crate/dec2flt/lemire.rs:95: mantissa &= !1_u64;
crate/dec2flt/lemire.rs:98: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:99: mantissa >>= 1;
crate/dec2flt/lemire.rs:100: if mantissa >= (2_u64 << F::SIG_BITS) {
crate/dec2flt/lemire.rs:104: mantissa = 1_u64 << F::SIG_BITS;
crate/dec2flt/lemire.rs:108: mantissa &= !(1_u64 << F::SIG_BITS);
crate/dec2flt/lemire.rs:122: (q.wrapping_mul(152_170 + 65536) >> 16) + 63
crate/dec2flt/lemire.rs:128: (r as u64, (r >> 64) as u64)
crate/dec2flt/lemire.rs:140: 0xFFFF_FFFF_FFFF_FFFF_u64 >> precision
crate/dec2flt/lemire.rs:155: if first_hi & mask == mask {
crate/dec2flt/slow.rs:27:pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
crate/dec2flt/slow.rs:33: let get_shift = |n| {
crate/dec2flt/slow.rs:43: if d.num_digits == 0 || d.decimal_point < -324 {
crate/dec2flt/slow.rs:51: while d.decimal_point > 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:69: while d.decimal_point <= 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:73: 0 | 1 => 2,
crate/dec2flt/slow.rs:107: d.left_shift(F::SIG_BITS as usize + 1);
crate/dec2flt/slow.rs:109: if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
crate/dec2flt/slow.rs:120: if mantissa < (1_u64 << F::SIG_BITS) {
crate/dec2flt/slow.rs:124: mantissa &= (1_u64 << F::SIG_BITS) - 1;
crate/dec2flt/parse.rs:23: v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
crate/dec2flt/parse.rs:24: let v1 = (v & MASK).wrapping_mul(MUL1);
crate/dec2flt/parse.rs:25: let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
crate/dec2flt/parse.rs:26: ((v1.wrapping_add(v2) >> 32) as u32) as u64
crate/dec2flt/parse.rs:30:fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
crate/dec2flt/parse.rs:40: s = &s[8..];
crate/dec2flt/parse.rs:50: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:55: s = &s[count..];
crate/dec2flt/parse.rs:61:fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
crate/dec2flt/parse.rs:86:fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
crate/dec2flt/parse.rs:89: while scan_index < start.len() && scanning {
crate/dec2flt/parse.rs:91: if c == b'.' || c == b'0' {
crate/dec2flt/parse.rs:104:fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
crate/dec2flt/parse.rs:107: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:111: s = &s[1..];
crate/dec2flt/parse.rs:113: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:121:pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:129: if c == b'-' || c == b'+' {
crate/dec2flt/parse.rs:137: if !s.is_empty() && s[0].is_ascii_digit() {
crate/dec2flt/parse.rs:145: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:147: if exponent < (1_i64 << 59) {
crate/dec2flt/parse.rs:152: *s_ref = &s[count..];
crate/dec2flt/parse.rs:164:fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:198: if c == b'e' || c == b'E' {
crate/dec2flt/parse.rs:201: exp_number = parse_scientific(&mut s)?;
crate/dec2flt/parse.rs:234:pub fn parse_number(s: &[u8]) -> Option<Decimal> {
crate/dec2flt/parse.rs:244:pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
crate/dec2flt/parse.rs:260: register = (c << 16) | (b << 8) | a;
crate/dec2flt/parse.rs:269: register &= 0xDFDFDFDFDFDFDFDF;
crate/dec2flt/parse.rs:280: (INF_3, 3) => F::INFINITY,
crate/dec2flt/parse.rs:281: (INF_8, 8) => F::INFINITY,
crate/dec2flt/parse.rs:282: (NAN, 3) => F::NAN,
crate/dec2flt/parse.rs:286: if negative { Some(-float) } else { Some(float) }
STDERR:
(empty)
Current guarded native body, exact f64 boundary and unrestricted assembler:
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 39,111p crate/dec2flt/decimal.rs
EXIT: 0
STDOUT:
impl Decimal {
/// Detect if the float can be accurately reconstructed from native floats.
#[inline]
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
/// Try turning the decimal into an exact float representation, using machine-sized integers
/// and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
/// can be exactly represented as a machine float, since IEE-754 guarantees
/// no rounding will occur.
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
pub fn try_fast_path<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
&self,
) -> Option<F> {
// `Lemire` already entails these three operator bounds through
// `Float`; spelling them directly changes no admitted type. Charon
// needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
// The `set_precision` function takes care of setting the precision on architectures which
// require setting it by changing the global state (like the control word of the x87 FPU).
let _cw = set_precision::<F>();
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 112,138p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
///
/// Not intended for use outside of the `dec2flt` module.
#[doc(hidden)]
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
/// Gets a small power-of-ten for fast-path multiplication.
fn pow10_fast_path(exponent: usize) -> Self;
/// Converts integer into float through an as cast.
/// This is only called in the fast-path algorithm, and therefore
/// will not lose precision, since the value will always have
/// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
fn from_u64(v: u64) -> Self;
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 217,286p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
impl Lemire for f64 {
// Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
#[inline]
pub(super) fn pfe_empty() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Empty }
}
// Used in unit tests, keep public.
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
#[inline]
pub fn pfe_invalid() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Invalid }
}
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 315,365p crate/traits.rs
EXIT: 0
STDOUT:
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
// Exact value of trunc(1024 / log2(10)) from the upstream default.
const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
// This is the upstream default after substituting `Self::Int = u64`;
// it preserves every decoded field while avoiding unsupported generic
// associated-integer operator resolution.
fn integer_decode(self) -> (u64, i16, i8) {
let bits = self.to_bits();
let sign = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
let mantissa = if exponent == 0 {
(bits & Self::MANTISSA_MASK) << 1
} else {
(bits & Self::MANTISSA_MASK) | (1_u64 << 52)
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 245,291p crate/dec2flt/parse.rs
EXIT: 0
STDOUT:
// Since a valid string has at most the length 8, we can load
// all relevant characters into a u64 and work from there.
// This also generates much better code.
let mut register;
let len: usize;
// All valid strings are either of length 8 or 3.
if s.len() == 8 {
register = s.read_u64();
len = 8;
} else if s.len() == 3 {
let a = s[0] as u64;
let b = s[1] as u64;
let c = s[2] as u64;
register = (c << 16) | (b << 8) | a;
len = 3;
} else {
return None;
}
// Clear out the bits which turn ASCII uppercase characters into
// lowercase characters. The resulting string is all uppercase.
// What happens to other characters is irrelevant.
register &= 0xDFDFDFDFDFDFDFDF;
// u64 values corresponding to relevant cases
const INF_3: u64 = 0x464E49; // "INF"
const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
const NAN: u64 = 0x4E414E; // "NAN"
// Match register value to constant to parse string.
// Also match on the string length to catch edge cases
// like "inf\0\0\0\0\0".
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
}
STDERR:
(empty)
Fresh constant and symbolic-negation reproduction
=================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C opt-level=0 reference/model-evidence/binary64-probe.rs -o .trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
; ModuleID = 'binary64_negation_probe.566fd6d762029c-cgu.0'
source_filename = "binary64_negation_probe.566fd6d762029c-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 7, !"uwtable", i32 2}
!3 = !{!"rustc version 1.98.0-nightly (14210df0e 2026-05-31)"}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
.file "binary64_negation_probe.566fd6d762029c-cgu.0"
.section .text.neg_f64_trait_bits,"ax",@progbits
.globl neg_f64_trait_bits
.p2align 4
.type neg_f64_trait_bits,@function
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
.Lfunc_end0:
.size neg_f64_trait_bits, .Lfunc_end0-neg_f64_trait_bits
.cfi_endproc
.ident "rustc version 1.98.0-nightly (14210df0e 2026-05-31)"
.section ".note.GNU-stack","",@progbits
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum .trellis/scratch/binary64-probe .trellis/scratch/binary64-negation-probe.ll .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322 .trellis/scratch/binary64-probe
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
STDERR:
(empty)
Fresh checked-shift reproduction and full dynamic-count MIR
===========================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shl-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir ../../reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shl-probe u64-shl-probe.mir
EXIT: 0
STDOUT:
1d8bda234272af0f20a360fe4ff631c8ed038f9aac02bfe539192fff86706d4c u64-shl-probe
1d05de9f3cfb93082c17a57d39f7fc0813c3fe0d3ebd0efe470b0885fba931b9 u64-shl-probe.mir
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shr-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir ../../reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shr-probe u64-shr-probe.mir
EXIT: 0
STDOUT:
1cceba3e03b755a37112c16ad347161a9732793944f34d0a740470584a08c9fc u64-shr-probe
9a72f1d018d926b3e5672c8fb473e2495a710cf4a252c7515e12d2e5009c134e u64-shr-probe.mir
STDERR:
(empty)
Interpretation and limits
=========================
The constant source really evaluates f64::NAN; its nan=7ff8000000000000 observation
fixes that pinned constant, not arbitrary arithmetic-NaN signs or payloads.
The arbitrary-u64 qualified Neg probe passes w in rdi; movabsq loads 2^63 in rax,
xorq combines them, retq returns rax, with no branch or NaN exception. Its XOR law
holds for all 2^64 words, including every signaling/quiet NaN payload.
The checked dynamic-count MIR establishes the whole U64 x U32 branch condition,
not merely seven runtime samples: counts <64 shift, counts >=64 fail, without masking.
AND/OR remain exact over all words. from_u64 still asserts <=2^53 before casting;
the ordinary source guard gives -22<=exponent<=22, mantissa<=2^53, !many_digits.
The disguised source arm checks its integer product and <=2^53 before the cast,
and uses fixed table index 22. Only then may conditional Binary64NativeCallDomain
supply finite non-NaN cast/table operands and a positive nonzero divisor.
Thus reached native arithmetic is exact; generic arithmetic NaNs retain permitted-choice
semantics, not universal exact-bit equivalence. Assembly admits every BiasedFp field pair.
Equal-target preservation retains both rounding relations to the same target, without
deriving uniqueness from vocabulary or assuming an unresolved GOAL conclusion.
All 32 original GOALs remain pursued with their own quantifiers, domains and polarity.
These source-facing checks are evidence, not preservation Sound certification or GOAL proofs.
Managed checks and final scope verification
===========================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py compose-native . --check
EXIT: 0
Selected raw result fields:
{
"full_result": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/compose-native-1791584636440554217.json",
"matches": true,
"changed": false,
"mismatched_files": [],
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
COMMAND: python3 .trellis/scripts/check.py model-support-check .
EXIT: 0
Raw result:
{"ok": true, "errors": []}
COMMAND: python3 .trellis/scripts/check.py tablet . --json
EXIT: 0
Structured projection from the final full managed JSON result:
{
"command": [
"python3",
".trellis/scripts/check.py",
"tablet",
".",
"--json"
],
"exit_status": 0,
"ok": true,
"errors": [],
"node_count": 340,
"all_nodes_compile": true,
"elaboration_failures": [],
"structure_failures": [],
"warning_count": 696,
"warning_examples": [
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:364:4: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:587:8: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/StringIter.lean:13:4: declaration uses `sorry`"
],
"raw_stdout_sha256": "15a1d03a085481d315bcc1a4716aa174475f03e72d8f452f5f33d45a71f5ed91",
"stderr_line_count": 340,
"raw_stderr_sha256": "50c8fde0aef24c1b87ce95c51d21794927d6abba46d90fd04a8d3a714bfed46e"
}
This final command was captured and summarized by
python3 .trellis/scratch/managed-tablet-summary.py (exit 0).
Two earlier identical whole-Tablet checks also exited 0; one jq projection
reported tablet_exit=0 jq_exit=0, node_count=340, failing_elaboration=[],
invalid_structure=[]. The first tool preview truncated its verbose JSON;
that truncation was not used as a proof-closure certificate. The retained
warnings include permitted principal GOAL sketches and installed Aeneas
Slice/StringIter sorry warnings. No definition was supplied with sorry.
These checks establish elaboration, structure and composition freshness,
not preservation Sound or proof closure of the pursued GOALs.
COMMAND: python3 .trellis/scratch/preservation-scope-check.py
EXIT: 0
Raw result:
{
"ok": true,
"owner_checks": [
{
"node": "Binary64ModelDefault",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "210652331cd53e0254aae45856663c01d0552fe992b69608fe243260022ccd79"
},
{
"node": "ModelF64Neg",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "f7d74d4558333c0754ccce8f6861d1409c049fd4dfd1825daad2fd2f441eb78f"
},
{
"node": "ModelU64BitAnd",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "b401e17a058ec2909fb7a58d01f07867f03a933c2901338efebda252692ca6ff"
},
{
"node": "ModelU64BitOr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "c53e3e5ad29cc4419d07c3f2a8913e0f4df87ecbcf4ac1567a9e699a2bd18e2d"
},
{
"node": "ModelU64Shl",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "ed68845da19138d7406e8022c5a9adb765ed70c2ed075f41aea7c190dea9909a"
},
{
"node": "ModelU64Shr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "04b6ec376e7ec490c64183f2a18be832ea574391d7f24d49db7ddc10019cd2f0"
}
],
"principal_goal_pairs": [
{
"node": "AssemblyCorrespondence",
"target": "assembly_correspondence",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationDeterminism",
"target": "classification_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationSignificandDigit",
"target": "classification_significand_digit",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationTotality",
"target": "classification_totality",
"paired_files_byte_unchanged": true
},
{
"node": "ExponentValueAgreement",
"target": "exponent_value_agreement",
"paired_files_byte_unchanged": true
},
{
"node": "IntegerCorrectOrDefer",
"target": "integer_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NativeCorrectOrDefer",
"target": "native_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAcceptance",
"target": "number_helper_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAccumulatedValue",
"target": "number_helper_accumulated_value",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRecordBounds",
"target": "number_helper_record_bounds",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRejection",
"target": "number_helper_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserAccumulatedRounding",
"target": "parser_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserEqualTargetRounding",
"target": "parser_equal_target_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserExactRounding",
"target": "parser_exact_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInfinity",
"target": "parser_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInvalidRejection",
"target": "parser_invalid_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNanAcceptance",
"target": "parser_nan_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNonNanResults",
"target": "parser_non_nan_results",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericAcceptance",
"target": "parser_numeric_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericSign",
"target": "parser_numeric_sign",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserSignedZero",
"target": "parser_signed_zero",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserTotality",
"target": "parser_totality",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_SlowAccumulatedRounding",
"target": "slow_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchAbstractComposition",
"target": "dispatch_abstract_composition",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchComponentCompliance",
"target": "dispatch_component_compliance",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedExponent",
"target": "parser_selected_exponent",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedMagnitudeSign",
"target": "parser_selected_magnitude_sign",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingDeterminism",
"target": "rounding_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingTotality",
"target": "rounding_totality",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperInfinity",
"target": "special_helper_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperNan",
"target": "special_helper_nan",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperRejection",
"target": "special_helper_rejection",
"paired_files_byte_unchanged": true
}
],
"new_nodes": [],
"evidence_consumers_for_current_Sound": [
"Binary64ModelDefault",
"DecimalGoalVocabularyDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"frozen_boundary_unchanged": true,
"pre_existing_config_delta_unchanged": true,
"changed_paths_in_assigned_scope": [
"Tablet/Binary64ModelDefault.tex",
"Tablet/ModelF64Neg.tex",
"Tablet/ModelU64BitAnd.tex",
"Tablet/ModelU64BitOr.tex",
"Tablet/ModelU64Shl.tex",
"Tablet/ModelU64Shr.tex",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
],
"completion_meaning_audit_still_required": true
}
Delivery, acceptance and certification status
============================================
The executed kernel task is task_id=11 (worker request 118), compiler=managed,
under trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91.
Submitted scope is exactly the six owners' preservation sections and ten
reserved evidence paths listed above. No acceptance/publication outcome is
available before worker delivery; the host's real receipt must supply it.
The raw-only worker validator and a Submitted marker mean delivery, not host
acceptance, publication, preservation Sound or Modeling completion.
Keep retry-binary64-preservation-exclusively live until actual publication,
and verify-published-preservation-and-meanings live until current certification.
After publication, request current Sound on all changed evidence consumers,
including DecimalGoalVocabularyDefault's u64-shl/u64-bitor citations, and
repaired support before parents whose named gaps remain open. Do not reset
Binary64ModelDefault's genuine VerifierFail based on these worker checks.
The independent all-32 original-GOAL meaning audit remains required before
Modeling completion; a byte-unchanged pair check is not that semantic audit.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-negation-probe.rs
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
reference/model-evidence/binary64-negation.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
Primary evidence for binary64 trait negation
============================================
Scope and conclusion
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction and the
nightly-2026-06-01 toolchain fixed by modeling-input/SETUP.md and
modeling-input/manifest.json. It establishes the following statement for the
specific extracted Rust operation bound to ModelF64Neg:
For every u64 word w, including every signaling or quiet NaN payload,
to_bits(<f64 as core::ops::Neg>::neg(f64::from_bits(w)))
equals w XOR 0x8000000000000000.
Thus precisely bit 63 is toggled and every other bit is preserved. This is a
universal symbolic result, not an inference from finitely many test inputs.
Pinned identities
-----------------
The following command was run from the repository root. RROOT is the source
tree installed with the configured compiler.
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
RROOT=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
sha256sum "$R" \
"$RROOT/core/src/ops/arith.rs" \
"$RROOT/core/src/primitive_docs.rs" \
crate/dec2flt/mod.rs upstream/dec2flt/mod.rs \
generated.lean Tablet/model-support.json \
modeling-input/tool-identities.json \
reference/model-evidence/binary64-negation-probe.rs
Raw output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
modeling-input/tool-identities.json records the same rustc path and SHA-256.
The compiler reports:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Concrete core implementation
----------------------------
The following exact excerpt is core/src/ops/arith.rs:709-728 in the source
whose SHA-256 is 596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0:
macro_rules! neg_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const Neg for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> $t { -self }
}
forward_ref_unop! { impl Neg, neg for $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
The macro invocation explicitly includes f64. Its expansion is therefore the
concrete `impl Neg for f64`, with `Output = f64`, whose method body is the
primitive expression `-self`.
Frozen parser statement and primitive guarantee
------------------------------------------------
The adapted frozen parser and supplied upstream parser have identical text at
dec2flt/mod.rs:20-22. Their complete-file hashes are pinned above. The exact
three lines are:
//! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
//! process and re-apply it at the very end. This is correct in all edge cases since IEEE
//! floats are symmetric around zero, negating one simply flips the first bit.
The installed primitive documentation is pinned above by SHA-256
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5.
At primitive_docs.rs:1369-1375 it identifies f64 as binary64 and directs the
reader to the f32 documentation for the common floating-point rules:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The exact common rule at primitive_docs.rs:1256-1260 is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
This rule expressly covers unary negation and bit conversion, and expressly
distinguishes them from arithmetic NaN production. It therefore preserves the
quiet/signaling bit and every payload bit for NaNs as well as all non-sign bits
for finite values, zeros, and infinities. The parser statement identifies the
permitted sign-bit change as an actual flip in all edge cases.
Extraction and support binding
------------------------------
The frozen generated.lean, pinned above, contains this exact declaration and
trait implementation record:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
/-- Trait implementation: [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}]
Source: '/rustc/library/core/src/ops/arith.rs', lines 713:8-713:29
Name pattern: [core::ops::arith::Neg<f64, f64>] -/
@[reducible, rust_trait_impl "core::ops::arith::Neg<f64, f64>"]
def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
neg := F64.Insts.CoreOpsArithNegF64.neg
}
Thus the extracted external is the same f64 macro expansion and method body
identified above, not an abstract or different negation operation. Running
`python3 .trellis/scripts/pv_modeling.py inspect-native "$PWD"` and selecting
that declaration gives the following raw inventory fields:
name: F64.Insts.CoreOpsArithNegF64.neg
extracted_signature: : F64 → Result F64
rust_symbol: core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
raw_declaration_sha256: bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0
The raw declaration hash is independently reproduced after that inspection by:
I=$(ls -1t .trellis/scratch/inspect-native-*.json | head -n 1)
jq -j '.. | objects | select(.name? == "F64.Insts.CoreOpsArithNegF64.neg") | .source_utf8' "$I" | sha256sum
Raw output:
bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0 -
Tablet/model-support.json, whose complete-file hash is pinned above, copies all
four identity fields unchanged and binds this external to the model definition:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
Symbolic same-toolchain probe
-----------------------------
The retained probe source is:
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
The argument is an arbitrary symbolic u64. The qualified call forces the same
`Neg for f64` trait method identified by the core source and extraction. The
following exact commands use the extraction's compiler and target and retain
both optimized LLVM IR and assembly in the worker scratch directory:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-negation-probe.rs
IR=.trellis/scratch/binary64-negation-probe.ll
ASM=.trellis/scratch/binary64-negation-probe.s
"$R" --version --verbose
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir "$P" -o "$IR"
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm "$P" -o "$ASM"
sha256sum "$R" "$P" "$IR" "$ASM"
cat "$IR"
cat "$ASM"
Raw hash output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
Raw optimized LLVM IR function:
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
Raw optimized x86_64 assembly function:
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
Under the selected x86_64 C ABI, the symbolic input w arrives in %rdi and the
u64 result is returned in %rax. The loaded signed decimal constant
-9223372036854775808 has u64 bit pattern 0x8000000000000000, with bit 63 set
and every other bit clear. The emitted `xorq %rdi, %rax` therefore returns
w XOR 0x8000000000000000. There is no branch, floating-point exceptional
case, or input precondition in the emitted function.
Universal preservation conclusion
---------------------------------
The core macro and f64 instantiation connect the trait method to primitive
unary `-`; generated.lean and model-support.json connect that exact method to
ModelF64Neg. The parser source says the operation flips the sign bit in all
edge cases, while the primitive guarantee says every non-sign bit is preserved,
including the quiet/signaling and payload bits of NaNs. Finally, the symbolic
same-compiler/same-target probe makes the exact transformation explicit as XOR
with the bit-63 mask for its arbitrary u64 argument.
Because f64::from_bits accepts every one of the 2^64 u64 words and to_bits
returns the resulting raw word, the symbolic input covers the entire modeled
F64 carrier. Consequently the source result for every word is exactly the
model package's `ok` result containing that word with bit 63 toggled. This
includes both signs of zero and infinity, every finite/subnormal word, and
every possible NaN payload without canonicalization or quieting.
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/u64-bitand.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitAnd preservation evidence
================================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitAnd. The commands below were run from the repository
root on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790258751442882118.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790258751442882118.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790258751442882118.json
The exact U64 BitAnd entry in that index is:
name: U64.Insts.CoreOpsBitBitAndU64U64.bitand
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
source: /rustc/library/core/src/ops/bit.rs, lines 178:12-178:42
raw_declaration_sha256: 36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitAndU64U64.bitand") | .source_utf8' \
.trellis/scratch/inspect-native-1790258751442882118.json | sha256sum
Output:
36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line ranges are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '170,187p'
The pinned source says at lines 170-179:
macro_rules! bitand_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitAnd for $t {
type Output = $t;
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
and line 187 instantiates that implementation for u64:
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 conjunction `self & rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
--------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 105-116 and theorem at line 274 are:
def UScalar.and {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv &&& y.bv ⟩
instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where
hAnd x y := UScalar.and x y
theorem UScalar.bv_and {ty} (x y : UScalar ty) :
(x &&& y).bv = x.bv &&& y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 148-153 prove, for every width and bit index:
theorem BitVec.getElem!_and {w} (x y : BitVec w) (i : Nat) :
(x &&& y)[i]! = (x[i]! && y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_and, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.and_self]
Therefore `x &&& y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean conjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-bitor.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitOr preservation evidence
===============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitOr. The commands below were run from the repository root
on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790259866184055823.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790259866184055823.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790259866184055823.json
The exact U64 BitOr entry in that index is:
name: U64.Insts.CoreOpsBitBitOrU64U64.bitor
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
source: /rustc/library/core/src/ops/bit.rs, lines 282:12-282:41
raw_declaration_sha256: 85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitOrU64U64.bitor") | .source_utf8' \
.trellis/scratch/inspect-native-1790259866184055823.json | sha256sum
Output:
85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line range are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '274,291p'
The pinned source says at lines 274-289:
macro_rules! bitor_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitOr for $t {
type Output = $t;
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
forward_ref_binop! { impl BitOr, bitor for $t, $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
and line 291 instantiates that implementation for u64:
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 disjunction `self | rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
-------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 118-126 and theorem at line 275 are:
def UScalar.or {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv ||| y.bv ⟩
instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where
hOr x y := UScalar.or x y
theorem UScalar.bv_or {ty} (x y : UScalar ty) :
(x ||| y).bv = x.bv ||| y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 141-146 prove, for every width and bit index:
theorem BitVec.getElem!_or {w} (x y : BitVec w) (i : Nat) :
(x ||| y)[i]! = (x[i]! || y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_or, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.or_self]
Therefore `x ||| y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean disjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-shl-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x << count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shl.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shl preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shl. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a bounded U64 shift, and all U32 counts at least
64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790260978718245524.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790260978718245524.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790260978718245524.json
The exact U64 Shl entry in that fresh index is:
name: U64.Insts.CoreOpsBitShlU32U64.shl
extracted_signature: : Std.U64 → Std.U32 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
source: /rustc/library/core/src/ops/bit.rs, lines 489:12-489:41
raw_declaration_sha256: e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShlU32U64.shl") | .source_utf8' \
.trellis/scratch/inspect-native-1790260978718245524.json | sha256sum
Output:
e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d -
Thus this boundary is specifically u64 shifted by u32, and its extracted
codomain is the Aeneas Result used below to distinguish normal return from
checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '479,520p'
Lines 479-498 define the implementation macro:
macro_rules! shl_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shl<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shl(self, other: $f) -> $t {
self << other
}
}
forward_ref_binop! { impl Shl, shl for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 500-518 apply `shl_impl! { $t, u32 }` to every type in
`shl_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shl_impl_all {
($($t:ty)*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
shl_impl! { $t, u64 }
shl_impl! { $t, u128 }
shl_impl! { $t, usize }
...
)*)
}
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shl<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self << other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shl-probe.rs
with SHA-256:
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8
It places the same primitive expression `x << count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
./u64-shl-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir \
../../reference/model-evidence/u64-shl-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shl` operation and returns its bounded 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with the
expected truncation to 64 bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 17-21 and 29-31 define:
def UScalar.shiftLeft {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.shiftLeft s ⟩
else fail .integerOverflow
def UScalar.shiftLeft_UScalar {ty tys} (x : UScalar ty) (s : UScalar tys) :
Result (UScalar ty) :=
x.shiftLeft s.val
Lines 81-82 resolve the notation used by Tablet/ModelU64Shl.lean:
instance {ty0 ty1} : HShiftLeft (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftLeft x y := UScalar.shiftLeft_UScalar x y
Consequently `x <<< y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the 64-bit vector shift; at least 64 it is
exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftLeft_spec`, lines 193-205, proves the successful
branch has both equivalent bounded descriptions:
theorem UScalar.ShiftLeft_spec ... (hy : y.val < ty0.numBits) ... :
(x <<< y) ⦃ z =>
z.val = (x.val <<< y.val) % size ∧
z.bv = x.bv <<< y.val ⦄
For U64, `size` is `2^64`; hence the returned natural value is the mathematical
left shift reduced modulo `2^64`, and the returned carrier is exactly the
corresponding 64-bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 248-266 give the bit-level characterization: every result bit below
the shift count (or outside the fixed width) is false, and every in-width bit at
or above the count equals the corresponding input bit at index `i - n`:
theorem BitVec.getElem!_shiftLeft_false ...
(h : i < n ∨ w ≤ i) : (v <<< n)[i]! = false
theorem BitVec.getElem!_shiftLeft_eq ...
(h : n ≤ i ∧ i < w) : (v <<< n)[i]! = v[i - n]!
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive U64 shift. The Aeneas branch condition also succeeds and returns
`ok` of `BitVec.shiftLeft n`. `UScalar.ShiftLeft_spec` and the BitVec lemmas
identify both results as the same 64-bit word, equivalently `(x * 2^n) mod
2^64`, with discarded high bits and zero-filled low bits.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shl preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
reference/model-evidence/u64-shr-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x >> count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shr.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shr preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shr. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a logical U64 right shift, and all U32 counts at
least 64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790262316075577976.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790262316075577976.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790262316075577976.json
The exact U64 Shr entry in that fresh index is:
name: U64.Insts.CoreOpsBitShrU32U64.shr
extracted_signature: : Std.U64 -> Std.U32 -> Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
source: /rustc/library/core/src/ops/bit.rs, lines 612:12-612:41
raw_declaration_sha256: 77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 -> Std.U32 -> Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShrU32U64.shr") | .source_utf8' \
.trellis/scratch/inspect-native-1790262316075577976.json | sha256sum
Output:
77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f -
Tablet/model-support.json binds precisely this indexed declaration and
signature to dec2flt_model.ModelU64Shr. Thus the boundary is specifically u64
shifted by u32, and its extracted codomain is the Aeneas Result used below to
distinguish normal return from checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '602,641p'
Lines 602-620 define the implementation macro:
macro_rules! shr_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shr<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shr(self, other: $f) -> $t {
self >> other
}
}
forward_ref_binop! { impl Shr, shr for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 623-641 apply `shr_impl! { $t, u32 }` to every type in
`shr_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shr_impl_all {
($($t:ty)*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
shr_impl! { $t, u64 }
shr_impl! { $t, u128 }
shr_impl! { $t, usize }
...
)*)
}
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shr<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self >> other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shr-probe.rs
with SHA-256:
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee
It places the same primitive expression `x >> count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
./u64-shr-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir \
../../reference/model-evidence/u64-shr-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shr` operation and returns its logical 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with
zero-filled high bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 23-35 define:
def UScalar.shiftRight {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.ushiftRight s ⟩
else fail .integerOverflow
def UScalar.shiftRight_UScalar {ty tys} (x : UScalar ty)
(s : UScalar tys) : Result (UScalar ty) :=
x.shiftRight s.val
Lines 93-94 resolve the notation used by Tablet/ModelU64Shr.lean:
instance {ty0 ty1} : HShiftRight (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftRight x y := UScalar.shiftRight_UScalar x y
Consequently `x >>> y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the unsigned 64-bit vector shift; at least
64 it is exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftRight_spec`, lines 166-174, proves the successful
branch has both equivalent logical-shift descriptions:
theorem UScalar.ShiftRight_spec ... (hy : y.val < ty0.numBits) :
(x >>> y) ⦃ z =>
z.val = x.val >>> y.val ∧
z.bv = x.bv >>> y.val ⦄
Here natural-number `>>>` is division by `2^y.val`, so the returned numeric
value is `floor(x.val / 2^y.val)`, and the returned carrier is exactly the
unsigned shift of the fixed-width bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 268-283 give the bit-level logical zero-fill characterization. For
every result position, the total bit lookup is the input bit at the offset
position; positions whose offset is outside the 64-bit input are false:
theorem BitVec.getElem!_shiftRight {w} (v : BitVec w) (n i : Nat) :
(v >>> n)[i]! = v[n + i]!
theorem BitVec.getElem_shiftRight_false {m n : Nat} (v : BitVec m)
(hm : i < m) (h : m <= n + i) :
(v >>> n)[i]'hm = false
Together with `BitVec.getElem_shiftRight_lt`, this states that every in-range
source bit moves downward by the count and every newly exposed high bit is
zero. Because the carrier is unsigned, there is no sign extension.
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive unsigned U64 right shift. The Aeneas branch condition also
succeeds and returns `ok` of `BitVec.ushiftRight n`. `UScalar.ShiftRight_spec`
and the BitVec lemmas identify both results as the same 64-bit word,
equivalently `floor(x / 2^n)`, with every newly exposed high bit filled by zero.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shr preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:413dd882adfeb3964b4e265f6d6f4c4b98fa9c560a08a18186b5fc59c6b12030 |
| Preservation current fingerprint | preservation-v1:413dd882adfeb3964b4e265f6d6f4c4b98fa9c560a08a18186b5fc59c6b12030 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","lean_semantic_closure":"eb3665125cfccd3338b901a3a743d3789335315a8f2ca7a0988e6a1cd4962f11","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","lean_semantic_closure":"eb3665125cfccd3338b901a3a743d3789335315a8f2ca7a0988e6a1cd4962f11","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["Binary64Model","F64","core_num_FpCategory"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "06494fa978be141a1ae5fa81b06da5a0a2073f3a1ca899206582183a70112b74",
"dep_statement_hashes": {
"Binary64NativeCallDomain": "5b06c401ea7b8fe802a4cae40bcf11c5e438e342f3284a9e27ea421e01cb3642",
"DecimalGoalVocabularyDefault": "32a84a43f71314245b7cbbbce3aefa2bde7d8120fb1fddb93ff7b90796f8a87b",
"DispatchContracts": "4515ac9357cf79a45937c80584897befcb3040702c14d0c55f1a5adeccc02d25"
},
"combined_sound_fp": "preservation-v1:413dd882adfeb3964b4e265f6d6f4c4b98fa9c560a08a18186b5fc59c6b12030"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T2_current-applicability.txt",
"sha256": "aefdc935645f37c69a2c3f2e7c2fb00baad81970455148f3dbb591b0eeabced3",
"cited_by": [
"Tablet/Binary64ModelDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/Binary64ModelDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation-probe.rs",
"sha256": "268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5",
"cited_by": [
"Tablet/Binary64ModelDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation.txt",
"sha256": "e19a2cd2283c8435f6d6107d06ccc798cbba4d63f0220b32b5216e43ad071aac",
"cited_by": [
"Tablet/Binary64ModelDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"Tablet/Binary64ModelDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/u64-bitand.txt",
"sha256": "6a48b1a79f8a52a27fb06a0b25cda9de24f68395d66ab668ecac721806883f54",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-bitor.txt",
"sha256": "f3dadaec6c4ebc98d0d3178bf29df7436e52998b6b97e8d108ca97a6f8092e70",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl-probe.rs",
"sha256": "a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shl.txt"
]
},
{
"path": "reference/model-evidence/u64-shl.txt",
"sha256": "e4cacfd29333a91c1258524a520e849325a85a05cf50b0065ffbf91d7977f69c",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shr-probe.rs",
"sha256": "11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/u64-shr.txt",
"sha256": "c0295af2452a4748bc1a642580414acfc76285ba87b6203b6cbff7ff9924b6ad",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
}
]DecimalGoalVocabulary
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.DecimalLexeme
import Tablet.F64
import Tablet.num_imp_dec2flt_common_BiasedFp
import Tablet.num_imp_dec2flt_decimal_Decimal
import Mathlib.Data.Real.Basic
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalGoalVocabulary]
structure DecimalGoalVocabulary where
-- BODY
bytes : Slice Std.U8 -> List Nat
sourceString : Str -> Prop
validNumeric : DecimalLexeme -> Prop
renderNumeric : DecimalLexeme -> List Nat
lexicalNegative : DecimalLexeme -> Bool
specialLiteral : List Nat -> Option Bool -> Bool -> Prop
classifies : List Nat -> Option (Sum DecimalLexeme (Option Bool × Bool)) -> Prop
mathExplicitExponent : DecimalLexeme -> Int
accumulatedExplicitExponent : DecimalLexeme -> Int
exactMagnitude : DecimalLexeme -> Real
accumulatedMagnitude : DecimalLexeme -> Real
decimalMagnitude : num.imp.dec2flt.decimal.Decimal -> Real
roundsMagnitude : Real -> F64 -> Prop
isNan : F64 -> Prop
isInfinity : Bool -> F64 -> Prop
isNegative : F64 -> Prop
signedMagnitude : Bool -> F64 -> F64 -> Prop
assembledWord : num.imp.dec2flt.common.BiasedFp -> F64 -> Prop
end dec2flt_model
Why this model is faithful
Definition
Decimal record; binary64 magnitude
rounding; NaN, signed infinity, and sign-bit observations; application of a
lexical sign to a magnitude word; and unrestricted BiasedFp assembly.Preservation argument
Claim
DecimalGoalVocabulary record is a noncomputational vocabulary
package. It supplies named fields for observing slice bytes, admitting source
strings, stating numeric and special grammar and classification, interpreting
explicit exponents and decimal values, relating real magnitudes to binary64
words, observing NaN, infinity, and sign bits, applying a lexical sign, and
interpreting raw-pair assembly. The record itself asserts no execution fact:
in particular it does not preserve termination, panic versus normal return,
the outer Aeneas Result versus the returned Rust Result,
Option/Result discriminants, returned Decimal
fields, selected-pair trace state, component compliance, deferral, or the
behavior of any extracted call.Proof
Str is
definitionally Slice U8, so those carrier types alone do not
distinguish Rust strings from byte slices. The sourceString field
receives its concrete length-bounded UTF-8 meaning only in
DecimalGoalVocabularyDefault; the complete arbitrary-byte Rust
&[u8] carrier is instead identified by the separate
SourceValidByteSlice definition. The bytes field is total
on every model slice and carries no source-length premise. Likewise,
classifies accepts every finite natural-number list and
roundsMagnitude accepts every real input. Thus the purely
mathematical list and real relations are not restricted to source-representable
inputs. Concrete grammar, value, rounding, word, sign, and assembly meanings
are supplied by DecimalGoalVocabularyDefault, not by an execution
claim in this record.Authored arguments for individual requirements
Requirement: parser totality
sourceString predicate for the parser's source domain. Termination, panic versus normal return, and the distinction between the outer Aeneas result and returned Rust result belong to the source-model and operation-preservation owners.Requirement: parser numeric acceptance
sourceString, bytes, validNumeric, and renderNumeric to state the source domain and numeric grammar. Normal return and the returned Ok discriminant are left to the parser-operation owner.Requirement: parser invalid rejection
sourceString, bytes, and classifies to state complete-input invalidity. It makes no claim that the parser returns normally or returns Err; those are parser-operation facts.Requirement: parser nan acceptance
sourceString, bytes, specialLiteral, and isNan for NaN grammar and the word predicate. Acceptance, normal return, and Ok are left to the parser-operation owner.Requirement: parser infinity
sourceString, bytes, specialLiteral, and isInfinity for signed infinity grammar and words. It does not assert a normal or successful parser return.Requirement: parser non nan results
sourceString, bytes, specialLiteral, and isNan to state the input exclusion and output-word observation. The implication from a successful extracted return to a non-NaN word is left to parser preservation.Requirement: parser numeric sign
sourceString, the numeric grammar fields, lexicalNegative, and signedMagnitude. It does not assert that parsing succeeds or that an extracted return satisfies the sign relation.Requirement: parser signed zero
sourceString, the numeric grammar fields, exactMagnitude, lexicalNegative, and signedMagnitude to express zero and its lexical sign. Acceptance and the returned word remain parser-operation facts.Requirement: parser exact rounding
sourceString, the numeric grammar fields, exactMagnitude, roundsMagnitude, lexicalNegative, and signedMagnitude. It does not infer acceptance or connect an extracted return to those relations.Requirement: parser selected exponent
sourceString to this parser goal; it has no trace-selection or biased-exponent-range field. Normal success, selection of a raw pair, and its exponent bound belong to the traced source model and operation-preservation owners.Requirement: parser selected magnitude sign
sourceString and assembledWord to interpret a supplied raw pair and word. It does not establish successful execution, trace selection, or the selected word's clear sign bit.Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
sourceString, the numeric grammar fields, accumulatedMagnitude, roundsMagnitude, lexicalNegative, and signedMagnitude. Acceptance and the relation of an extracted return to those fields remain parser-operation facts.Requirement: parser equal target rounding
sourceString, the numeric grammar fields, both magnitude interpretations, roundsMagnitude, lexicalNegative, and signedMagnitude. It neither asserts acceptance nor proves that a returned word is the common target.Requirement: number helper acceptance
bytes, validNumeric, and renderNumeric for the unsigned numeric grammar; normal return and Some are left to the numeric-helper operation owner.Requirement: number helper rejection
bytes, validNumeric, and renderNumeric to state failure of the unsigned grammar, not the helper's normal return or None.Requirement: number helper record bounds
bytes observation. Returned-record fields, the Some discriminant, normal return, negativity, and the mantissa bound are not fields or consequences of this vocabulary record.Requirement: number helper accumulated value
bytes, the unsigned numeric grammar, accumulatedMagnitude, and decimalMagnitude; the optional return and its record/value relationship belong to numeric-helper preservation.Requirement: special helper infinity
bytes, specialLiteral, and isInfinity; normal return, Some, and the helper's use of the separate sign argument are operation facts.Requirement: special helper nan
bytes, specialLiteral, and isNan; normal return and Some are left to special-helper preservation.Requirement: special helper rejection
bytes and specialLiteral for the keyword grammar; normal return and None remain special-helper operation facts.Requirement: native correct or defer
decimalMagnitude, roundsMagnitude, and signedMagnitude to express the record value, target, and sign. Normal return, None/Some, many_digits, and both native paths belong to native-operation preservation.Requirement: integer correct or defer
roundsMagnitude and assembledWord to interpret a real target and a supplied raw pair. It does not preserve normal return, deferral, or production of that pair by the integer operation.Requirement: slow accumulated rounding
accumulatedMagnitude, roundsMagnitude, and assembledWord; normal return and production of a raw pair are left to slow-operation preservation.Requirement: assembly correspondence
assembledWord as the relation between an unrestricted supplied raw pair and a word. Normal return and agreement of the extracted assembly call with that relation belong to assembly-operation preservation.Requirement: classification totality
classifies field has the unrestricted finite-list domain required by this mathematical goal, independently of Rust length or UTF-8 validity. Merely supplying that relation does not prove that every byte list has a classification.Requirement: classification determinism
classifies relation records complete numeric content on finite byte lists. This vocabulary contribution does not prove uniqueness of classifications or parsed lexemes.Requirement: classification significand digit
classifies and validNumeric fields provide the mathematical grammar vocabulary for significand digits. This node does not prove the claimed digit-existence theorem.Requirement: rounding totality
roundsMagnitude field is a relation on unrestricted real inputs and binary64 words, with no source-domain bound. Supplying the relation does not prove that a target exists for every nonnegative real.Requirement: rounding determinism
roundsMagnitude field supplies one unrestricted real-to-word relation for both target hypotheses. This vocabulary record does not prove uniqueness of the targets.Requirement: exponent value agreement
roundsMagnitude are separate unrestricted mathematical fields. This node does not prove that equality of exponents yields agreement of rounding targets.Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
DecimalGoalVocabulary · Lean checked
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:a3b7ced1aa346f9d8d07b707203969a05b7bdb1e423036e2fae40ecb98d5070a |
| Preservation current fingerprint | preservation-v1:a3b7ced1aa346f9d8d07b707203969a05b7bdb1e423036e2fae40ecb98d5070a |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","lean_semantic_closure":"c5e131808ca7c2258bd4e9ab3ac387fb18520c3691a9cb8189466ab4bb44dd2a","lean_relevant_definition_descendants":{"DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["DecimalLexeme","F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","lean_semantic_closure":"c5e131808ca7c2258bd4e9ab3ac387fb18520c3691a9cb8189466ab4bb44dd2a","lean_relevant_definition_descendants":{"DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["DecimalLexeme","F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "fdccd846654e841007712806bb2ede776139b9b05d0b4fcf6f32ea94f451f353",
"dep_statement_hashes": {
"DecimalGoalVocabularyDefault": "32a84a43f71314245b7cbbbce3aefa2bde7d8120fb1fddb93ff7b90796f8a87b",
"SourceValidByteSlice": "52522ae5b8602c6279dde2af31f94e21db249400641f5d3e951f68a74c3c11e2"
},
"combined_sound_fp": "preservation-v1:a3b7ced1aa346f9d8d07b707203969a05b7bdb1e423036e2fae40ecb98d5070a"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}DecimalGoalVocabularyDefault
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.DecimalGoalVocabulary
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalGoalVocabularyDefault]
noncomputable def DecimalGoalVocabularyDefault : DecimalGoalVocabulary :=
-- BODY
let signBytes := fun sign : Option Bool =>
match sign with | none => [] | some negative => [if negative then 45 else 43]
let digitByte := fun d : Nat => 48 + d
let allDigits := fun ds : List Nat => ∀ d ∈ ds, d < 10
let validNumeric := fun x : DecimalLexeme =>
allDigits x.integerDigits ∧
(match x.fractionDigits with | none => True | some ds => allDigits ds) ∧
(x.integerDigits ≠ [] ∨
match x.fractionDigits with | none => False | some ds => ds ≠ []) ∧
(match x.exponent with | none => True | some (_, _, ds) => ds ≠ [] ∧ allDigits ds)
let renderNumeric := fun x : DecimalLexeme =>
signBytes x.leadingSign ++ x.integerDigits.map digitByte ++
(match x.fractionDigits with | none => [] | some ds => 46 :: ds.map digitByte) ++
(match x.exponent with
| none => []
| some (upper, sign, ds) =>
(if upper then 69 else 101) ::
(match sign with | none => [] | some neg => [if neg then 45 else 43]) ++
ds.map digitByte)
let asciiCaseEq := fun xs ys : List Nat =>
List.Forall₂ (fun actual lower => actual = lower ∨ actual + 32 = lower) xs ys
let specialLiteral := fun bs : List Nat => fun sign : Option Bool => fun nan : Bool =>
∃ body, bs = signBytes sign ++ body ∧
if nan then asciiCaseEq body [110, 97, 110]
else asciiCaseEq body [105, 110, 102] ∨
asciiCaseEq body [105, 110, 102, 105, 110, 105, 116, 121]
let numericLiteral := fun bs : List Nat => fun x : DecimalLexeme =>
validNumeric x ∧ renderNumeric x = bs
let classifies := fun bs : List Nat =>
fun c : Option (Sum DecimalLexeme (Option Bool × Bool)) =>
match c with
| some (Sum.inl x) => numericLiteral bs x
| some (Sum.inr (sign, nan)) => specialLiteral bs sign nan
| none => (¬ ∃ x, numericLiteral bs x) ∧ (¬ ∃ sign nan, specialLiteral bs sign nan)
let digitsValue : List Nat -> Nat :=
fun ds => ds.foldl (fun (n d : Nat) => 10 * n + d) 0
let exponentValue := fun x : DecimalLexeme =>
match x.exponent with
| none => 0
| some (_, sign, ds) =>
let n : Int := digitsValue ds
match sign with | some true => -n | _ => n
let accumulatedExponentValue := fun x : DecimalLexeme =>
match x.exponent with
| none => 0
| some (_, sign, ds) =>
let n : Nat := ds.foldl
(fun (n d : Nat) => if n < 576460752303423488 then 10 * n + d else n) 0
match sign with | some true => -(n : Int) | _ => (n : Int)
let fractionCount := fun x : DecimalLexeme =>
match x.fractionDigits with | none => 0 | some ds => ds.length
let significandDigits := fun x : DecimalLexeme =>
x.integerDigits ++ match x.fractionDigits with | none => [] | some ds => ds
let magnitudeWithExponent := fun x : DecimalLexeme => fun e : Int =>
(digitsValue (significandDigits x) : Real) *
(10 : Real) ^ (e - (fractionCount x : Int))
let signBit : Nat := 2 ^ 63
let fractionUnit : Nat := 2 ^ 52
let infinityBits : Nat := 2047 * fractionUnit
let finiteMagnitudeValue := fun bits : Nat =>
let e := bits / fractionUnit
let m := bits % fractionUnit
if e = 0 then
(m : Real) / ((2 : Real) ^ (1074 : Nat))
else if 1075 <= e then
((fractionUnit + m : Nat) : Real) * ((2 : Real) ^ (e - 1075))
else
((fractionUnit + m : Nat) : Real) / ((2 : Real) ^ (1075 - e))
let overflowThreshold : Real :=
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat))
let roundsMagnitude := fun x : Real => fun w : F64 =>
0 <= x ∧ w.val <= infinityBits ∧
if w.val = infinityBits then overflowThreshold <= x
else x < overflowThreshold ∧
∀ v : F64, v.val < infinityBits -> v ≠ w ->
abs (x - finiteMagnitudeValue w.val) <= abs (x - finiteMagnitudeValue v.val) ∧
(abs (x - finiteMagnitudeValue w.val) = abs (x - finiteMagnitudeValue v.val) ->
w.val % 2 = 0)
{
bytes := fun s => s.val.map (fun b => b.val)
sourceString := fun s => s.val.length <= 9223372036854775807 ∧
∃ t : String, s.val.map (fun b => b.val) = t.toUTF8.toList.map UInt8.toNat
validNumeric := validNumeric
renderNumeric := renderNumeric
lexicalNegative := fun x => x.leadingSign = some true
specialLiteral := specialLiteral
classifies := classifies
mathExplicitExponent := exponentValue
accumulatedExplicitExponent := accumulatedExponentValue
exactMagnitude := fun x => magnitudeWithExponent x (exponentValue x)
accumulatedMagnitude := fun x => magnitudeWithExponent x (accumulatedExponentValue x)
decimalMagnitude := fun d => (d.mantissa.val : Real) * (10 : Real) ^ d.exponent.val
roundsMagnitude := roundsMagnitude
isNan := fun w =>
(w.val % signBit) / fractionUnit = 2047 ∧ w.val % fractionUnit ≠ 0
isInfinity := fun negative w =>
w.val = infinityBits + if negative then signBit else 0
isNegative := fun w => signBit <= w.val
signedMagnitude := fun negative magnitude result =>
magnitude.val < signBit ∧ result.val = magnitude.val + if negative then signBit else 0
assembledWord := fun fp w =>
w.val = Nat.lor fp.m.val
(((fp.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64))
}
end dec2flt_model
Why this model is faithful
Definition
Str is source-valid
exactly when its byte list has length at most
\mathtt{isize::MAX}=9223372036854775807 and is the UTF-8 encoding of a Lean
string. A numeric
lexeme has an optional minus or plus sign and is valid exactly when every
recorded digit is in 0,\ldots,9, at least
one digit occurs on either side of the optional point, and a present exponent
has at least one digit. Rendering uses ASCII, an optional leading sign, the
recorded optional point, and an optional e/E exponent with
its optional sign. Special literals are optionally signed
inf, infinity, or nan, ASCII case-insensitively.
Classification is numeric with its complete lexeme, special with its sign and
kind, or invalid exactly when neither grammar matches.Decimal has magnitude \mathit{mantissa}\,10^{\mathit{exponent}}.BiasedFp assembly is the low 64 bits of the
mantissa OR the Rust two's-complement i32-to-u64 cast of the
biased exponent shifted left by 52.Preservation argument
Claim
str domain, while its total byte observation also applies
to every source-valid arbitrary-byte slice in SourceValidByteSlice.
Its rounding field expresses binary64 magnitude round-to-nearest,
ties-to-even, including subnormals and overflow, but makes no assertion that a
target exists or is unique. Its assembly field covers every value of both
fields of an unrestricted source BiasedFp. The instance supplies
vocabulary only: it does not assert parser termination, return discriminants,
record bounds, trace selection, component compliance, deferral behavior, or
the truth of any principal GOAL theorem.Proof
Slice U8 an ordered list subtype, and all relevant slice observations
retain that order. Consequently s.val.map (fun b => b.val) maps every
represented element, in order and without omission, to the natural-number
value of its unsigned eight-bit scalar
(reference/model-evidence/aeneas-slice-observations.txt). Thus
bytes is the complete unsigned byte list, not a UTF-8-filtered
observation. The first conjunct of sourceString is precisely the
\mathtt{isize::MAX}=2^{63}-1 source-length condition, as established for the
configured target by SourceValidByteSlice and
reference/model-evidence/source-valid-byte-slice.txt.t.toUTF8 is definitionally t.toByteArray, and the proof field
of the String structure shows that this byte array is in the image of
List.utf8Encode; equality of the lists of unsigned byte values
identifies it with the Aeneas bytes, so those bytes are valid UTF-8.
Conversely, if the source bytes are valid UTF-8, the constructor of
ByteArray.IsValidUTF8 supplies a character list whose
List.utf8Encode is exactly that byte array. Applying
String.fromUTF8 to the byte array and this proof constructs a Lean
string whose toUTF8, by definition, is the original array, furnishing
the existential. Rust str requires exactly valid UTF-8 in addition
to the same length bound
(reference/model-evidence/source-valid-byte-slice.txt), so
sourceString is equivalent in both directions to the configured Rust
string domain rather than merely assuming an unspecified UTF-8 equivalence.allDigits says exactly that each stored natural is
one of 0,\ldots,9. The four conjuncts of validNumeric require this
for the integer digits, for present fractional digits, and for present
exponent digits; require at least one digit in the integer/fraction pair; and
require a present exponent to contain at least one digit. In
renderNumeric, none, some false, and
some true for the leading sign render respectively as no byte,
ASCII plus, and ASCII minus. Integer digits render as 48+d; a present
fraction renders one point byte 46 followed by its digits; and a present
exponent renders ASCII e or E, its independently optional
plus/minus sign, and its digits. Equality with the complete input byte list in
numericLiteral leaves no whitespace, suffix, second point, or other
extra byte. These are exactly the optional-sign, point, e/E,
and exponent clauses pinned from the reference in
reference/model-evidence/goal-vocabulary.txt.asciiCaseEq, List.Forall2 first forces the two lists to
have equal length. At each position whose required lowercase ASCII byte is
l\in\{97,102,105,110,116,121\}, the disjunction is
a=l or a+32=l, hence a is exactly the lowercase byte l or its uppercase
byte l-32. Therefore the three fixed lists accept exactly ASCII
case-variants of nan, inf, and infinity.
specialLiteral prepends precisely the optional sign bytes and selects
nan when its Boolean is true and one of the two infinity spellings
when it is false. Finally, unfolding classifies shows: a left value
is related exactly by numericLiteral; a right value is related
exactly by specialLiteral; and none is related exactly when
there exists neither a numeric lexeme nor a special sign/kind witness. Thus
the invalid case is precisely the complement of the two complete grammars,
without any assertion that successful witnesses are unique.lexicalNegative is true exactly when the
DecimalLexeme leading-sign field is some true, the encoding
of a rendered minus. The fold digitsValue starts at zero and replaces
n by 10n+d for every digit, so for all-digit lists it is their ordinary
base-ten value, including leading zeroes. Accordingly
mathExplicitExponent is zero when absent and otherwise applies the
recorded minus exactly for sign some true. The accumulated fold
performs the same update exactly while the previous accumulator is below
2^{59}, and otherwise retains it. An update from 0\leq a<2^{59}
and 0\leq d\leq9 lies in [0,10\cdot2^{59}-1], whose upper endpoint
is 5764607523034234879<2^{63}-1; ExponentFoldBounds
establishes this invariant for every finite digit list and starting state.
Multiplication and addition are therefore
exact even with overflow checks. Induction on digit prefixes identifies
the fold with the accumulator after each source update. A stopped update
retains the accumulator, not the scanning position: the source still consumes
every following digit and returns the first nondigit suffix. Negation after
scanning is exact because the accumulator is nonnegative and below the I64
maximum. The fold names only that value, not acceptance or termination of
the enclosing parser. ScientificVocabularyFold proves this
natural digit fold equals the actual signed scientific result and suffix,
without an A restriction. NumberHelperScientificClassificationSourceLength
keeps empty digit prefixes as normal None on the exact sign-stripped suffix.
This is the current source loop,
including its update test, pinned in
reference/model-evidence/goal-vocabulary.txt.fractionCount counts exactly the latter.
Therefore exactMagnitude is
N10^{e-f} for the all-digit significand value N, mathematical explicit
exponent e, and fractional length f; accumulatedMagnitude is the
same all-digit formula with the bounded-fold exponent. Independently, for
every extracted Decimal record d, decimalMagnitude is the
unsigned real d.\mathit{mantissa}\,10^{d.\mathit{exponent}}. Its sign is not
lexical: where needed it is the separate record field d.\mathit{negative}.finiteMagnitudeValue is
m/2^{1074}=m2^{-1074}, including zero and every subnormal. When e>0, its
two executable branches are respectively
(2^{52}+m)2^{e-1075} for e\ge1075 and
(2^{52}+m)/2^{1075-e}=(2^{52}+m)2^{e-1075} below 1075.
Thus all and only finite nonnegative binary64 magnitude candidates are covered
with their ordinary values. The 11-bit exponent, 52-bit fraction, and IEEE
interpretation are independently pinned in
reference/model-evidence/binary64-boundary.txt.roundsMagnitude requires its finite
candidate to have distance no greater than every other finite candidate; if a
competitor is at equal distance, it requires the selected word's low bit to be
even. This is exactly nearest selection and the even-low-bit tie condition.
The maximum finite value is
(2^{53}-1)2^{971}=2^{1024}-2^{971}, its top-binade spacing is 2^{971},
and adding half that spacing gives the overflow midpoint
2^{1024}-2^{970}. At or above that midpoint the relation selects the
positive-infinity word; below it the infinity branch is impossible and the
finite branch applies. These clauses establish the meaning of the relation
only. They do not supply a target or prove two targets equal, leaving
rounding_totality and rounding_determinism as the unresolved
principal theorem obligations.isNan means exponent 2047 and nonzero fraction.
isInfinity requires exponent 2047, zero fraction, and adds the sign
bit exactly when its Boolean is true. Since every carrier word is below
2^{64}, isNegative tests exactly whether bit 63 is set.
signedMagnitude requires a zero-sign-bit input and either leaves it
unchanged or adds 2^{63}, so it applies the requested sign without changing
the exponent or fraction; this includes the two zeros and the two infinities.p_biased : i32 to u64, shifts it by the f64
significand width 52, and ORs it with m. For every signed field value
p, sign extension to a 64-bit word has unsigned value
(p\mathbin{\mathrm{emod}}2^{64}).\mathit{toNat}: it is p for
p\ge0 and 2^{64}+p for p<0. For every such cast word, shifting left by
52 is multiplication by 2^{52} modulo 2^{64}, by the complete U64 shift
semantics in reference/model-evidence/u64-shl.txt. The
Nat.lor of that result with the unrestricted U64 mantissa has exactly
the per-bit disjunction of the Rust U64 OR, by
reference/model-evidence/u64-bitor.txt. Therefore
assembledWord is the exact source cast/shift/OR word for every
unrestricted BiasedFp; no exponent-range or nonoverlap premise has
been introduced.Authored arguments for individual requirements
Requirement: parser totality
sourceString is exactly the complete configured Rust-string domain, and bytes retains its ordered bytes. This vocabulary makes no termination, panic, or Result claim; those remain with the dispatcher operation and totality theorem. The obligation's A bound is on complete string length, not on any shortened body.Requirement: parser numeric acceptance
validNumeric plus complete rendering is exactly the whole-input numeric grammar. Normal return and the public Ok discriminant remain with the parser operation. The original acceptance domain has complete string length at most A.Requirement: parser invalid rejection
none classification is precisely the complement of both complete grammars. Normal return and the public Err value remain with the parser operation. The original rejection domain has complete string length at most A.Requirement: parser nan acceptance
specialLiteral gives exactly the optionally signed case-insensitive nan grammar and isNan gives exactly the exponent-all-ones, nonzero-fraction words. Acceptance and the returned payload are operation facts.Requirement: parser infinity
specialLiteral retains the optional lexical sign and isInfinity gives the corresponding signed infinity word. Acceptance and production of that word remain parser facts.Requirement: parser non nan results
Requirement: parser numeric sign
lexicalNegative, and signedMagnitude applies that Boolean even to zero and infinity. The connection to every successful parser result remains operation behavior.Requirement: parser signed zero
signedMagnitude maps its zero word to positive or negative zero according to lexicalNegative. Acceptance and returned-word selection remain parser facts.Requirement: parser exact rounding
roundsMagnitude is the full binary64 magnitude relation. Parser acceptance and selection of a related word remain operation behavior. The original exact-rounding obligation restricts complete string length to B without restricting exponent digits.Requirement: parser selected exponent
assembledWord relation adds no well-formedness premise to raw pairs. Which pairs a successful trace selects and the asserted 0\ldots2047 bound remain with trace and dispatcher preservation.Requirement: parser selected magnitude sign
isNegative reads its sign bit exactly. Successful trace selection and the proof that selected magnitudes have clear sign bits remain with the dispatcher.Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
accumulatedMagnitude retains every significand digit and uses exactly the source threshold fold. Acceptance and production of a related target remain parser behavior. The original diagnostic restricts complete string length to A.Requirement: parser equal target rounding
Requirement: number helper acceptance
validNumeric and renderNumeric with leading sign none; normal return and Some remain numeric-helper behavior. The original acceptance domain also requires nonemptiness and slice length at most A.Requirement: number helper rejection
None remain numeric-helper behavior. The original rejection domain also requires nonemptiness and slice length at most A.Requirement: number helper record bounds
bytes adds no content restriction. Nonemptiness, normal return, Some, record negativity, and the mantissa bound remain with numeric-helper preservation.Requirement: number helper accumulated value
many_digits branch, equality, and half-open bounds remain helper behavior. The original representation obligation restricts this unsigned slice to length at most A.Requirement: special helper infinity
specialLiteral (bytes s) none false. The separate Boolean argument is not a lexical sign and is used only in isInfinity for the returned word; normal return and Some remain special-helper behavior.Requirement: special helper nan
specialLiteral (bytes s) none true; the separate sign argument does not alter that grammar. isNan accepts every NaN payload, while normal return and Some remain special-helper behavior.Requirement: special helper rejection
specialLiteral cases with sign none is exactly failure of the unsigned keyword grammar, independently of the separate sign argument. Normal return and None remain special-helper behavior.Requirement: native correct or defer
decimalMagnitude d is its unsigned \mathit{mantissa}\,10^{\mathit{exponent}}, and signedMagnitude d.negative uses the Decimal record sign, not a lexical sign. Normal return, None/Some, many_digits, and both native paths remain native-operation behavior.Requirement: integer correct or defer
Requirement: slow accumulated rounding
none, accumulated magnitude retains the full significand, and rounding plus assembly have their exact meanings. Normal return and production of a raw pair remain slow-operation behavior.Requirement: assembly correspondence
assembledWord is exactly the Rust i32-to-u64 cast modulo 2^{64}, 52-bit left shift modulo 2^{64}, and U64 bitwise OR. Normal return and the final from_u64_bits observation remain with the assembly operation and float binding.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
validNumeric lexeme explicitly has a nonempty integer list or a present nonempty fraction list. The principal grammar consequence is left to its theorem proof.Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
DecimalGoalVocabularyDefault · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/P89_T1_PrimitiveApplicability.txt
Current first/split_first/as_bytes applicability
==============================================
This is CURRENT primary source/extraction inspection, not a parser execution
or a GOAL verdict. It was independently checked in request 99, task 10, from
/home/leanagent/math/dec2flt-r0003-runtime/dispatch/10/repo.
The prior task-8 candidate was accepted=false and is only advisory. All commands
in the fresh inspection transcript below exited 0; their unmodified outputs
are recorded separately from the historical predecessor records.
The predecessor records aeneas-slice-observations.txt and
aeneas-string-bytes.txt retain their original 45b5027c... extraction identity;
their old call locations are not used as current inventory.
1. Identities and unchanged library meanings
-------------------------------------------
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Raw output:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw output:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Raw output (path suffixes abbreviated only here):
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
These are the same executable/library/core-source identities as the historical
records. Slice.lean:22 still defines
def Slice (a : Type u) := { l : List a // l.length <= Usize.max }
(ASCII rendering of the Lean alpha and inequality). String.lean:6 defines
def Str := Slice U8
The overview:240 says shared borrows (&T) become plain T parameters, which may
be copied; its table:432 describes them as immutable. The actual pinned core
bodies (sed -n '155,157p' .../core/src/slice/mod.rs,
sed -n '198,200p' .../core/src/slice/mod.rs, and
sed -n '498,501p' .../core/src/str/mod.rs) are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
No primitive body or representation change is being introduced.
These are read-only inspections with no compiler invocation, new build setting
or extraction invocation. The audited manifest, toolchain, target and extraction
configuration remain fixed. The full paths and exact Unicode representations
are retained in the fresh inspection transcript below. The separate
source-valid-byte-slice.txt record supplies the target isize::MAX bound and
Rust str's UTF-8 condition; a general &[u8] does not require UTF-8.
2. Exact current externals and support reconciliation
----------------------------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
Result: declaration_count=24; full inventory retained at
.trellis/scratch/inspect-native-1791579714814493776.json
The three entries selected by their exact names have the following unchanged
signatures, Rust symbols and raw declaration SHA256 values. Unicode below is
retained to copy the exact inventory signatures.
name: core.slice.Slice.first
extracted_signature: {T : Type} : Slice T → Result (Option T)
rust_symbol: core::slice::{[T]}::first
raw_declaration_sha256: 221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105
name: core.slice.Slice.split_first
extracted_signature: {T : Type} : Slice T → Result (Option (T × (Slice T)))
rust_symbol: core::slice::{[T]}::split_first
raw_declaration_sha256: f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49
name: core.str.Str.as_bytes
extracted_signature: : Str → Result (Slice Std.U8)
rust_symbol: core::str::{str}::as_bytes
raw_declaration_sha256: 11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The corresponding complete raw declaration text is generated.lean:311-316,
318-324 and 326-331, respectively (sed -n for each range):
/-- [core::slice::{[T]}::first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43
Name pattern: [core::slice::{[@T]}::first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::first"]
axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
/-- [core::slice::{[T]}::split_first]:
Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57
Name pattern: [core::slice::{[@T]}::split_first]
Visibility: public -/
@[rust_fun "core::slice::{[@T]}::split_first"]
axiom core.slice.Slice.split_first
{T : Type} : Slice T → Result (Option (T × (Slice T)))
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
Recomputing each declaration digest, including its final newline:
sed -n '311,316p' generated.lean | sha256sum
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
sed -n '318,324p' generated.lean | sha256sum
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
sed -n '326,331p' generated.lean | sha256sum
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
jq '.bindings[] | select(.node == "ModelSliceFirst" or .node == "ModelSliceSplitFirst" or .node == "ModelStrAsBytes")' Tablet/model-support.json
Each binding copies precisely the name, extracted_signature, rust_symbol and
raw_declaration_sha256 above. Its node/declaration pair is, respectively:
ModelSliceFirst / dec2flt_model.ModelSliceFirst
ModelSliceSplitFirst / dec2flt_model.ModelSliceSplitFirst
ModelStrAsBytes / dec2flt_model.ModelStrAsBytes
This reconciles the full raw declarations, not merely the identifier spelling.
In the current composed Preamble.lean:212,219,226 the externals are typed
references to exactly these principal definitions. Their bodies are, in order,
ok s.val.head?, empty/head-tail list matching (tail bound from s.property),
and ok s. No external axiom for these operations remains in the composition.
3. Complete current bound-call inventory
---------------------------------------
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Complete raw output:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Rust call / current extracted function and input:
crate/dec2flt/parse.rs:127 / parse_scientific:1732-1765, s_ref : Slice Std.U8
crate/dec2flt/parse.rs:65 / try_parse_19digits_loop.body:4087-4110, s : Slice Std.U8
crate/dec2flt/parse.rs:180 / parse_partial_number:4337-4364, s1 : Slice Std.U8
crate/dec2flt/parse.rs:197 / parse_partial_number:4369, s2 : Slice Std.U8
crate/dec2flt/mod.rs:364 / dec2flt_with_trace:4567, s : Str
crate/dec2flt/mod.rs:365 / dec2flt_with_trace:4568, body : Slice Std.U8
The s1 argument is returned by try_parse_digits; s2 is s1 or the returned
Std.U8 suffix after fractional scanning. Every bound slice call infers
T=Std.U8. Returned heads are copied/read, and tails are immutable next slices;
none of these calls observes pointer identity or mutates the returned borrow.
The dispatcher strips at most one leading sign after as_bytes and first.
The authored fixed frame mirrors these same two initial operations at
Tablet/P9_T1_DispatchFrame.lean:15-16. It uses the same bound as_bytes and
first definitions even with abstract helper components; it has no split_first
call of its own. These are authored frame uses, not additional call sites in
the raw generated module enumerated above.
4. Original observations versus audited indexed replacements
------------------------------------------------------------
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Complete raw output:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
The output ordering is the recorded rg ordering, not program evaluation order.
The original scientific digit-entry test at upstream/dec2flt/parse.rs:86
uses first(). Its audited replacement at crate/dec2flt/parse.rs:134-137 is:
// `matches!` with a guarded slice pattern triggers an Aeneas internal
// error. This short-circuit test reads the same first byte exactly when
// it exists and therefore preserves both acceptance and evaluation order.
if !s.is_empty() && s[0].is_ascii_digit() {
For [] both tests are false without a byte read; for x::xs both test the
identical x for is_ascii_digit. Therefore this original first observation
still exists semantically, but is not a call to the bound first external.
The extraction:1747-1753 uses is_empty, then index_usize 0, then the digit test.
Likewise original decimal-sequence split observations at upstream lines
244,250,255,291 become guarded indexing in crate lines 296,302,309,348-363;
the leading-dot/zero adjustment at upstream parse.rs:156 becomes
adjust_many_digit_count:86-99. Original common.rs:39-52 scans by split_first
and consumes a digit only when c.wrapping_sub(b'0')<10; the specialized
indexed scans retain that order and first-nondigit stop. These adaptations
are distinct from the four bound split calls. Their audited source comments
and Preamble preservation remain separate obligations, not claims proved by
absence from the external inventory.
5. Slow scientific path, residual and outer outcomes
---------------------------------------------------
The source call chain is crate/dec2flt/slow.rs:40 ->
crate/dec2flt/decimal_seq.rs:362-363 -> crate/dec2flt/parse.rs:127.
The extracted chain starts at generated.lean:3941:
let d <- num.imp.dec2flt.decimal_seq.parse_decimal_seq s
and reaches parse_scientific exponent_suffix in all eight e/E branches:
2084/2094, 2156/2166, 2224/2234, 2281/2292. The <- here is ASCII rendering;
the raw extraction uses Lean's left arrow. Inspect each branch with sed -n;
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
shows each call immediately followed by
ok (core.option.Option.unwrap_or o 0#i64)
The scientific call itself reaches the bound split_first at 1734. The
numeric parser also calls this same scientific function at 4412 and 4459,
but observes its returned residual in its consumed-length calculation;
crate/dec2flt/parse.rs:234-240 requires rest == s.len() for Some.
The source at crate/dec2flt/decimal_seq.rs:350-366 reads:
if ch == b'e' || ch == b'E' {
// [preservation comments at 351-361, retained in the pinned file]
let mut exponent_suffix = &s[1..];
explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
Counts have been saved before this call. The residual mutation is unobserved
only after the scientific call returns; the call is not elided. Original
upstream/dec2flt/decimal_seq.rs:291-295 likewise calls parse_scientific then
unwrap_or. The later generated.lean:3942 test for d.num_digits=0 is after
the bind at 3941, so zero-significand inputs do not bypass scientific parsing.
The unsigned numeric literal 1e-2 passes -2 as the exponent suffix, despite
having no leading sign. This is source inspection, not a newly run test.
The exact loop body at generated.lean:1692-1716 / crate/dec2flt/parse.rs:145-151
tests count<len and the byte's wrapping-sub digit predicate, updates E only
when E<2^59, then increments count regardless of whether E was updated.
The sign is taken from the scientific suffix (1735-1746), not the leading
literal sign. The residual is the slice starting at count (1758-1761).
With 0<=E<2^59 and 0<=digit<=9, an update is at most
10*2^59-1=5764607523034234879<i64::MAX. One update can overshoot 2^59;
this is not a clamp. Later exponent digits are still consumed, including
arbitrarily many zeroes/digits within a source-valid slice; the first nondigit
and everything after it remain in the residual. Empty/sign-only/nondigit
suffixes normally produce None with the exact post-sign residual.
The monadic distinction is independently checkable in the unchanged Aeneas
library. Commands:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Raw output (path suffixes abbreviated):
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 Aeneas/Std/Core/Core.lean
Primitives.lean:62-66 has Result.ok, Result.fail and Result.div. Its
117-121 bind is:
match x with
| ok v => f v
| fail v => fail v
| div => div
Core/Core.lean:100-104 unwrap_or takes an Option T, not a Result:
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Thus normal None becomes zero after the call; failure/divergence skips that
continuation and propagates outward. No Option Try/residual conversion is
used for the slow None-to-zero behavior. Equal head/tail observations preserve
this distinction without assuming termination or rounding of the slow helper.
Applicability conclusion
------------------------
The unchanged list representations, core bodies, exact declarations and
bindings justify reuse of the predecessor's immutable head/tail and byte-list
arguments, with this current inventory instead of predecessor call locations.
Primitive equivalence is extensional on every source-valid byte slice/string,
not conditioned on lexical acceptance, native/slow rounding, component package
inhabitability, A/B length bounds, or public reachability. A/B are used only
where the individual original GOAL requires them, and public bounds concern
the complete string before optional sign removal. The direct slow application
retains every source-valid unsigned numeric literal, with its independently
signed exponent and full significand, and is only on normal return. This
evidence supplies neither a GOAL proof nor a new model assumption.
Fresh request-99 inspection transcript
--------------------------------------
Each stdout block below is exact, without path abbreviations or ASCII
substitutions. Unicode occurs only where it is part of the inspected source or
inventory. Command exit status is reported separately.
Command:
sha256sum generated.lean upstream/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/parse.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/mod.rs crate/dec2flt/slow.rs Tablet/model-support.json Tablet/ModelSliceFirst.lean Tablet/ModelSliceSplitFirst.lean Tablet/ModelStrAsBytes.lean
Exit status: 0
Raw stdout:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18 Tablet/ModelSliceFirst.lean
f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e Tablet/ModelSliceSplitFirst.lean
8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981 Tablet/ModelStrAsBytes.lean
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Exit status: 0
Raw stdout:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7 /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Command:
sed -n '311,316p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105 -
Command:
sed -n '318,324p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49 -
Command:
sed -n '326,331p' generated.lean | sha256sum
Exit status: 0
Raw stdout:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f -
Command:
rg -n 'core\.slice\.Slice\.(first|split_first)|core\.str\.Str\.as_bytes' generated.lean
Exit status: 0
Raw stdout:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
1734: let o ← core.slice.Slice.split_first s_ref
4094: let o ← core.slice.Slice.split_first s
4347: let o ← core.slice.Slice.split_first s1
4369: let o1 ← core.slice.Slice.split_first s2
4567: let body ← core.str.Str.as_bytes s
4568: let o ← core.slice.Slice.first body
Command:
rg -n 'first\(|split_first\(|as_bytes\(' crate/dec2flt upstream/dec2flt
Exit status: 0
Raw stdout:
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
upstream/dec2flt/mod.rs:212: let mut s = s.as_bytes();
upstream/dec2flt/mod.rs:213: let Some(&c) = s.first() else { return Err(pfe_empty()) };
upstream/dec2flt/decimal_seq.rs:244: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:250: if let Some((b'.', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:255: while let Some((&b'0', s_next)) = s.split_first() {
upstream/dec2flt/decimal_seq.rs:291: if let Some((&ch, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:55: if let Some((c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:79: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:86: if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
upstream/dec2flt/parse.rs:120: if let Some((&b'.', s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:137: if let Some((&c, s_next)) = s.split_first() {
upstream/dec2flt/parse.rs:156: while let Some((&c, p_next)) = p.split_first() {
upstream/dec2flt/common.rs:42: while let Some((c, rest)) = s.split_first() {
crate/dec2flt/parse.rs:65: if let Some((c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
Command:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
852be2e07d9dd941a1b105c0867f52ede98542175b5cd3cc15fa238784b61299 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Command:
jq '.declarations[] | select(.name == "core.slice.Slice.first" or .name == "core.slice.Slice.split_first" or .name == "core.str.Str.as_bytes")' .trellis/scratch/inspect-native-1791579714814493776.json
Exit status: 0
Raw stdout:
{
"name": "core.slice.Slice.first",
"extracted_signature": "{T : Type} : Slice T → Result (Option T)",
"rust_symbol": "core::slice::{[T]}::first",
"raw_declaration_sha256": "221298364b1df3a924d1ee3951ad3e7d786065b4aa48e2b74eedb0a49f643105",
"source_utf8": "/-- [core::slice::{[T]}::first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 155:4-155:43\n Name pattern: [core::slice::{[@T]}::first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::first\"]\naxiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)\n"
}
{
"name": "core.slice.Slice.split_first",
"extracted_signature": "{T : Type} : Slice T → Result (Option (T × (Slice T)))",
"rust_symbol": "core::slice::{[T]}::split_first",
"raw_declaration_sha256": "f983904621cafa667f0bfd9822b4d95fb0bd6820ee84b107130e7c4f7bac3c49",
"source_utf8": "/-- [core::slice::{[T]}::split_first]:\n Source: '/rustc/library/core/src/slice/mod.rs', lines 198:4-198:57\n Name pattern: [core::slice::{[@T]}::split_first]\n Visibility: public -/\n@[rust_fun \"core::slice::{[@T]}::split_first\"]\naxiom core.slice.Slice.split_first\n {T : Type} : Slice T → Result (Option (T × (Slice T)))\n"
}
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"source_utf8": "/-- [core::str::{str}::as_bytes]:\n Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41\n Name pattern: [core::str::{str}::as_bytes]\n Visibility: public -/\n@[rust_fun \"core::str::{str}::as_bytes\"]\naxiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)\n"
}
Command:
sed -n '155,157p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
Command:
sed -n '198,200p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
Exit status: 0
Raw stdout:
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Command:
sed -n '498,501p' /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Exit status: 0
Raw stdout:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
Command:
sed -n '18,24p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
Exit status: 0
Raw stdout:
/-!
# Slice
-/
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
/-- We need this to coerce slices to lists without marking `Slice` as reducible.
Command:
sed -n '1,9p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Exit status: 0
Raw stdout:
import Aeneas.Std.Scalar
import Aeneas.Std.Slice
namespace Aeneas.Std
def Str := Slice U8
instance : DecidableEq Str := inferInstanceAs (DecidableEq (Slice U8))
Command:
sed -n '237,244p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
- **Mutable reference parameters** become plain value parameters.
- **Returned mutable borrows** produce a tuple of (value, backward continuation).
- **Shared borrows (`&T`)** become plain `T` parameters (the value may be copied).
- **Pattern matching** maps directly to `match` in Lean.
- **Recursive functions** become Lean recursive functions (may require termination proofs).
- **Traits** are translated to Lean type classes.
Command:
sed -n '428,434p' /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
Exit status: 0
Raw stdout:
| Rust Concept | Lean Translation |
|--------------------------|--------------------------------------------------------------|
| `&mut T` parameter | `T` parameter (passed by value) |
| Returning `&'a mut T` | Returns `Result (T × (T → ...))` with backward continuation |
| `&T` (shared borrow) | `T` parameter (immutable, may be copied) |
| `panic!()` | `fail` in the `Result` monad |
| Integer overflow | `fail` (all arithmetic is checked) |
Command:
sed -n '60,67p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
open Error
inductive Result (α : Type u) where
| ok (v: α): Result α
| fail (e: Error): Result α
| div
deriving Repr, BEq
Command:
sed -n '115,122p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
Exit status: 0
Raw stdout:
-/
def bind {α : Type u} {β : Type v} (x: Result α) (f: α → Result β) : Result β :=
match x with
| ok v => f v
| fail v => fail v
| div => div
Command:
sed -n '97,105p' /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Core/Core.lean
Exit status: 0
Raw stdout:
unwrap x ⦃ v => x = some v ⦄ := by
simp only [unwrap, ofOption]; grind
@[step_pure_def, rust_fun "core::option::{core::option::Option<@T>}::unwrap_or" -canFail]
def core.option.Option.unwrap_or (self : Option T) (default : T) : T :=
match self with
| none => default
| some self => self
Command:
rg -n -A 1 'parse_scientific exponent_suffix|let \(o, _\) ←$' generated.lean
Exit status: 0
Raw stdout:
2084: let (o, _) ← num.imp.dec2flt.parse.parse_scientific exponent_suffix
2085- ok (core.option.Option.unwrap_or o 0#i64)
--
2093: let (o, _) ←
2094: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2095- ok (core.option.Option.unwrap_or o 0#i64)
--
2155: let (o, _) ←
2156: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2157- ok (core.option.Option.unwrap_or o 0#i64)
--
2165: let (o, _) ←
2166: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2167- ok (core.option.Option.unwrap_or o 0#i64)
--
2223: let (o, _) ←
2224: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2225- ok (core.option.Option.unwrap_or o 0#i64)
--
2233: let (o, _) ←
2234: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2235- ok (core.option.Option.unwrap_or o 0#i64)
--
2280: let (o, _) ←
2281: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2282- ok (core.option.Option.unwrap_or o 0#i64)
--
2291: let (o, _) ←
2292: num.imp.dec2flt.parse.parse_scientific exponent_suffix
2293- ok (core.option.Option.unwrap_or o 0#i64)
Command:
sed -n '27,46p' crate/dec2flt/slow.rs
Exit status: 0
Raw stdout:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
Command:
sed -n '244,260p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
s = s.parse_digits(|digit| d.try_add_digit(digit));
if let Some((b'.', s_next)) = s.split_first() {
s = s_next;
let first = s;
// Skip leading zeros.
if d.num_digits == 0 {
while let Some((&b'0', s_next)) = s.split_first() {
s = s_next;
}
}
while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
let v = s.read_u64();
Command:
sed -n '287,300p' upstream/dec2flt/decimal_seq.rs
Exit status: 0
Raw stdout:
}
}
let mut explicit = 0;
if let Some((&ch, s_next)) = s.split_first() {
if ch == b'e' || ch == b'E' {
s = s_next;
explicit = parse_scientific(&mut s).unwrap_or(0);
}
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
d.digits[i] = 0;
Command:
sed -n '39,52p' upstream/dec2flt/common.rs
Exit status: 0
Raw stdout:
fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
let mut s = self;
while let Some((c, rest)) = s.split_first() {
let c = c.wrapping_sub(b'0');
if c < 10 {
func(c);
s = rest;
} else {
break;
}
}
s
reference/model-evidence/P89_T2_current-applicability.txt
Current applicability of reused binary64 and U64 preservation evidence
Task 11 / worker request 118; checked in the current private checkout.
All commands below ran in this assignment; EXIT records the command status.
Rust commands use LD_LIBRARY_PATH=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib
and RUSTUP_TOOLCHAIN=nightly-2026-06-01.
The managed Lean commands are recorded separately, not invoked by this script.
Reuse and scope
===============
Read-only predecessor: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002
The historical 45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
generated.lean hash belongs to that predecessor, never the current extraction.
The old primary evidence retains its original commands, raw identities and results.
Current checks below establish applicability; prior worker task 9 was rejected,
accepted=false, and its self-report is neither publication nor certification.
Only preservation sections of the six listed owners and ten reserved evidence paths
are submitted. No ordinary statement, Lean computation, GOAL pair, source, extraction,
provenance, Preamble, binding, dispatcher owner or existing config delta is edited.
No new node, route, under-model premise, GOAL decline or polarity change is proposed.
The new 2^59 exponent fold, final-point repair and A/B GOAL domains are not old semantics.
Unchanged primitive meanings are reused, not old parser correctness or old counterexamples.
{
"task_execution": {
"binding": {
"allowed_tasks": [
"ordinary",
"lean_closure"
],
"lightweight": false,
"max_timeout_seconds": 14400,
"model": "gpt-6.1-sol",
"provider": "codex",
"reasoning_effort": "xhigh",
"timeout_seconds": 14400
},
"compiler": "managed",
"profile": "sol-xhigh",
"task_id": 11,
"task_kind": "ordinary"
},
"acceptance_logic_identity": "trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91",
"parallel_scope": {
"exclusive": true,
"helper_prefixes": [
"P116_T1_"
],
"nodes": [
"Binary64ModelDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"shared_writes": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
]
}
}
Current file, compiler, configuration and library identities
============================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum GOAL.md generated.lean Tablet/model-support.json modeling-input/manifest.json modeling-input/extraction.json modeling-input/tool-identities.json modeling-input/SETUP.md modeling-input/revision-from.json crate/Cargo.toml crate/rust-toolchain.toml lean-toolchain lakefile.lean lake-manifest.json trellis.config.json reference/model-evidence/binary64-boundary.txt crate/dec2flt/common.rs crate/dec2flt/decimal.rs crate/dec2flt/decimal_seq.rs crate/dec2flt/fpu.rs crate/dec2flt/lemire.rs crate/dec2flt/mod.rs crate/dec2flt/parse.rs crate/dec2flt/slow.rs crate/dec2flt/table.rs crate/lib.rs crate/num/imp/mod.rs crate/num/mod.rs crate/traits.rs upstream/dec2flt/common.rs upstream/dec2flt/decimal.rs upstream/dec2flt/decimal_seq.rs upstream/dec2flt/fpu.rs upstream/dec2flt/lemire.rs upstream/dec2flt/mod.rs upstream/dec2flt/parse.rs upstream/dec2flt/slow.rs upstream/dec2flt/table.rs upstream/traits.rs reference/model-evidence/binary64-probe.rs reference/model-evidence/binary64-negation-probe.rs reference/model-evidence/u64-shl-probe.rs reference/model-evidence/u64-shr-probe.rs Tablet/Binary64ModelDefault.lean Tablet/ModelF64Neg.lean Tablet/ModelU64BitAnd.lean Tablet/ModelU64BitOr.lean Tablet/ModelU64Shl.lean Tablet/ModelU64Shr.lean
EXIT: 0
STDOUT:
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
1a7d2eea7888b7bdb0421ed6bb96c5ee1e80afe8e788438cd30725f2120a2aea modeling-input/revision-from.json
10584b73664d42dc85fb009bb0783a616520c2cc05f3b0f8c64e5d5cb32e2905 crate/Cargo.toml
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
8dab550b59cec828a4ba436bc25ce9ad66547bdd7f55899b8cbf7e4f65389518 lakefile.lean
a5f9756cd42129193c0285127cddb734224e9c69686fc2de56de2c9d48ed0695 lake-manifest.json
d8fceb13f84ecbf5bf6e9fd7ecdcb061569cfabdb0079243e2eb1609d012ac02 trellis.config.json
749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e reference/model-evidence/binary64-boundary.txt
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b crate/lib.rs
df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1 crate/num/imp/mod.rs
d84067991b142196281bc0968d32634bdcdb9a3a41c2ce2fd3c344d0f61504af crate/num/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e reference/model-evidence/binary64-probe.rs
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8 reference/model-evidence/u64-shl-probe.rs
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee reference/model-evidence/u64-shr-probe.rs
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3 Tablet/Binary64ModelDefault.lean
9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2 Tablet/ModelF64Neg.lean
3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179 Tablet/ModelU64BitAnd.lean
aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f Tablet/ModelU64BitOr.lean
af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad Tablet/ModelU64Shl.lean
54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b Tablet/ModelU64Shr.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo /home/leanagent/pv_spike/tools/charon/bin/charon /home/leanagent/pv_spike/tools/aeneas/bin/aeneas /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
EXIT: 0
STDOUT:
54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade /home/leanagent/pv_spike/tools/charon/bin/charon
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc
STDERR:
(empty)
All installed tool hashes equal the current tool-identities.json pins.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
EXIT: 0
STDOUT:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print cfg --target x86_64-unknown-linux-gnu
EXIT: 0
STDOUT:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat crate/Cargo.toml modeling-input/extraction.json
EXIT: 0
STDOUT:
# Standalone extraction package for the supplied `core::num::dec2flt` slice.
# The package metadata and profiles select the configured environment; source
# correspondence and extraction adaptations are recorded in ../SETUP.md and
# local preservation comments.
[package]
name = "dec2flt-model"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
path = "lib.rs"
[features]
default = []
optimize_for_size = []
[profile.dev]
overflow-checks = true
[profile.release]
overflow-checks = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(target_has_reliable_f16)"] }
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
STDERR:
(empty)
Current effective tools:
{
"aeneas": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"cargo": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"charon": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"env": {
"LD_LIBRARY_PATH": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib",
"RUSTUP_TOOLCHAIN": "nightly-2026-06-01"
},
"lean": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"lean_paths": [
"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean"
],
"readonly": [
"/home/leanagent/pv_spike/tools",
"/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages"
],
"timeouts": {
"aeneas": 3600,
"cargo": 600,
"charon": 600,
"lean": 3600
}
}
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
EXIT: 0
STDOUT:
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/clone.rs
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
EXIT: 0
STDOUT:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Core.lean
EXIT: 0
STDOUT:
100644 blob f8582928fe49a0ce75e143b46bb0a8826d7fddae backends/lean/Aeneas/Std/Scalar/Core.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
EXIT: 0
STDOUT:
100644 blob d3eb5022efc22d1d6c3ac055965f612c7f2fbca9 backends/lean/Aeneas/Std/Scalar/Bitwise.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Data/BitVec.lean
EXIT: 0
STDOUT:
100644 blob f7bc57109569cdd0fb0c3323021c73673dcfcd33 backends/lean/Aeneas/Data/BitVec.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: git -C /home/leanagent/pv_spike/tools/aeneas ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 backends/lean/Aeneas/Std/Primitives.lean
EXIT: 0
STDOUT:
100644 blob e5733a774268c8dee71bd4ba402240d151bb8cb8 backends/lean/Aeneas/Std/Primitives.lean
STDERR:
(empty)
Predecessor pair and probe reuse checks
=======================================
Tablet/Binary64ModelDefault.lean: predecessor_sha256=03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3; whole Lean byte-identical.
Tablet/Binary64ModelDefault.tex: predecessor_sha256=57c6e9ed282cf2dd718f822c6a31255040c71b5c7531488f3951d9c4d4d8b822; ordinary NL definition byte-identical.
Tablet/ModelF64Neg.lean: predecessor_sha256=9d2ebb3e668687227a06d16f1e3573efd69337a0db62f346d757ea3b5fcc7af2; whole Lean byte-identical.
Tablet/ModelF64Neg.tex: predecessor_sha256=9d2811046df611e45e2637da57241bace75c3de5822e03126de5f1fc9faeb859; ordinary NL definition byte-identical.
Tablet/ModelU64BitAnd.lean: predecessor_sha256=3f4955dabcc02a2688ba2b27c78db077f6de63d701c90d4ec3c082b509a69179; whole Lean byte-identical.
Tablet/ModelU64BitAnd.tex: predecessor_sha256=db8a1445918e94fd1c11f92f1c5f218f165aec945ac2ebdeda3cc1675165f8fe; ordinary NL definition byte-identical.
Tablet/ModelU64BitOr.lean: predecessor_sha256=aa27d93d9dd1dc77af05a65148d6c7ce8ab9e4da238591fce32aa4ad12a3602f; whole Lean byte-identical.
Tablet/ModelU64BitOr.tex: predecessor_sha256=fbbb37c3cfa81c5811869baf46671d93a6c457042f0a5bbb78ba32c26607dbe2; ordinary NL definition byte-identical.
Tablet/ModelU64Shl.lean: predecessor_sha256=af3e1ddec0b1b5d69f2bf89e1dec00f75c043e894b228aaea868964ca597e2ad; whole Lean byte-identical.
Tablet/ModelU64Shl.tex: predecessor_sha256=725582880c20b16d00487e01aceb0552a39263616563280cee0d49635984beab; ordinary NL definition byte-identical.
Tablet/ModelU64Shr.lean: predecessor_sha256=54cdf7bf335c60688d0b21060cda7f6bd638e6b2f3a9fc54d2ab4e32b61c6a7b; whole Lean byte-identical.
Tablet/ModelU64Shr.tex: predecessor_sha256=3def4409d97d8316d4d77dc2fe01c4142219859ea9596b835ac40f83c3a18784; ordinary NL definition byte-identical.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/binary64-negation-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/binary64-negation-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shl-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cmp reference/model-evidence/u64-shr-probe.rs /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
Current raw declarations and exact support bindings
===================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py inspect-native .
EXIT: 0
STDOUT:
{
"full_index": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json",
"declaration_count": 24,
"declarations": [
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05"
},
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c"
},
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768"
},
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816"
},
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e"
},
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71"
},
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538"
},
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 \u2192 Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78"
},
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 \u2192 Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae"
},
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 \u2192 Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19"
},
{
"name": "core.num.U8.is_ascii_digit",
"extracted_signature": ": Std.U8 \u2192 Result Bool",
"rust_symbol": "core::num::{u8}::is_ascii_digit",
"raw_declaration_sha256": "fae6cbf092f55de23a7159eb77782a6336592a4609f96942008513624ed2033b"
},
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec"
},
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 \u2192 F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36"
},
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 \u2192 Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0"
},
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 \u2192 Std.U64 \u2192 Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02"
}
],
"declarations_omitted": 9
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
EXIT: 0
STDOUT:
fbe3b76ef8fbb588841979e071c52eee0fc850472ac55da6f2ca2033e4a34cf4 /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/inspect-native-1791584614533837464.json
STDERR:
(empty)
RAW DECLARATION:
/-- [core::clone::impls::{impl core::clone::Clone for f64}::clone]:
Source: '/rustc/library/core/src/clone.rs', lines 698:20-698:43
Name pattern: [core::clone::impls::{core::clone::Clone<f64>}::clone]
Visibility: public -/
@[rust_fun "core::clone::impls::{core::clone::Clone<f64>}::clone"]
axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreCloneClone.clone",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::clone::impls::{impl core::clone::Clone for f64}::clone",
"raw_declaration_sha256": "5eaad5fb9af034045cf0dafed5af85445fe4af9a78958259a15a1faddd1e8f05",
"node": "ModelF64Clone",
"declaration": "dec2flt_model.ModelF64Clone"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dfbdb508142706b4c716f701e52a26d63d764f088dacfa461dd81c6df0b9bf0d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_DIGITS]
Source: '/rustc/library/core/src/num/f64.rs', lines 412:4-412:34
Name pattern: [core::f64::{f64}::MANTISSA_DIGITS]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_DIGITS"]
axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_DIGITS",
"extracted_signature": ": Result Std.U32",
"rust_symbol": "core::f64::{f64}::MANTISSA_DIGITS",
"raw_declaration_sha256": "42b1b0c4d2c2bbc7271748fc78c518391f55bf6517c643667a6561a0ac6e771c",
"node": "ModelF64MantissaDigits",
"declaration": "dec2flt_model.ModelF64MantissaDigits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 19dc0621c0c5c7d2a24f090dd7870ffa858de15fc4e1cc7bf57f16d64816c9bc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NAN]
Source: '/rustc/library/core/src/num/f64.rs', lines 509:4-509:22
Name pattern: [core::f64::{f64}::NAN]
Visibility: public -/
@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NAN",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NAN",
"raw_declaration_sha256": "a18685a80db5dbebe39151c7375a0470bb3905fe1228e5598a995a1cf017a768",
"node": "ModelF64Nan",
"declaration": "dec2flt_model.ModelF64Nan"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 75cd3ccca5992f42ef5afa9287573410d249d40f9bcc3120fae72389b2e2419d
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 512:4-512:27
Name pattern: [core::f64::{f64}::INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::INFINITY"]
axiom core.f64.F64.INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::INFINITY",
"raw_declaration_sha256": "f905901e67400987f49cddd13a8768644bed9e7e3f79c3a81b34879f494a2816",
"node": "ModelF64Infinity",
"declaration": "dec2flt_model.ModelF64Infinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 9a5fb08a6bae926bafdba709d6da6aaad52b8f41c7dbf3e4b2a28b2bc0542716
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::NEG_INFINITY]
Source: '/rustc/library/core/src/num/f64.rs', lines 515:4-515:31
Name pattern: [core::f64::{f64}::NEG_INFINITY]
Visibility: public -/
@[rust_const "core::f64::{f64}::NEG_INFINITY"]
axiom core.f64.F64.NEG_INFINITY : Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.NEG_INFINITY",
"extracted_signature": ": Result F64",
"rust_symbol": "core::f64::{f64}::NEG_INFINITY",
"raw_declaration_sha256": "85f6e517e439c2f2d5c59aa29884ff38b2381c2f5dd7cb14e7947b232efe7f0e",
"node": "ModelF64NegInfinity",
"declaration": "dec2flt_model.ModelF64NegInfinity"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f5d6435579e1da8caecfc1a3b0039a0ce4e250e7dc55c4c69f3edbdd2a5a10f6
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::EXPONENT_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 615:4-615:32
Name pattern: [core::f64::{f64}::EXPONENT_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::EXPONENT_MASK"]
axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.EXPONENT_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::EXPONENT_MASK",
"raw_declaration_sha256": "f1054e64392d8f9306e8c69015f0b521d9f387edda8458a3bae4773606f46a71",
"node": "ModelF64ExponentMask",
"declaration": "dec2flt_model.ModelF64ExponentMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): dcd87a62501dc8e76079204a4b43546a4750077e1f425f01dcd58c96bf31a865
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::MANTISSA_MASK]
Source: '/rustc/library/core/src/num/f64.rs', lines 637:4-637:32
Name pattern: [core::f64::{f64}::MANTISSA_MASK]
Visibility: public -/
@[rust_const "core::f64::{f64}::MANTISSA_MASK"]
axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.MANTISSA_MASK",
"extracted_signature": ": Result Std.U64",
"rust_symbol": "core::f64::{f64}::MANTISSA_MASK",
"raw_declaration_sha256": "dc3517faa141b7a7a016e9f73930af3c9af23d3e6d06874440d99eabbc846538",
"node": "ModelF64MantissaMask",
"declaration": "dec2flt_model.ModelF64MantissaMask"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): cf1585ae2e94a7bf5bb6b5ff37a06a0677b7e8d81420c1e0ca7ee29eca8cfd4c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::classify]:
Source: '/rustc/library/core/src/num/f64.rs', lines 782:4-782:45
Name pattern: [core::f64::{f64}::classify]
Visibility: public -/
@[rust_fun "core::f64::{f64}::classify"]
axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
IDENTITY AND BINDING:
{
"name": "core.f64.F64.classify",
"extracted_signature": ": F64 → Result core.num.FpCategory",
"rust_symbol": "core::f64::{f64}::classify",
"raw_declaration_sha256": "9fedd442d1d0403c4a7323d8f4e95c51b8bd39bf82d2d0ba357eaaf243e69b78",
"node": "ModelF64Classify",
"declaration": "dec2flt_model.ModelF64Classify"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 7cf497c5bfc31455d5490d5da75914d7eaf9e522aa2eccd14fe9935502b5127c
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::to_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1223:4-1223:37
Name pattern: [core::f64::{f64}::to_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::to_bits"]
axiom core.f64.F64.to_bits : F64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.to_bits",
"extracted_signature": ": F64 → Result Std.U64",
"rust_symbol": "core::f64::{f64}::to_bits",
"raw_declaration_sha256": "ddaec6bb7c36ba6445a5b0b8e52f841240ca2563004e8ce1255caf0e36ec22ae",
"node": "ModelF64ToBits",
"declaration": "dec2flt_model.ModelF64ToBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b35203125fea8ba89df874b609344bbe8ad61a61fcb946a184a72c729a1e3364
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::f64::{f64}::from_bits]:
Source: '/rustc/library/core/src/num/f64.rs', lines 1269:4-1269:42
Name pattern: [core::f64::{f64}::from_bits]
Visibility: public -/
@[rust_fun "core::f64::{f64}::from_bits"]
axiom core.f64.F64.from_bits : Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "core.f64.F64.from_bits",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "core::f64::{f64}::from_bits",
"raw_declaration_sha256": "af8ee4387cea97d0a353a83d6280c03f3c9f739bf733af5bd39c29909f1b2b19",
"node": "ModelF64FromBits",
"declaration": "dec2flt_model.ModelF64FromBits"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f819b0951f4f63943abf8d4787a2f9489ffd1137fa91529e0771a303bc8fcb94
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 350:12-350:41
Name pattern: [core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Mul<f64, f64, f64>}::mul"]
axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithMulF64F64.mul",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Mul<f64, f64> for f64}::mul",
"raw_declaration_sha256": "20d985819a981e9e80485ce169c1d045ea13fa8796e9314d5b621141aae6deec",
"node": "ModelF64Mul",
"declaration": "dec2flt_model.ModelF64Mul"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 4adead3b54aa85bfb81b7122b0e942b2c6f3d232d548d8361a2a2ca067be1e7f
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 515:12-515:41
Name pattern: [core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Div<f64, f64, f64>}::div"]
axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithDivF64F64.div",
"extracted_signature": ": F64 → F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Div<f64, f64> for f64}::div",
"raw_declaration_sha256": "1ebb67b412d89328acb4c5dd53168e84fdf26be6cbe1ef49f5a27edbd84ada36",
"node": "ModelF64Div",
"declaration": "dec2flt_model.ModelF64Div"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 62ca24414fa18ef9709d7c5703429d7262f27d017abc975ffb532ae284ba054a
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 945f30e7dbb62802e6ba5bb9d9445e100528b2a52d3b0b6a3a0629c939ff9860
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitAndU64U64.bitand",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand",
"raw_declaration_sha256": "36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02",
"node": "ModelU64BitAnd",
"declaration": "dec2flt_model.ModelU64BitAnd"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): b66bd94c28f512804622c3717705dbe7ef5a3ced5beaac7435704d053038c36e
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitBitOrU64U64.bitor",
"extracted_signature": ": Std.U64 → Std.U64 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor",
"raw_declaration_sha256": "85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6",
"node": "ModelU64BitOr",
"declaration": "dec2flt_model.ModelU64BitOr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 68909ba4060a48df31ea54bcf0510b089709a3a644c9c1b0770780a98d31f4cc
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShlU32U64.shl",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl",
"raw_declaration_sha256": "e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d",
"node": "ModelU64Shl",
"declaration": "dec2flt_model.ModelU64Shl"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 5c0105f2c7ce3d255f053e0ccbefa65f73f65de1462832217571cf8cd4963e47
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 → Std.U32 → Result Std.U64
IDENTITY AND BINDING:
{
"name": "U64.Insts.CoreOpsBitShrU32U64.shr",
"extracted_signature": ": Std.U64 → Std.U32 → Result Std.U64",
"rust_symbol": "core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr",
"raw_declaration_sha256": "77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f",
"node": "ModelU64Shr",
"declaration": "dec2flt_model.ModelU64Shr"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): f100256a450680392496fb74934592e9e2822a1648320153e27c1c0d100ff482
All four identity fields and full raw declaration equal predecessor; current binding matches.
RAW DECLARATION:
/-- [dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 263:4-266:5
Visibility: public -/
axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
: Std.U64 → Result F64
IDENTITY AND BINDING:
{
"name": "F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64",
"extracted_signature": ": Std.U64 → Result F64",
"rust_symbol": "dec2flt_model::num::imp::dec2flt::{impl dec2flt_model::num::imp::dec2flt::Lemire<u64> for f64}::from_u64",
"raw_declaration_sha256": "ad172bce0522e7e41bceb8c66a5adff962822ee8a9454dfd59b7019086797ba8",
"node": "ModelF64FromU64",
"declaration": "dec2flt_model.ModelF64FromU64"
}
binding_sha256 (sorted-key compact UTF-8 JSON, no newline): 0bb769d884e3d54d7aa94163fdf4c8fc589050ed84f4fa0d11f694cf599cdb8f
All four identity fields and full raw declaration equal predecessor; current binding matches.
Complete relevant call and wiring inventories
=============================================
This deliberately includes record wiring and scalar lowerings, not just direct external calls.
The four U64 external trait fields wire into Int; generic scalar notation in generated.lean
also lowers directly to the installed operations with the same full-domain meanings.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n 'F64\.Insts\.(CoreClone|CoreOpsArith)|core\.f64\.F64\.|U64\.Insts\.CoreOpsBit|coreops(bit|arith)|\.from_u64|\.pow10_fast_path|FloatInst\.(INFINITY|NEG_INFINITY|NAN|NEG_NAN|SIG_|EXP_|INFINITE_POWER)|&&&|\|\|\||<<<|>>>' generated.lean
EXIT: 0
STDOUT:
25:axiom F64.Insts.CoreCloneClone.clone : F64 → Result F64
31:def F64.Insts.CoreCloneClone : core.clone.Clone F64 := {
32: clone := F64.Insts.CoreCloneClone.clone
40: cloneInst := F64.Insts.CoreCloneClone
48:axiom core.f64.F64.MANTISSA_DIGITS : Result Std.U32
54:@[rust_const "core::f64::{f64}::NAN"] axiom core.f64.F64.NAN : Result F64
61:axiom core.f64.F64.INFINITY : Result F64
68:axiom core.f64.F64.NEG_INFINITY : Result F64
75:axiom core.f64.F64.EXPONENT_MASK : Result Std.U64
82:axiom core.f64.F64.MANTISSA_MASK : Result Std.U64
101:axiom core.f64.F64.classify : F64 → Result core.num.FpCategory
108:axiom core.f64.F64.to_bits : F64 → Result Std.U64
115:axiom core.f64.F64.from_bits : Std.U64 → Result F64
138:axiom F64.Insts.CoreOpsArithMulF64F64.mul : F64 → F64 → Result F64
144:def F64.Insts.CoreOpsArithMulF64F64 : core.ops.arith.Mul F64 F64 F64 := {
145: mul := F64.Insts.CoreOpsArithMulF64F64.mul
162:axiom F64.Insts.CoreOpsArithDivF64F64.div : F64 → F64 → Result F64
168:def F64.Insts.CoreOpsArithDivF64F64 : core.ops.arith.Div F64 F64 F64 := {
169: div := F64.Insts.CoreOpsArithDivF64F64.div
185:axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
191:def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
192: neg := F64.Insts.CoreOpsArithNegF64.neg
200:axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
207:def U64.Insts.CoreOpsBitBitAndU64U64 : core.ops.bit.BitAnd Std.U64 Std.U64
209: bitand := U64.Insts.CoreOpsBitBitAndU64U64.bitand
226:axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
233:def U64.Insts.CoreOpsBitBitOrU64U64 : core.ops.bit.BitOr Std.U64 Std.U64
235: bitor := U64.Insts.CoreOpsBitBitOrU64U64.bitor
252:axiom U64.Insts.CoreOpsBitShlU32U64.shl
259:def U64.Insts.CoreOpsBitShlU32U64 : core.ops.bit.Shl Std.U64 Std.U32 Std.U64
261: shl := U64.Insts.CoreOpsBitShlU32U64.shl
278:axiom U64.Insts.CoreOpsBitShrU32U64.shr
285:def U64.Insts.CoreOpsBitShrU32U64 : core.ops.bit.Shr Std.U64 Std.U32 Std.U64
287: shr := U64.Insts.CoreOpsBitShrU32U64.shr
393: let i ← lift (a ||| b)
394: let i1 ← lift (i &&& 9259542123273814144#u64)
635: coreopsbitShrSelfU32SelfInst : core.ops.bit.Shr Self Std.U32 Self
636: coreopsbitShlSelfU32SelfInst : core.ops.bit.Shl Self Std.U32 Self
637: coreopsbitBitAndInst : core.ops.bit.BitAnd Self Self Self
638: coreopsbitBitOrInst : core.ops.bit.BitOr Self Self Self
664: coreopsarithDivInst : core.ops.arith.Div Self Self Self
665: coreopsarithNegInst : core.ops.arith.Neg Self Self
666: coreopsarithMulInst : core.ops.arith.Mul Self Self Self
726: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
727: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
728: (coreopsarithNegInst : core.ops.arith.Neg F F)
739: let value ← LemireInst.from_u64 self.mantissa
746: let t ← LemireInst.pow10_fast_path i2
747: coreopsarithDivInst.div value t
751: let t ← LemireInst.pow10_fast_path i1
752: coreopsarithMulInst.mul value t
754: then let t ← coreopsarithNegInst.neg value1
769: let t ← LemireInst.from_u64 val
771: let t1 ← LemireInst.pow10_fast_path i4
772: let value ← coreopsarithMulInst.mul t t1
774: then let t2 ← coreopsarithNegInst.neg value
1018: let i5 ← lift (1#u8 &&& i4)
1219: let shift1 ← lift (shift &&& 63#usize)
1228: let i1 ← x_a >>> 11#i32
1230: let i2 ← lift (2047#u16 &&& x_a)
1232: let i3 ← lift (2047#u16 &&& x_b)
1264: let i2 ← i1 <<< shift
1370: let i ← n >>> shift
1400: let i ← n >>> shift
1451: let i1 ← n >>> shift
1453: let i2 ← lift (n &&& mask)
1490: let i ← n >>> shift
1492: let i1 ← lift (n &&& mask)
1544: let i4 ← 1#u64 <<< shift
1704: let i3 ← 1#i64 <<< 59#i32
2971: let i3 ← r >>> 64#i32
2990: then 18446744073709551615#u64 >>> precision
3000: let i4 ← lift (first_hi &&& mask)
3016: let i2 ← i1 >>> 16#i32
3028: let i ← traitsFloatInst.INFINITE_POWER
3045: let w1 ← w <<< lz
3046: let i5 ← traitsFloatInst.SIG_BITS
3058: let i8 ← hi >>> 63#i32
3064: let mantissa ← hi >>> i12
3070: let i18 ← traitsFloatInst.EXP_MIN
3081: let mantissa1 ← mantissa >>> i22
3082: let i23 ← lift (mantissa1 &&& 1#u64)
3084: let mantissa3 ← mantissa2 >>> 1#i32
3085: let i24 ← 1#u64 <<< i5
3102: let i24 ← lift (mantissa &&& 3#u64)
3108: let i28 ← mantissa <<< i27
3111: ok (mantissa &&& i29)
3117: let i20 ← lift (mantissa1 &&& 1#u64)
3119: let mantissa3 ← mantissa2 >>> 1#i32
3120: let i21 ← 2#u64 <<< i5
3125: let mantissa5 ← 1#u64 <<< i5
3129: let i22 ← 1#u64 <<< i5
3131: let mantissa5 ← lift (mantissa4 &&& i23)
3137: let i8 ← hi >>> 63#i32
3143: let mantissa ← hi >>> i12
3149: let i18 ← traitsFloatInst.EXP_MIN
3160: let mantissa1 ← mantissa >>> i22
3161: let i23 ← lift (mantissa1 &&& 1#u64)
3163: let mantissa3 ← mantissa2 >>> 1#i32
3164: let i24 ← 1#u64 <<< i5
3181: let i24 ← lift (mantissa &&& 3#u64)
3187: let i28 ← mantissa <<< i27
3190: ok (mantissa &&& i29)
3196: let i20 ← lift (mantissa1 &&& 1#u64)
3198: let mantissa3 ← mantissa2 >>> 1#i32
3199: let i21 ← 2#u64 <<< i5
3204: let mantissa5 ← 1#u64 <<< i5
3208: let i22 ← 1#u64 <<< i5
3210: let mantissa5 ← lift (mantissa4 &&& i23)
3232: let i ← LemireInst.traitsFloatExtInst.FloatInst.SIG_TOTAL_BITS
3233: 1#u64 <<< i
3240: let bits ← core.f64.F64.to_bits self
3241: let i ← bits >>> 63#i32
3245: let i1 ← core.f64.F64.EXPONENT_MASK
3246: let i2 ← lift (bits &&& i1)
3247: let i3 ← i2 >>> 52#i32
3253: let i4 ← core.f64.F64.MANTISSA_MASK
3254: let i5 ← lift (bits &&& i4)
3255: i5 <<< 1#i32
3258: let i4 ← core.f64.F64.MANTISSA_MASK
3259: let i5 ← lift (bits &&& i4)
3260: let i6 ← 1#u64 <<< 52#i32
3261: ok (i5 ||| i6)
3269:def F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3271: core.f64.F64.from_bits v
3278: core.f64.F64.classify self
3285: core.f64.F64.to_bits self
3324: core.f64.F64.MANTISSA_MASK
3331: core.f64.F64.EXPONENT_MASK
3339: core.f64.F64.MANTISSA_DIGITS
3352: core.f64.F64.from_bits 18444492273895866368#u64
3359: core.f64.F64.NAN
3366: core.f64.F64.NEG_INFINITY
3373: core.f64.F64.INFINITY
3381: let i ← FloatInst.EXP_BIAS
3392: let i ← FloatInst.EXP_SAT
3393: i >>> 1#i32
3402: let i ← FloatInst.EXP_SAT
3411: let i ← FloatInst.EXP_BITS
3412: let i1 ← 1#u32 <<< i
3422: let i1 ← FloatInst.SIG_BITS
3432: let i ← FloatInst.SIG_TOTAL_BITS
3471: coreopsbitShrSelfU32SelfInst := U64.Insts.CoreOpsBitShrU32U64
3472: coreopsbitShlSelfU32SelfInst := U64.Insts.CoreOpsBitShlU32U64
3473: coreopsbitBitAndInst := U64.Insts.CoreOpsBitBitAndU64U64
3474: coreopsbitBitOrInst := U64.Insts.CoreOpsBitBitOrU64U64
3512: coreopsarithDivInst := F64.Insts.CoreOpsArithDivF64F64
3513: coreopsarithNegInst := F64.Insts.CoreOpsArithNegF64
3514: coreopsarithMulInst := F64.Insts.CoreOpsArithMulF64F64
3529: from_u64_bits := F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.from_u64_bits
3537:axiom F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3543:def F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3545: let i ← lift (exponent &&& 31#usize)
3547: | 0 => core.f64.F64.from_bits 4607182418800017408#u64
3548: | 1 => core.f64.F64.from_bits 4621819117588971520#u64
3549: | 2 => core.f64.F64.from_bits 4636737291354636288#u64
3550: | 3 => core.f64.F64.from_bits 4652007308841189376#u64
3551: | 4 => core.f64.F64.from_bits 4666723172467343360#u64
3552: | 5 => core.f64.F64.from_bits 4681608360884174848#u64
3553: | 6 => core.f64.F64.from_bits 4696837146684686336#u64
3554: | 7 => core.f64.F64.from_bits 4711630319722168320#u64
3555: | 8 => core.f64.F64.from_bits 4726483295884279808#u64
3556: | 9 => core.f64.F64.from_bits 4741671816366391296#u64
3557: | 10 => core.f64.F64.from_bits 4756540486875873280#u64
3558: | 11 => core.f64.F64.from_bits 4771362005757984768#u64
3559: | 12 => core.f64.F64.from_bits 4786511204640096256#u64
3560: | 13 => core.f64.F64.from_bits 4801453603149578240#u64
3561: | 14 => core.f64.F64.from_bits 4816244402031689728#u64
3562: | 15 => core.f64.F64.from_bits 4831355200913801216#u64
3563: | 16 => core.f64.F64.from_bits 4846369599423283200#u64
3564: | 17 => core.f64.F64.from_bits 4861130398305394688#u64
3565: | 18 => core.f64.F64.from_bits 4876203697187506176#u64
3566: | 19 => core.f64.F64.from_bits 4891288408196988160#u64
3567: | 20 => core.f64.F64.from_bits 4906019910204099648#u64
3568: | 21 => core.f64.F64.from_bits 4921056587992461136#u64
3569: | 22 => core.f64.F64.from_bits 4936209963552724370#u64
3570: | _ => core.f64.F64.from_bits 0#u64
3606: F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path
3607: from_u64 := F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
3643: let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
3644: let i2 ← i <<< i1
3645: let word ← lift (x.m ||| i2)
3646: traitsFloatExtInst.from_u64_bits word
3903: let i ← traitsFloatInst.EXP_MIN
3939: let i ← traitsFloatInst.INFINITE_POWER
3971: let i5 ← traitsFloatInst.EXP_MIN
3977: let i8 ← traitsFloatInst.SIG_BITS
3984: let i12 ← 1#u64 <<< i11
3999: let i16 ← 1#u64 <<< i8
4004: let i17 ← 1#u64 <<< i8
4006: let mantissa2 ← lift (mantissa1 &&& i18)
4011: let i14 ← 1#u64 <<< i8
4016: let i15 ← 1#u64 <<< i8
4018: let mantissa1 ← lift (mantissa &&& i16)
4035: let register1 ← lift (register &&& 16131858542891098079#u64)
4039: let float ← traitsFloatInst.INFINITY
4041: then let t ← traitsFloatInst.coreopsarithNegInst.neg float
4056: let i5 ← c <<< 16#i32
4057: let i6 ← b <<< 8#i32
4058: let i7 ← lift (i5 ||| i6)
4059: let register ← lift (i7 ||| a)
4060: let register1 ← lift (register &&& 16131858542891098079#u64)
4063: let float ← traitsFloatInst.INFINITY
4066: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4071: let float ← traitsFloatInst.NAN
4074: let t ← traitsFloatInst.coreopsarithNegInst.neg float
4237: let i1 ← v1 >>> 8#i32
4239: let i2 ← lift (v2 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4243: let i3 ← v2 >>> 16#i32
4244: let i4 ← lift (i3 &&& num.imp.dec2flt.parse.parse_8digits.MASK)
4249: let i6 ← i5 >>> 32#i32
4561: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4562: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4563: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4611: coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
4656: let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
4657: let i2 ← i <<< i1
4658: let assembled_word ← lift (selected_pair.m ||| i2)
4664: let result ← coreopsarithNegInst.neg assembly_result
4731: num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
4732: core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
4733: (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
4737: num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
4738: coreopsarithMulInst coreopsarithNegInst s
STDERR:
(empty)
Rust inventory is a complete operation-syntax superset, including generic and scalar forms;
trait bounds, comments and non-U64 integer operations are included, not silently omitted.
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: rg -n '<<|>>|[&|]|Neg::neg|Div::div|Mul::mul|from_u64|pow10_fast_path|SIG_BITS|SIG_TOTAL_BITS|F::NAN|F::INFINITY|Some\(-float\)' crate/traits.rs crate/dec2flt
EXIT: 0
STDOUT:
crate/traits.rs:95: const SIG_TOTAL_BITS: u32;
crate/traits.rs:101: const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
crate/traits.rs:104: const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
crate/traits.rs:110: const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
crate/traits.rs:116: const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
crate/traits.rs:137: /// (in the 32-bit case). In both cases,the power of five(5^|q|)
crate/traits.rs:172: fn from_u64_bits(v: u64) -> Self;
crate/traits.rs:177: /// exponent will be `-(EXP_BIAS + SIG_BITS)`, which is the minimum subnormal power. For
crate/traits.rs:178: /// infinity or NaN, the exponent will be `EXP_SAT - EXP_BIAS - SIG_BITS`.
crate/traits.rs:204: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:229: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:230: Self::from_bits((v & 0xFFFF) as u16)
crate/traits.rs:238: let sign = if bits >> 15 == 0 { 1 } else { -1 };
crate/traits.rs:239: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
crate/traits.rs:241: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:243: (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
crate/traits.rs:264: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:288: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:289: f32::from_bits((v & 0xFFFFFFFF) as u32)
crate/traits.rs:297: let sign = if bits >> 31 == 0 { 1 } else { -1 };
crate/traits.rs:298: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
crate/traits.rs:300: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:302: (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
crate/traits.rs:320: const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
crate/traits.rs:341: fn from_u64_bits(v: u64) -> Self {
crate/traits.rs:350: let sign = if bits >> 63 == 0 { 1 } else { -1 };
crate/traits.rs:351: let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
crate/traits.rs:353: (bits & Self::MANTISSA_MASK) << 1
crate/traits.rs:355: (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
crate/dec2flt/common.rs:10: fn read_u64(&self) -> u64;
crate/dec2flt/common.rs:13: fn write_u64(&mut self, value: u64);
crate/dec2flt/common.rs:16: fn offset_from(&self, other: &Self) -> isize;
crate/dec2flt/common.rs:22: fn read_u64(&self) -> u64 {
crate/dec2flt/common.rs:24: tmp.copy_from_slice(&self[..8]);
crate/dec2flt/common.rs:29: fn write_u64(&mut self, value: u64) {
crate/dec2flt/common.rs:30: self[..8].copy_from_slice(&value.to_le_bytes())
crate/dec2flt/common.rs:34: fn offset_from(&self, other: &Self) -> isize {
crate/dec2flt/common.rs:47: (a | b) & 0x8080_8080_8080_8080 == 0
crate/dec2flt/mod.rs:116: /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:120: /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
crate/dec2flt/mod.rs:124: /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
crate/dec2flt/mod.rs:127: /// Maximum mantissa for the fast-path (`1 << 53` for f64).
crate/dec2flt/mod.rs:128: const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
crate/dec2flt/mod.rs:131: fn pow10_fast_path(exponent: usize) -> Self;
crate/dec2flt/mod.rs:137: fn from_u64(v: u64) -> Self;
crate/dec2flt/mod.rs:147: // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
crate/dec2flt/mod.rs:153: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:157: match exponent & 7 {
crate/dec2flt/mod.rs:172: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:183: // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
crate/dec2flt/mod.rs:187: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:190: match exponent & 15 {
crate/dec2flt/mod.rs:211: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:218: // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
crate/dec2flt/mod.rs:222: fn pow10_fast_path(exponent: usize) -> Self {
crate/dec2flt/mod.rs:226: match exponent & 31 {
crate/dec2flt/mod.rs:263: fn from_u64(v: u64) -> Self {
crate/dec2flt/mod.rs:284: word |= (x.p_biased as u64) << F::SIG_BITS;
crate/dec2flt/mod.rs:285: F::from_u64_bits(word)
crate/dec2flt/mod.rs:299: SignOnly { body: &'a [u8], negative: bool },
crate/dec2flt/mod.rs:302: body: &'a [u8],
crate/dec2flt/mod.rs:309: body: &'a [u8],
crate/dec2flt/mod.rs:317: body: &'a [u8],
crate/dec2flt/mod.rs:330: pub body: &'a [u8],
crate/dec2flt/mod.rs:362: s: &'a str,
crate/dec2flt/mod.rs:365: let Some(&c) = body.first() else {
crate/dec2flt/mod.rs:369: if c == b'-' || c == b'+' {
crate/dec2flt/mod.rs:370: body = &body[1..];
crate/dec2flt/mod.rs:431: // occur exactly when `many_digits && fp.p_biased >= 0`.
crate/dec2flt/mod.rs:432: let second_compute_guard = num.many_digits && fp.p_biased >= 0;
crate/dec2flt/mod.rs:468: let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
crate/dec2flt/mod.rs:472: core::ops::Neg::neg(assembly_result)
crate/dec2flt/mod.rs:514: s: &str,
crate/dec2flt/fpu.rs:31: /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
crate/dec2flt/fpu.rs:32: /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
crate/dec2flt/fpu.rs:33: /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
crate/dec2flt/fpu.rs:52: in(reg) &cw,
crate/dec2flt/fpu.rs:76: in(reg) &mut cw,
crate/dec2flt/fpu.rs:83: set_cw((cw & 0xFCFF) | cw_precision);
crate/dec2flt/fpu.rs:89: fn drop(&mut self) {
crate/dec2flt/decimal.rs:42: fn can_use_fast_path<F: Lemire>(&self) -> bool {
crate/dec2flt/decimal.rs:44: && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
crate/dec2flt/decimal.rs:45: && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
crate/dec2flt/decimal.rs:46: && !self.many_digits
crate/dec2flt/decimal.rs:65: &self,
crate/dec2flt/decimal.rs:84: let value = F::from_u64(self.mantissa);
crate/dec2flt/decimal.rs:88: core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
crate/dec2flt/decimal.rs:90: core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
crate/dec2flt/decimal.rs:99: core::ops::Mul::mul(
crate/dec2flt/decimal.rs:100: F::from_u64(mantissa),
crate/dec2flt/decimal.rs:101: F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
crate/dec2flt/decimal.rs:106: Some(core::ops::Neg::neg(value))
crate/dec2flt/decimal_seq.rs:74: pub(super) fn try_add_digit(&mut self, digit: u8) {
crate/dec2flt/decimal_seq.rs:83: pub fn trim(&mut self) {
crate/dec2flt/decimal_seq.rs:92: while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
crate/dec2flt/decimal_seq.rs:97: pub(super) fn round(&self) -> u64 {
crate/dec2flt/decimal_seq.rs:98: if self.num_digits == 0 || self.decimal_point < 0 {
crate/dec2flt/decimal_seq.rs:118: if self.digits[dp] == 5 && dp + 1 == self.num_digits {
crate/dec2flt/decimal_seq.rs:119: round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
crate/dec2flt/decimal_seq.rs:130: pub(super) fn left_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:142: n += (self.digits[read_index] as u64) << shift;
crate/dec2flt/decimal_seq.rs:176: pub(super) fn right_shift(&mut self, shift: usize) {
crate/dec2flt/decimal_seq.rs:181: while (n >> shift) == 0 && !all_zero {
crate/dec2flt/decimal_seq.rs:191: while (n >> shift) == 0 {
crate/dec2flt/decimal_seq.rs:209: let mask = (1_u64 << shift) - 1;
crate/dec2flt/decimal_seq.rs:211: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:212: n = (10 * (n & mask)) + self.digits[read_index] as u64;
crate/dec2flt/decimal_seq.rs:218: let new_digit = (n >> shift) as u8;
crate/dec2flt/decimal_seq.rs:219: n = 10 * (n & mask);
crate/dec2flt/decimal_seq.rs:236:fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
crate/dec2flt/decimal_seq.rs:240: while i != 0 && scanning {
crate/dec2flt/decimal_seq.rs:242: if c == b'0' || c == b'.' {
crate/dec2flt/decimal_seq.rs:254:// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
crate/dec2flt/decimal_seq.rs:257:fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
crate/dec2flt/decimal_seq.rs:259: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/decimal_seq.rs:264: &s[count..]
crate/dec2flt/decimal_seq.rs:288:pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
crate/dec2flt/decimal_seq.rs:296: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:297: s = &s[1..];
crate/dec2flt/decimal_seq.rs:300: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:302: if !s.is_empty() && s[0] == b'.' {
crate/dec2flt/decimal_seq.rs:303: s = &s[1..];
crate/dec2flt/decimal_seq.rs:309: while !s.is_empty() && s[0] == b'0' {
crate/dec2flt/decimal_seq.rs:310: s = &s[1..];
crate/dec2flt/decimal_seq.rs:313: while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
crate/dec2flt/decimal_seq.rs:320: s = &s[8..];
crate/dec2flt/decimal_seq.rs:322: s = parse_digits_into_seq(s, &mut d);
crate/dec2flt/decimal_seq.rs:350: if ch == b'e' || ch == b'E' {
crate/dec2flt/decimal_seq.rs:362: let mut exponent_suffix = &s[1..];
crate/dec2flt/decimal_seq.rs:363: explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
crate/dec2flt/decimal_seq.rs:375:fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
crate/dec2flt/decimal_seq.rs:433: shift &= 63;
crate/dec2flt/decimal_seq.rs:436: let num_new_digits = (x_a >> 11) as _;
crate/dec2flt/decimal_seq.rs:437: let pow5_a = (0x7FF & x_a) as usize;
crate/dec2flt/decimal_seq.rs:438: let pow5_b = (0x7FF & x_b) as usize;
crate/dec2flt/decimal_seq.rs:439: let pow5 = &TABLE_POW5[pow5_a..];
crate/dec2flt/decimal_seq.rs:441: for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
crate/dec2flt/lemire.rs:32: if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
crate/dec2flt/lemire.rs:39: w <<= lz;
crate/dec2flt/lemire.rs:40: let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
crate/dec2flt/lemire.rs:57: let inside_safe_exponent = (q >= -27) && (q <= 55);
crate/dec2flt/lemire.rs:62: let upperbit = (hi >> 63) as i32;
crate/dec2flt/lemire.rs:63: let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
crate/dec2flt/lemire.rs:71: mantissa >>= -power2 + 1;
crate/dec2flt/lemire.rs:72: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:73: mantissa >>= 1;
crate/dec2flt/lemire.rs:74: power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
crate/dec2flt/lemire.rs:89: && q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:90: && q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
crate/dec2flt/lemire.rs:91: && mantissa & 0b11 == 0b01
crate/dec2flt/lemire.rs:92: && (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
crate/dec2flt/lemire.rs:95: mantissa &= !1_u64;
crate/dec2flt/lemire.rs:98: mantissa += mantissa & 1;
crate/dec2flt/lemire.rs:99: mantissa >>= 1;
crate/dec2flt/lemire.rs:100: if mantissa >= (2_u64 << F::SIG_BITS) {
crate/dec2flt/lemire.rs:104: mantissa = 1_u64 << F::SIG_BITS;
crate/dec2flt/lemire.rs:108: mantissa &= !(1_u64 << F::SIG_BITS);
crate/dec2flt/lemire.rs:122: (q.wrapping_mul(152_170 + 65536) >> 16) + 63
crate/dec2flt/lemire.rs:128: (r as u64, (r >> 64) as u64)
crate/dec2flt/lemire.rs:140: 0xFFFF_FFFF_FFFF_FFFF_u64 >> precision
crate/dec2flt/lemire.rs:155: if first_hi & mask == mask {
crate/dec2flt/slow.rs:27:pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
crate/dec2flt/slow.rs:33: let get_shift = |n| {
crate/dec2flt/slow.rs:43: if d.num_digits == 0 || d.decimal_point < -324 {
crate/dec2flt/slow.rs:51: while d.decimal_point > 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:69: while d.decimal_point <= 0 && loop_result.is_none() {
crate/dec2flt/slow.rs:73: 0 | 1 => 2,
crate/dec2flt/slow.rs:107: d.left_shift(F::SIG_BITS as usize + 1);
crate/dec2flt/slow.rs:109: if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
crate/dec2flt/slow.rs:120: if mantissa < (1_u64 << F::SIG_BITS) {
crate/dec2flt/slow.rs:124: mantissa &= (1_u64 << F::SIG_BITS) - 1;
crate/dec2flt/parse.rs:23: v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
crate/dec2flt/parse.rs:24: let v1 = (v & MASK).wrapping_mul(MUL1);
crate/dec2flt/parse.rs:25: let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
crate/dec2flt/parse.rs:26: ((v1.wrapping_add(v2) >> 32) as u32) as u64
crate/dec2flt/parse.rs:30:fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
crate/dec2flt/parse.rs:40: s = &s[8..];
crate/dec2flt/parse.rs:50: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:55: s = &s[count..];
crate/dec2flt/parse.rs:61:fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
crate/dec2flt/parse.rs:86:fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
crate/dec2flt/parse.rs:89: while scan_index < start.len() && scanning {
crate/dec2flt/parse.rs:91: if c == b'.' || c == b'0' {
crate/dec2flt/parse.rs:104:fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
crate/dec2flt/parse.rs:107: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:111: s = &s[1..];
crate/dec2flt/parse.rs:113: try_parse_19digits(&mut s, &mut mantissa);
crate/dec2flt/parse.rs:121:pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
crate/dec2flt/parse.rs:127: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:129: if c == b'-' || c == b'+' {
crate/dec2flt/parse.rs:137: if !s.is_empty() && s[0].is_ascii_digit() {
crate/dec2flt/parse.rs:145: while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
crate/dec2flt/parse.rs:147: if exponent < (1_i64 << 59) {
crate/dec2flt/parse.rs:152: *s_ref = &s[count..];
crate/dec2flt/parse.rs:164:fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
crate/dec2flt/parse.rs:180: if let Some((&b'.', s_next)) = s.split_first() {
crate/dec2flt/parse.rs:197: if let Some((&c, s_next)) = s.split_first() {
crate/dec2flt/parse.rs:198: if c == b'e' || c == b'E' {
crate/dec2flt/parse.rs:201: exp_number = parse_scientific(&mut s)?;
crate/dec2flt/parse.rs:234:pub fn parse_number(s: &[u8]) -> Option<Decimal> {
crate/dec2flt/parse.rs:244:pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
crate/dec2flt/parse.rs:260: register = (c << 16) | (b << 8) | a;
crate/dec2flt/parse.rs:269: register &= 0xDFDFDFDFDFDFDFDF;
crate/dec2flt/parse.rs:280: (INF_3, 3) => F::INFINITY,
crate/dec2flt/parse.rs:281: (INF_8, 8) => F::INFINITY,
crate/dec2flt/parse.rs:282: (NAN, 3) => F::NAN,
crate/dec2flt/parse.rs:286: if negative { Some(-float) } else { Some(float) }
STDERR:
(empty)
Current guarded native body, exact f64 boundary and unrestricted assembler:
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 39,111p crate/dec2flt/decimal.rs
EXIT: 0
STDOUT:
impl Decimal {
/// Detect if the float can be accurately reconstructed from native floats.
#[inline]
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
/// Try turning the decimal into an exact float representation, using machine-sized integers
/// and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
/// can be exactly represented as a machine float, since IEE-754 guarantees
/// no rounding will occur.
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
pub fn try_fast_path<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
&self,
) -> Option<F> {
// `Lemire` already entails these three operator bounds through
// `Float`; spelling them directly changes no admitted type. Charon
// needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
// The `set_precision` function takes care of setting the precision on architectures which
// require setting it by changing the global state (like the control word of the x87 FPU).
let _cw = set_precision::<F>();
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 112,138p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
///
/// Not intended for use outside of the `dec2flt` module.
#[doc(hidden)]
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
/// Gets a small power-of-ten for fast-path multiplication.
fn pow10_fast_path(exponent: usize) -> Self;
/// Converts integer into float through an as cast.
/// This is only called in the fast-path algorithm, and therefore
/// will not lose precision, since the value will always have
/// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
fn from_u64(v: u64) -> Self;
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 217,286p crate/dec2flt/mod.rs
EXIT: 0
STDOUT:
impl Lemire for f64 {
// Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
#[inline]
pub(super) fn pfe_empty() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Empty }
}
// Used in unit tests, keep public.
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
#[inline]
pub fn pfe_invalid() -> ParseFloatError {
ParseFloatError { kind: FloatErrorKind::Invalid }
}
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 315,365p crate/traits.rs
EXIT: 0
STDOUT:
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
// Exact value of trunc(1024 / log2(10)) from the upstream default.
const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
// This is the upstream default after substituting `Self::Int = u64`;
// it preserves every decoded field while avoiding unsupported generic
// associated-integer operator resolution.
fn integer_decode(self) -> (u64, i16, i8) {
let bits = self.to_bits();
let sign = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
let mantissa = if exponent == 0 {
(bits & Self::MANTISSA_MASK) << 1
} else {
(bits & Self::MANTISSA_MASK) | (1_u64 << 52)
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sed -n 245,291p crate/dec2flt/parse.rs
EXIT: 0
STDOUT:
// Since a valid string has at most the length 8, we can load
// all relevant characters into a u64 and work from there.
// This also generates much better code.
let mut register;
let len: usize;
// All valid strings are either of length 8 or 3.
if s.len() == 8 {
register = s.read_u64();
len = 8;
} else if s.len() == 3 {
let a = s[0] as u64;
let b = s[1] as u64;
let c = s[2] as u64;
register = (c << 16) | (b << 8) | a;
len = 3;
} else {
return None;
}
// Clear out the bits which turn ASCII uppercase characters into
// lowercase characters. The resulting string is all uppercase.
// What happens to other characters is irrelevant.
register &= 0xDFDFDFDFDFDFDFDF;
// u64 values corresponding to relevant cases
const INF_3: u64 = 0x464E49; // "INF"
const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
const NAN: u64 = 0x4E414E; // "NAN"
// Match register value to constant to parse string.
// Also match on the string length to catch edge cases
// like "inf\0\0\0\0\0".
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
}
STDERR:
(empty)
Fresh constant and symbolic-negation reproduction
=================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C opt-level=0 reference/model-evidence/binary64-probe.rs -o .trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/binary64-probe
EXIT: 0
STDOUT:
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.ll
EXIT: 0
STDOUT:
; ModuleID = 'binary64_negation_probe.566fd6d762029c-cgu.0'
source_filename = "binary64_negation_probe.566fd6d762029c-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}
!0 = !{i32 8, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 7, !"uwtable", i32 2}
!3 = !{!"rustc version 1.98.0-nightly (14210df0e 2026-05-31)"}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm reference/model-evidence/binary64-negation-probe.rs -o .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: cat .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
.file "binary64_negation_probe.566fd6d762029c-cgu.0"
.section .text.neg_f64_trait_bits,"ax",@progbits
.globl neg_f64_trait_bits
.p2align 4
.type neg_f64_trait_bits,@function
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
.Lfunc_end0:
.size neg_f64_trait_bits, .Lfunc_end0-neg_f64_trait_bits
.cfi_endproc
.ident "rustc version 1.98.0-nightly (14210df0e 2026-05-31)"
.section ".note.GNU-stack","",@progbits
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: sha256sum .trellis/scratch/binary64-probe .trellis/scratch/binary64-negation-probe.ll .trellis/scratch/binary64-negation-probe.s
EXIT: 0
STDOUT:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322 .trellis/scratch/binary64-probe
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
STDERR:
(empty)
Fresh checked-shift reproduction and full dynamic-count MIR
===========================================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shl-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir ../../reference/model-evidence/u64-shl-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shl-probe u64-shl-probe.mir
EXIT: 0
STDOUT:
1d8bda234272af0f20a360fe4ff631c8ed038f9aac02bfe539192fff86706d4c u64-shl-probe
1d05de9f3cfb93082c17a57d39f7fc0813c3fe0d3ebd0efe470b0885fba931b9 u64-shl-probe.mir
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind ../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: ./u64-shr-probe
EXIT: 0
STDOUT:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --target x86_64-unknown-linux-gnu -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir ../../reference/model-evidence/u64-shr-probe.rs
EXIT: 0
STDOUT:
(empty)
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
EXIT: 0
STDOUT:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
STDERR:
(empty)
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch
COMMAND: sha256sum u64-shr-probe u64-shr-probe.mir
EXIT: 0
STDOUT:
1cceba3e03b755a37112c16ad347161a9732793944f34d0a740470584a08c9fc u64-shr-probe
9a72f1d018d926b3e5672c8fb473e2495a710cf4a252c7515e12d2e5009c134e u64-shr-probe.mir
STDERR:
(empty)
Interpretation and limits
=========================
The constant source really evaluates f64::NAN; its nan=7ff8000000000000 observation
fixes that pinned constant, not arbitrary arithmetic-NaN signs or payloads.
The arbitrary-u64 qualified Neg probe passes w in rdi; movabsq loads 2^63 in rax,
xorq combines them, retq returns rax, with no branch or NaN exception. Its XOR law
holds for all 2^64 words, including every signaling/quiet NaN payload.
The checked dynamic-count MIR establishes the whole U64 x U32 branch condition,
not merely seven runtime samples: counts <64 shift, counts >=64 fail, without masking.
AND/OR remain exact over all words. from_u64 still asserts <=2^53 before casting;
the ordinary source guard gives -22<=exponent<=22, mantissa<=2^53, !many_digits.
The disguised source arm checks its integer product and <=2^53 before the cast,
and uses fixed table index 22. Only then may conditional Binary64NativeCallDomain
supply finite non-NaN cast/table operands and a positive nonzero divisor.
Thus reached native arithmetic is exact; generic arithmetic NaNs retain permitted-choice
semantics, not universal exact-bit equivalence. Assembly admits every BiasedFp field pair.
Equal-target preservation retains both rounding relations to the same target, without
deriving uniqueness from vocabulary or assuming an unresolved GOAL conclusion.
All 32 original GOALs remain pursued with their own quantifiers, domains and polarity.
These source-facing checks are evidence, not preservation Sound certification or GOAL proofs.
Managed checks and final scope verification
===========================================
CWD: /home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo
COMMAND: python3 .trellis/scripts/pv_modeling.py compose-native . --check
EXIT: 0
Selected raw result fields:
{
"full_result": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/11/repo/.trellis/scratch/compose-native-1791584636440554217.json",
"matches": true,
"changed": false,
"mismatched_files": [],
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
COMMAND: python3 .trellis/scripts/check.py model-support-check .
EXIT: 0
Raw result:
{"ok": true, "errors": []}
COMMAND: python3 .trellis/scripts/check.py tablet . --json
EXIT: 0
Structured projection from the final full managed JSON result:
{
"command": [
"python3",
".trellis/scripts/check.py",
"tablet",
".",
"--json"
],
"exit_status": 0,
"ok": true,
"errors": [],
"node_count": 340,
"all_nodes_compile": true,
"elaboration_failures": [],
"structure_failures": [],
"warning_count": 696,
"warning_examples": [
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:364:4: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/Slice.lean:587:8: declaration uses `sorry`",
"AssemblyCorrespondence: warning: Aeneas/Std/StringIter.lean:13:4: declaration uses `sorry`"
],
"raw_stdout_sha256": "15a1d03a085481d315bcc1a4716aa174475f03e72d8f452f5f33d45a71f5ed91",
"stderr_line_count": 340,
"raw_stderr_sha256": "50c8fde0aef24c1b87ce95c51d21794927d6abba46d90fd04a8d3a714bfed46e"
}
This final command was captured and summarized by
python3 .trellis/scratch/managed-tablet-summary.py (exit 0).
Two earlier identical whole-Tablet checks also exited 0; one jq projection
reported tablet_exit=0 jq_exit=0, node_count=340, failing_elaboration=[],
invalid_structure=[]. The first tool preview truncated its verbose JSON;
that truncation was not used as a proof-closure certificate. The retained
warnings include permitted principal GOAL sketches and installed Aeneas
Slice/StringIter sorry warnings. No definition was supplied with sorry.
These checks establish elaboration, structure and composition freshness,
not preservation Sound or proof closure of the pursued GOALs.
COMMAND: python3 .trellis/scratch/preservation-scope-check.py
EXIT: 0
Raw result:
{
"ok": true,
"owner_checks": [
{
"node": "Binary64ModelDefault",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "210652331cd53e0254aae45856663c01d0552fe992b69608fe243260022ccd79"
},
{
"node": "ModelF64Neg",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "f7d74d4558333c0754ccce8f6861d1409c049fd4dfd1825daad2fd2f441eb78f"
},
{
"node": "ModelU64BitAnd",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "b401e17a058ec2909fb7a58d01f07867f03a933c2901338efebda252692ca6ff"
},
{
"node": "ModelU64BitOr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "c53e3e5ad29cc4419d07c3f2a8913e0f4df87ecbcf4ac1567a9e699a2bd18e2d"
},
{
"node": "ModelU64Shl",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "ed68845da19138d7406e8022c5a9adb765ed70c2ed075f41aea7c190dea9909a"
},
{
"node": "ModelU64Shr",
"ordinary_definition_unchanged": true,
"lean_unchanged": true,
"distinct_original_goal_applications": 32,
"tex_sha256": "04b6ec376e7ec490c64183f2a18be832ea574391d7f24d49db7ddc10019cd2f0"
}
],
"principal_goal_pairs": [
{
"node": "AssemblyCorrespondence",
"target": "assembly_correspondence",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationDeterminism",
"target": "classification_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationSignificandDigit",
"target": "classification_significand_digit",
"paired_files_byte_unchanged": true
},
{
"node": "ClassificationTotality",
"target": "classification_totality",
"paired_files_byte_unchanged": true
},
{
"node": "ExponentValueAgreement",
"target": "exponent_value_agreement",
"paired_files_byte_unchanged": true
},
{
"node": "IntegerCorrectOrDefer",
"target": "integer_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NativeCorrectOrDefer",
"target": "native_correct_or_defer",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAcceptance",
"target": "number_helper_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperAccumulatedValue",
"target": "number_helper_accumulated_value",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRecordBounds",
"target": "number_helper_record_bounds",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_NumberHelperRejection",
"target": "number_helper_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserAccumulatedRounding",
"target": "parser_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserEqualTargetRounding",
"target": "parser_equal_target_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserExactRounding",
"target": "parser_exact_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInfinity",
"target": "parser_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserInvalidRejection",
"target": "parser_invalid_rejection",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNanAcceptance",
"target": "parser_nan_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNonNanResults",
"target": "parser_non_nan_results",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericAcceptance",
"target": "parser_numeric_acceptance",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserNumericSign",
"target": "parser_numeric_sign",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserSignedZero",
"target": "parser_signed_zero",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_ParserTotality",
"target": "parser_totality",
"paired_files_byte_unchanged": true
},
{
"node": "P13_T1_SlowAccumulatedRounding",
"target": "slow_accumulated_rounding",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchAbstractComposition",
"target": "dispatch_abstract_composition",
"paired_files_byte_unchanged": true
},
{
"node": "P9_T1_DispatchComponentCompliance",
"target": "dispatch_component_compliance",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedExponent",
"target": "parser_selected_exponent",
"paired_files_byte_unchanged": true
},
{
"node": "ParserSelectedMagnitudeSign",
"target": "parser_selected_magnitude_sign",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingDeterminism",
"target": "rounding_determinism",
"paired_files_byte_unchanged": true
},
{
"node": "RoundingTotality",
"target": "rounding_totality",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperInfinity",
"target": "special_helper_infinity",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperNan",
"target": "special_helper_nan",
"paired_files_byte_unchanged": true
},
{
"node": "SpecialHelperRejection",
"target": "special_helper_rejection",
"paired_files_byte_unchanged": true
}
],
"new_nodes": [],
"evidence_consumers_for_current_Sound": [
"Binary64ModelDefault",
"DecimalGoalVocabularyDefault",
"ModelF64Neg",
"ModelU64BitAnd",
"ModelU64BitOr",
"ModelU64Shl",
"ModelU64Shr"
],
"frozen_boundary_unchanged": true,
"pre_existing_config_delta_unchanged": true,
"changed_paths_in_assigned_scope": [
"Tablet/Binary64ModelDefault.tex",
"Tablet/ModelF64Neg.tex",
"Tablet/ModelU64BitAnd.tex",
"Tablet/ModelU64BitOr.tex",
"Tablet/ModelU64Shl.tex",
"Tablet/ModelU64Shr.tex",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation-probe.rs",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/binary64-probe.rs",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl-probe.rs",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/u64-shr-probe.rs",
"reference/model-evidence/u64-shr.txt"
],
"completion_meaning_audit_still_required": true
}
Delivery, acceptance and certification status
============================================
The executed kernel task is task_id=11 (worker request 118), compiler=managed,
under trellis-worker-acceptance-v2:sha256:6ba29f81c7fad2d256a8a8816e0e2d2dc5d9cb4180238dcef442684979a9ab91.
Submitted scope is exactly the six owners' preservation sections and ten
reserved evidence paths listed above. No acceptance/publication outcome is
available before worker delivery; the host's real receipt must supply it.
The raw-only worker validator and a Submitted marker mean delivery, not host
acceptance, publication, preservation Sound or Modeling completion.
Keep retry-binary64-preservation-exclusively live until actual publication,
and verify-published-preservation-and-meanings live until current certification.
After publication, request current Sound on all changed evidence consumers,
including DecimalGoalVocabularyDefault's u64-shl/u64-bitor citations, and
repaired support before parents whose named gaps remain open. Do not reset
Binary64ModelDefault's genuine VerifierFail based on these worker checks.
The independent all-32 original-GOAL meaning audit remains required before
Modeling completion; a byte-unchanged pair check is not that semantic audit.
reference/model-evidence/aeneas-slice-observations.txt
Aeneas slice-observation evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout and executable used for the frozen extraction are:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Slice.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328
At that commit, Aeneas/Std/Slice.lean:22 defines:
def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max }
Thus an Aeneas Slice is an ordered List subtype. Its val field is the complete
ordered element list; the subtype property is the Usize.max length bound.
sha256sum /home/leanagent/pv_spike/tools/aeneas/documentation/aeneas-overview.md
8ba474e55ec3375f6eaccc7532715e29dc1d0d6473423a02100bb805a446c3a7
At that commit, aeneas-overview.md:240 states the translation convention that
shared borrows (&T) become plain T parameters and that the value may be copied.
The summary table at line 432 additionally describes the resulting value as
immutable. Returned shared byte references therefore have no mutable backward
continuation or separately observable identity in the generated model.
The Rust source is the configured nightly-2026-06-01 core library:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
Its exact observation bodies at core/src/slice/mod.rs:155-156 and 198-199 are:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
These bodies and the same core source hash are also pinned in
reference/model-evidence/binary64-boundary.txt. The complete configured Rust
&[u8] domain, including the isize::MAX byte-length condition, is independently
pinned in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module has this identity:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Its external signatures at generated.lean:316 and 323-324 are:
axiom core.slice.Slice.first {T : Type} :
Slice T → Result (Option T)
axiom core.slice.Slice.split_first {T : Type} :
Slice T → Result (Option (T × Slice T))
The following command enumerates every declaration or call occurrence:
rg -n 'core\.slice\.Slice\.(first|split_first)' generated.lean
Raw result:
316:axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)
323:axiom core.slice.Slice.split_first
4290: let o ← core.slice.Slice.split_first s_ref
4338: let o ← core.slice.Slice.split_first s
4591: let o ← core.slice.Slice.split_first s1
4613: let o1 ← core.slice.Slice.split_first s2
4812: let o ← core.slice.Slice.first body
All five calls infer T = Std.U8:
* generated.lean:4288-4290 declares parse_scientific with
s_ref : Slice Std.U8 and calls split_first on s_ref.
* generated.lean:4332-4338 declares try_parse_19digits_loop.body with
s : Slice Std.U8 and calls split_first on s.
* generated.lean:4582-4591 declares parse_partial_number with
s : Slice Std.U8; try_parse_digits returns s1 : Slice Std.U8, which is the
first split_first argument.
* In the same parse_partial_number definition, every branch defining s2 returns
either s1 or the Std.U8 tail s_next. Hence the call on s2 at line 4613 also
has T = Std.U8.
* generated.lean:4803-4812 declares dec2flt_with_trace; body is returned by
core.str.Str.as_bytes, whose signature at line 330 is
Str → Result (Slice Std.U8), and first is called on body.
The adapted sources containing the corresponding calls are pinned by:
sha256sum crate/dec2flt/parse.rs crate/dec2flt/mod.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f crate/dec2flt/parse.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
The five exact Rust call sites are:
crate/dec2flt/parse.rs:65
if let Some((c, s_next)) = s.split_first() {
let digit = c.wrapping_sub(b'0');
...
s = s_next;
crate/dec2flt/parse.rs:127
if let Some((&c, s_next)) = s.split_first() {
negative = c == b'-';
if c == b'-' || c == b'+' { s = s_next; }
crate/dec2flt/parse.rs:177
if let Some((&b'.', s_next)) = s.split_first() {
s = s_next;
crate/dec2flt/parse.rs:194
if let Some((&c, s_next)) = s.split_first() {
if c == b'e' || c == b'E' { s = s_next; ... }
crate/dec2flt/mod.rs:365
let Some(&c) = body.first() else { ... };
Thus every call is on &[u8]. The call sites either destructure the shared byte
reference into a copied byte or invoke an immutable u8 method through it, and
they use the shared tail only as the next immutable slice. There is no mutation
through a returned reference and no pointer or lifetime identity observation.
Consequently, at every frozen GOAL-facing call site, erasing the
shared-reference lifetime/aliasing data retains the observed U8 value and, for
split_first, the same ordered suffix.
reference/model-evidence/aeneas-string-bytes.txt
Aeneas string/as_bytes evidence
Historical predecessor record
-----------------------------
The original record below belongs to predecessor extraction
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9,
not the current extraction. Its commands, tools, settings, hashes, excerpts and
raw results are retained under their original identities. References to
"frozen" below describe that predecessor, not the current source/extraction.
Checked CURRENT applicability, exact declarations/signatures/Rust symbols,
binding digests and complete current call inventories are recorded separately
in reference/model-evidence/P89_T1_PrimitiveApplicability.txt.
Commands were run from the repository root unless an explicit -C directory is
shown. The Aeneas checkout used for the frozen extraction is pinned by:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
fa699427cdfa8f604b891fb0223ef42883dd7dc4
The configured executable and its identity are pinned by:
jq -r '.effective_tools.aeneas' modeling-input/manifest.json
/home/leanagent/pv_spike/tools/aeneas/bin/aeneas
sha256sum /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922 /home/leanagent/pv_spike/tools/aeneas/bin/aeneas
The Aeneas string definition at that commit is pinned by:
sha256sum /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
412329294f15a509ea526c7506c5f0c2d1a00f45e719049e87c6977b2e365978 /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/String.lean
Its exact definition at Aeneas/Std/String.lean:6 is:
def Str := Slice U8
Thus Aeneas Str itself has only the Aeneas Slice U8 constraints; it does not by
itself impose Rust str's UTF-8 validity or isize::MAX byte-length restriction.
The ordered-list representation of Aeneas Slice, including its Usize.max bound,
is pinned separately in reference/model-evidence/aeneas-slice-observations.txt.
The configured Rust str validity and isize::MAX byte-length conditions are
pinned separately in reference/model-evidence/source-valid-byte-slice.txt.
The frozen generated module and its string external are pinned by:
sha256sum generated.lean
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
The raw declaration at generated.lean:326-331 is:
/-- [core::str::{str}::as_bytes]:
Source: '/rustc/library/core/src/str/mod.rs', lines 498:4-498:41
Name pattern: [core::str::{str}::as_bytes]
Visibility: public -/
@[rust_fun "core::str::{str}::as_bytes"]
axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
The inspect-native raw declaration digest recorded in the support binding is:
11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f
The command
rg -n 'core\.str\.Str\.as_bytes' generated.lean
has the complete raw result:
331:axiom core.str.Str.as_bytes : Str → Result (Slice Std.U8)
4811: let body ← core.str.Str.as_bytes s
Consequently the only call in the frozen generated module is the first
operation in num.imp.dec2flt.dec2flt_with_trace, whose parameter and call at
generated.lean:4807-4811 are:
(coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
Result ((core.result.Result F num.float_parse.ParseFloatError) ×
(num.imp.dec2flt.Dec2FltTrace F))
:= do
let body ← core.str.Str.as_bytes s
The support manifest itself is pinned by:
sha256sum Tablet/model-support.json
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
Its exact binding at Tablet/model-support.json:183-190 is:
{
"name": "core.str.Str.as_bytes",
"extracted_signature": ": Str → Result (Slice Std.U8)",
"rust_symbol": "core::str::{str}::as_bytes",
"raw_declaration_sha256": "11bae0b1f519e9d892c9835bacc776977e8d5dbf1013af4a24178a41025a8b3f",
"node": "ModelStrAsBytes",
"declaration": "dec2flt_model.ModelStrAsBytes"
}
The configured Rust core implementation is pinned by:
sha256sum /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs
Its exact same-layout body at core/src/str/mod.rs:498-501 is:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
The frozen adapted dispatcher source and its sole source call are pinned by:
sha256sum crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
rg -n 'as_bytes' crate
crate/dec2flt/mod.rs:364: let mut body = s.as_bytes();
crate/dec2flt/mod.rs:362-365
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
The core body returns a shared byte slice by same-layout transmutation: it does
not change, reorder, add, or remove bytes and has no failure branch. The Aeneas
shared-borrow convention and the later immutable ordered-byte observations are
pinned in reference/model-evidence/aeneas-slice-observations.txt.
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-negation-probe.rs
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
reference/model-evidence/binary64-negation.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
Primary evidence for binary64 trait negation
============================================
Scope and conclusion
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction and the
nightly-2026-06-01 toolchain fixed by modeling-input/SETUP.md and
modeling-input/manifest.json. It establishes the following statement for the
specific extracted Rust operation bound to ModelF64Neg:
For every u64 word w, including every signaling or quiet NaN payload,
to_bits(<f64 as core::ops::Neg>::neg(f64::from_bits(w)))
equals w XOR 0x8000000000000000.
Thus precisely bit 63 is toggled and every other bit is preserved. This is a
universal symbolic result, not an inference from finitely many test inputs.
Pinned identities
-----------------
The following command was run from the repository root. RROOT is the source
tree installed with the configured compiler.
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
RROOT=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
sha256sum "$R" \
"$RROOT/core/src/ops/arith.rs" \
"$RROOT/core/src/primitive_docs.rs" \
crate/dec2flt/mod.rs upstream/dec2flt/mod.rs \
generated.lean Tablet/model-support.json \
modeling-input/tool-identities.json \
reference/model-evidence/binary64-negation-probe.rs
Raw output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/arith.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/primitive_docs.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d crate/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
c099ae8478fe2cea91a3f82f51a5d3369270ded2bc08a7596ba8cca0c8382e87 Tablet/model-support.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
modeling-input/tool-identities.json records the same rustc path and SHA-256.
The compiler reports:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Concrete core implementation
----------------------------
The following exact excerpt is core/src/ops/arith.rs:709-728 in the source
whose SHA-256 is 596368a6b3e7e16251f13ec80344f170e13517eb927ceaa9e3d4c7a1fa3b8ae0:
macro_rules! neg_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const Neg for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> $t { -self }
}
forward_ref_unop! { impl Neg, neg for $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
The macro invocation explicitly includes f64. Its expansion is therefore the
concrete `impl Neg for f64`, with `Output = f64`, whose method body is the
primitive expression `-self`.
Frozen parser statement and primitive guarantee
------------------------------------------------
The adapted frozen parser and supplied upstream parser have identical text at
dec2flt/mod.rs:20-22. Their complete-file hashes are pinned above. The exact
three lines are:
//! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
//! process and re-apply it at the very end. This is correct in all edge cases since IEEE
//! floats are symmetric around zero, negating one simply flips the first bit.
The installed primitive documentation is pinned above by SHA-256
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5.
At primitive_docs.rs:1369-1375 it identifies f64 as binary64 and directs the
reader to the f32 documentation for the common floating-point rules:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The exact common rule at primitive_docs.rs:1256-1260 is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
This rule expressly covers unary negation and bit conversion, and expressly
distinguishes them from arithmetic NaN production. It therefore preserves the
quiet/signaling bit and every payload bit for NaNs as well as all non-sign bits
for finite values, zeros, and infinities. The parser statement identifies the
permitted sign-bit change as an actual flip in all edge cases.
Extraction and support binding
------------------------------
The frozen generated.lean, pinned above, contains this exact declaration and
trait implementation record:
/-- [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg]:
Source: '/rustc/library/core/src/ops/arith.rs', lines 719:12-719:30
Name pattern: [core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg]
Visibility: public -/
@[rust_fun "core::ops::arith::{core::ops::arith::Neg<f64, f64>}::neg"]
axiom F64.Insts.CoreOpsArithNegF64.neg : F64 → Result F64
/-- Trait implementation: [core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}]
Source: '/rustc/library/core/src/ops/arith.rs', lines 713:8-713:29
Name pattern: [core::ops::arith::Neg<f64, f64>] -/
@[reducible, rust_trait_impl "core::ops::arith::Neg<f64, f64>"]
def F64.Insts.CoreOpsArithNegF64 : core.ops.arith.Neg F64 F64 := {
neg := F64.Insts.CoreOpsArithNegF64.neg
}
Thus the extracted external is the same f64 macro expansion and method body
identified above, not an abstract or different negation operation. Running
`python3 .trellis/scripts/pv_modeling.py inspect-native "$PWD"` and selecting
that declaration gives the following raw inventory fields:
name: F64.Insts.CoreOpsArithNegF64.neg
extracted_signature: : F64 → Result F64
rust_symbol: core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg
raw_declaration_sha256: bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0
The raw declaration hash is independently reproduced after that inspection by:
I=$(ls -1t .trellis/scratch/inspect-native-*.json | head -n 1)
jq -j '.. | objects | select(.name? == "F64.Insts.CoreOpsArithNegF64.neg") | .source_utf8' "$I" | sha256sum
Raw output:
bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0 -
Tablet/model-support.json, whose complete-file hash is pinned above, copies all
four identity fields unchanged and binds this external to the model definition:
{
"name": "F64.Insts.CoreOpsArithNegF64.neg",
"extracted_signature": ": F64 → Result F64",
"rust_symbol": "core::ops::arith::{impl core::ops::arith::Neg<f64> for f64}::neg",
"raw_declaration_sha256": "bbf93f24bd7cfbc72e47e8bb3a9acc6641df939ad6afafd9ba02c81fe27f7ed0",
"node": "ModelF64Neg",
"declaration": "dec2flt_model.ModelF64Neg"
}
Symbolic same-toolchain probe
-----------------------------
The retained probe source is:
#![no_std]
#![crate_type = "lib"]
use core::ops::Neg;
#[no_mangle]
pub extern "C" fn neg_f64_trait_bits(w: u64) -> u64 {
<f64 as Neg>::neg(f64::from_bits(w)).to_bits()
}
The argument is an arbitrary symbolic u64. The qualified call forces the same
`Neg for f64` trait method identified by the core source and extraction. The
following exact commands use the extraction's compiler and target and retain
both optimized LLVM IR and assembly in the worker scratch directory:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-negation-probe.rs
IR=.trellis/scratch/binary64-negation-probe.ll
ASM=.trellis/scratch/binary64-negation-probe.s
"$R" --version --verbose
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=llvm-ir "$P" -o "$IR"
"$R" --edition=2021 --crate-type=lib --target x86_64-unknown-linux-gnu -C opt-level=3 --emit=asm "$P" -o "$ASM"
sha256sum "$R" "$P" "$IR" "$ASM"
cat "$IR"
cat "$ASM"
Raw hash output:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5 reference/model-evidence/binary64-negation-probe.rs
7bbd38648c49de5770cd6716a5556f57ce7935b8cc36cf4077f15d9aceae6ca3 .trellis/scratch/binary64-negation-probe.ll
1b5789b02e9ece231d61a01b1b8b851b4109ea404f30d0b7d546221d1aaaa425 .trellis/scratch/binary64-negation-probe.s
Raw optimized LLVM IR function:
define noundef i64 @neg_f64_trait_bits(i64 noundef %w) unnamed_addr #0 {
start:
%_3 = bitcast i64 %w to double
%_2 = fneg double %_3
%_0 = bitcast double %_2 to i64
ret i64 %_0
}
Raw optimized x86_64 assembly function:
neg_f64_trait_bits:
.cfi_startproc
movabsq $-9223372036854775808, %rax
xorq %rdi, %rax
retq
Under the selected x86_64 C ABI, the symbolic input w arrives in %rdi and the
u64 result is returned in %rax. The loaded signed decimal constant
-9223372036854775808 has u64 bit pattern 0x8000000000000000, with bit 63 set
and every other bit clear. The emitted `xorq %rdi, %rax` therefore returns
w XOR 0x8000000000000000. There is no branch, floating-point exceptional
case, or input precondition in the emitted function.
Universal preservation conclusion
---------------------------------
The core macro and f64 instantiation connect the trait method to primitive
unary `-`; generated.lean and model-support.json connect that exact method to
ModelF64Neg. The parser source says the operation flips the sign bit in all
edge cases, while the primitive guarantee says every non-sign bit is preserved,
including the quiet/signaling and payload bits of NaNs. Finally, the symbolic
same-compiler/same-target probe makes the exact transformation explicit as XOR
with the bit-63 mask for its arbitrary u64 argument.
Because f64::from_bits accepts every one of the 2^64 u64 words and to_bits
returns the resulting raw word, the symbolic input covers the entire modeled
F64 carrier. Consequently the source result for every word is exactly the
model package's `ok` result containing that word with bit 63 toggled. This
includes both signs of zero and infinity, every finite/subnormal word, and
every possible NaN payload without canonicalization or quieting.
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/float-carriers.txt
Primary evidence for the F64 raw-word carrier
Scope
-----
This record supports only the representation claim that the source f64
specialization and the authored F64 carrier have the same set of 64-bit
encodings. It does not supply arithmetic or classification semantics.
All commands below were run from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0001/dec2flt-r0001
Tool and input identities
-------------------------
Command:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
Raw result:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Command:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean --version
Raw result:
Lean (version 4.30.0-rc2, x86_64-unknown-linux-gnu, commit 3dc1a088b6d2d8eafe25a7cd7ec7b58d731bd7cc, Release)
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw result:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
git -C /home/leanagent/pv_spike/tools/aeneas status --short
Raw result: empty (the pinned Aeneas checkout was clean).
Command:
sha256sum upstream/traits.rs modeling-input/manifest.json \
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs \
/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
Raw result:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
The manifest's effective_tools entry selects the rustc and Lean paths above,
and its effective_tools.lean_paths begins with the displayed Aeneas checkout.
Frozen f64 specialization
-------------------------
Command:
nl -ba upstream/traits.rs | sed -n '264,295p'
Raw result:
264 impl Float for f64 {
265 type Int = u64;
266
267 const INFINITY: Self = Self::INFINITY;
268 const NEG_INFINITY: Self = Self::NEG_INFINITY;
269 const NAN: Self = Self::NAN;
270 const NEG_NAN: Self = -Self::NAN;
271
272 const BITS: u32 = 64;
273 const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
274 const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
275 const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
276
277 const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
278 const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
279 const SMALLEST_POWER_OF_TEN: i32 = -342;
280
281 fn to_bits(self) -> Self::Int {
282 self.to_bits()
283 }
284
285 fn classify(self) -> FpCategory {
286 self.classify()
287 }
288 }
289
290 impl FloatExt for f64 {
291 #[inline]
292 fn from_u64_bits(v: u64) -> Self {
293 f64::from_bits(v)
294 }
295 }
Thus the exact specialization boundary uses u64 in both directions: its
observation calls f64::to_bits, and its constructor calls f64::from_bits with
the complete u64, without a mask or numeric cast.
Pinned Rust exact-bit operations
--------------------------------
The source path was obtained with this command:
printf '%s/lib/rustlib/src/rust/library/core/src/num/f64.rs\n' \
"$(/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print sysroot)"
Raw result:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
Command (with F equal to that raw result):
nl -ba "$F" | sed -n '1201,1273p'
Raw result:
1201 /// Raw transmutation to `u64`.
1202 ///
1203 /// This is currently identical to `transmute::<f64, u64>(self)` on all platforms.
1204 ///
1205 /// See [`from_bits`](Self::from_bits) for some discussion of the
1206 /// portability of this operation (there are almost no issues).
1207 ///
1208 /// Note that this function is distinct from `as` casting, which attempts to
1209 /// preserve the *numeric* value, and not the bitwise value.
1210 ///
1211 /// # Examples
1212 ///
1213 /// ```
1214 /// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
1215 /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
1216 /// ```
1217 #[must_use = "this returns the result of the operation, \
1218 without modifying the original"]
1219 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1220 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1221 #[allow(unnecessary_transmutes)]
1222 #[inline]
1223 pub const fn to_bits(self) -> u64 {
1224 // SAFETY: `u64` is a plain old datatype so we can always transmute to it.
1225 unsafe { mem::transmute(self) }
1226 }
1227
1228 /// Raw transmutation from `u64`.
1229 ///
1230 /// This is currently identical to `transmute::<u64, f64>(v)` on all platforms.
1231 /// It turns out this is incredibly portable, for two reasons:
1232 ///
1233 /// * Floats and Ints have the same endianness on all supported platforms.
1234 /// * IEEE 754 very precisely specifies the bit layout of floats.
1235 ///
1236 /// However there is one caveat: prior to the 2008 version of IEEE 754, how
1237 /// to interpret the NaN signaling bit wasn't actually specified. Most platforms
1238 /// (notably x86 and ARM) picked the interpretation that was ultimately
1239 /// standardized in 2008, but some didn't (notably MIPS). As a result, all
1240 /// signaling NaNs on MIPS are quiet NaNs on x86, and vice-versa.
1241 ///
1242 /// Rather than trying to preserve signaling-ness cross-platform, this
1243 /// implementation favors preserving the exact bits. This means that
1244 /// any payloads encoded in NaNs will be preserved even if the result of
1245 /// this method is sent over the network from an x86 machine to a MIPS one.
1246 ///
1247 /// If the results of this method are only manipulated by the same
1248 /// architecture that produced them, then there is no portability concern.
1249 ///
1250 /// If the input isn't NaN, then there is no portability concern.
1251 ///
1252 /// If you don't care about signaling-ness (very likely), then there is no
1253 /// portability concern.
1254 ///
1255 /// Note that this function is distinct from `as` casting, which attempts to
1256 /// preserve the *numeric* value, and not the bitwise value.
1257 ///
1258 /// # Examples
1259 ///
1260 /// ```
1261 /// let v = f64::from_bits(0x4029000000000000);
1262 /// assert_eq!(v, 12.5);
1263 /// ```
1264 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1265 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1266 #[must_use]
1267 #[inline]
1268 #[allow(unnecessary_transmutes)]
1269 pub const fn from_bits(v: u64) -> Self {
1270 // It turns out the safety issues with sNaN were overblown! Hooray!
1271 // SAFETY: `u64` is a plain old datatype so we can always transmute from it.
1272 unsafe { mem::transmute(v) }
1273 }
These are opposite same-size transmutations, and the source explicitly chooses
exact bit preservation for NaNs, including their payloads.
Pinned Aeneas 64-bit carrier
----------------------------
Command:
nl -ba /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean \
| sed -n '27,34p;45,53p;65,69p;650,656p;1089,1094p'
Raw result:
27 /-- Kinds of unsigned integers -/
28 inductive UScalarTy where
29 | Usize
30 | U8
31 | U16
32 | U32
33 | U64
34 | U128
45 @[implicit_reducible]
46 def UScalarTy.numBits (ty : UScalarTy) : Nat :=
47 match ty with
48 | Usize => System.Platform.numBits
49 | U8 => 8
50 | U16 => 16
51 | U32 => 32
52 | U64 => 64
53 | U128 => 128
65 /-- Unsigned integer -/
66 structure UScalar (ty : UScalarTy) where
67 /- The internal representation is a bit-vector -/
68 bv : BitVec ty.numBits
69 deriving Repr, BEq, DecidableEq
650 /-! The scalar types. -/
651 abbrev Usize := UScalar .Usize
652 abbrev U8 := UScalar .U8
653 abbrev U16 := UScalar .U16
654 abbrev U32 := UScalar .U32
655 abbrev U64 := UScalar .U64
656 abbrev U128 := UScalar .U128
1089 abbrev U8.bv (x : U8) : BitVec 8 := UScalar.bv x
1090 abbrev U16.bv (x : U16) : BitVec 16 := UScalar.bv x
1091 abbrev U32.bv (x : U32) : BitVec 32 := UScalar.bv x
1092 abbrev U64.bv (x : U64) : BitVec 64 := UScalar.bv x
1093 abbrev U128.bv (x : U128) : BitVec 128 := UScalar.bv x
1094 abbrev Usize.bv (x : Usize) : BitVec System.Platform.numBits := UScalar.bv x
Consequently Std.U64 is a one-field structure whose field ranges over every
BitVec 64. There is neither a validity predicate nor a quotient that could
remove, merge, or add raw words.
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/lean-utf8.txt
Lean UTF-8 representation evidence
==================================
Scope
-----
This record pins the configured Lean definitions used to characterize the
UTF-8 conjunct of DecimalGoalVocabularyDefault.sourceString. The Rust str
invariant and configured isize::MAX bound are pinned separately in
reference/model-evidence/source-valid-byte-slice.txt. The Aeneas ordered byte
carrier is pinned separately in reference/model-evidence/aeneas-slice-observations.txt.
Configured toolchain and source identities
------------------------------------------
All commands below were run from the repository root. The exact reproduction
commands are:
cat lean-toolchain
sha256sum lean-toolchain
lake env lean --version
lake env lean --print-prefix
P=$(lake env lean --print-prefix)
sha256sum "$P/bin/lean" \
"$P/src/lean/Init/Prelude.lean" \
"$P/src/lean/Init/Data/String/Defs.lean"
nl -ba "$P/src/lean/Init/Prelude.lean" | sed -n '3480,3526p'
nl -ba "$P/src/lean/Init/Data/String/Defs.lean" | sed -n '64,79p'
The configured toolchain file contains exactly:
leanprover/lean4:v4.30.0-rc2
The version and prefix results are:
Lean (version 4.30.0-rc2, x86_64-unknown-linux-gnu, commit 3dc1a088b6d2d8eafe25a7cd7ec7b58d731bd7cc, Release)
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
The reproduced SHA-256 identities are:
ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61 lean-toolchain
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf bin/lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b src/lean/Init/Prelude.lean
ff44638846752ae8d2b16707e12d4978a792a672a3f486cbff7433bd3d79ad69 src/lean/Init/Data/String/Defs.lean
Exact defining excerpts
-----------------------
Init/Prelude.lean defines the byte encoding and validity witness as:
noncomputable def List.utf8Encode (l : List Char) : ByteArray :=
l.flatMap String.utf8EncodeChar |>.toByteArray
inductive ByteArray.IsValidUTF8 (b : ByteArray) : Prop
| intro (m : List Char) (hm : Eq b (List.utf8Encode m))
It then defines String as precisely a byte array carrying such a witness:
structure String where ofByteArray ::
toByteArray : ByteArray
isValidUTF8 : ByteArray.IsValidUTF8 toByteArray
Init/Data/String/Defs.lean defines conversion from a valid byte array and the
toUTF8 observation by:
def String.fromUTF8 (a : @& ByteArray) (h : a.IsValidUTF8) : String :=
.ofByteArray a h
def String.toUTF8 (a : @& String) : ByteArray :=
a.toByteArray
theorem String.toUTF8_eq_toByteArray {s : String} :
s.toUTF8 = s.toByteArray := (rfl)
Two-direction consequence used by the model
-------------------------------------------
Let b be any finite byte array. If b is the toUTF8 byte array of a Lean
String t, then toUTF8 is definitionally t.toByteArray, and the String field
t.isValidUTF8 supplies ByteArray.IsValidUTF8 b. Unfolding that inductive proof
exhibits characters m with b = List.utf8Encode m.
Conversely, if b is valid UTF-8, unfolding ByteArray.IsValidUTF8 supplies
characters m and an equality b = List.utf8Encode m. Equivalently, use the
validity proof directly in String.fromUTF8 b h; the resulting String has
toByteArray, hence toUTF8, definitionally equal to b. Therefore existence of
a Lean String with a given toUTF8 byte array is equivalent in both directions
to ByteArray.IsValidUTF8 of that array; this is a consequence of the displayed
definitions, not an assumed UTF-8 equivalence.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
reference/model-evidence/u64-bitand.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitAnd preservation evidence
================================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitAnd. The commands below were run from the repository
root on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790258751442882118.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790258751442882118.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790258751442882118.json
The exact U64 BitAnd entry in that index is:
name: U64.Insts.CoreOpsBitBitAndU64U64.bitand
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand
source: /rustc/library/core/src/ops/bit.rs, lines 178:12-178:42
raw_declaration_sha256: 36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitAnd<u64, u64> for u64}::bitand]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 178:12-178:42
Name pattern: [core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitAnd<u64, u64, u64>}::bitand"]
axiom U64.Insts.CoreOpsBitBitAndU64U64.bitand
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitAndU64U64.bitand") | .source_utf8' \
.trellis/scratch/inspect-native-1790258751442882118.json | sha256sum
Output:
36ceff7ad919e1d966b58518e19d49faa70b057d1eeab97b5d99db91bdce3e02 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line ranges are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '170,187p'
The pinned source says at lines 170-179:
macro_rules! bitand_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitAnd for $t {
type Output = $t;
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
and line 187 instantiates that implementation for u64:
bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 conjunction `self & rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
--------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 105-116 and theorem at line 274 are:
def UScalar.and {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv &&& y.bv ⟩
instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where
hAnd x y := UScalar.and x y
theorem UScalar.bv_and {ty} (x y : UScalar ty) :
(x &&& y).bv = x.bv &&& y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 148-153 prove, for every width and bit index:
theorem BitVec.getElem!_and {w} (x y : BitVec w) (i : Nat) :
(x &&& y)[i]! = (x[i]! && y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_and, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.and_self]
Therefore `x &&& y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean conjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-bitor.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 BitOr preservation evidence
===============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64BitOr. The commands below were run from the repository root
on 2026-09-24. They use the frozen generated.lean and the approved tools
recorded in modeling-input/manifest.json and modeling-input/tool-identities.json.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790259866184055823.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790259866184055823.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790259866184055823.json
The exact U64 BitOr entry in that index is:
name: U64.Insts.CoreOpsBitBitOrU64U64.bitor
extracted_signature: : Std.U64 → Std.U64 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor
source: /rustc/library/core/src/ops/bit.rs, lines 282:12-282:41
raw_declaration_sha256: 85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::BitOr<u64, u64> for u64}::bitor]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 282:12-282:41
Name pattern: [core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::BitOr<u64, u64, u64>}::bitor"]
axiom U64.Insts.CoreOpsBitBitOrU64U64.bitor
: Std.U64 → Std.U64 → Result Std.U64
The declaration hash is reproducible directly from the fresh JSON index:
jq -jr '.declarations[] | select(.name == "U64.Insts.CoreOpsBitBitOrU64U64.bitor") | .source_utf8' \
.trellis/scratch/inspect-native-1790259866184055823.json | sha256sum
Output:
85930775e3fde73729bff04aa86624f11a9b03b31d18a49dc74ce7bae71b4ed6 -
Thus the inspected external is exactly the u64/u64 operation, has the stated
total-looking Result signature, and is traced by extraction to the Rust source
span used below. This inventory fact identifies the boundary; the next two
sections establish its semantics.
2. Approved Rust implementation
-------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under the same sysroot. Its relevant file
and hash are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and quoted line range are reproduced with:
RUSTSRC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '274,291p'
The pinned source says at lines 274-289:
macro_rules! bitor_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const BitOr for $t {
type Output = $t;
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
forward_ref_binop! { impl BitOr, bitor for $t, $t,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
)*)
}
and line 291 instantiates that implementation for u64:
bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Consequently the extracted Rust symbol's u64 implementation returns the
primitive bounded u64 disjunction `self | rhs` for every pair of u64 values;
there is no source guard, failure branch, or reachability precondition.
3. Pinned Aeneas scalar meaning
-------------------------------
Repository identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (with each relative file path listed below substituted
for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
`git diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- <path>`
returned status 0 for each file recorded below, so the inspected worktree files
are the files at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Its definitions at lines 28-34, 45-53, 65-69, and 650-656 include:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
abbrev U64 := UScalar .U64
Thus Std.U64 is exactly a UScalar whose sole data field is a BitVec 64.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Its definitions at lines 118-126 and theorem at line 275 are:
def UScalar.or {ty} (x y : UScalar ty) : UScalar ty :=
⟨ x.bv ||| y.bv ⟩
instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where
hOr x y := UScalar.or x y
theorem UScalar.bv_or {ty} (x y : UScalar ty) :
(x ||| y).bv = x.bv ||| y.bv := by rfl
For an explicit bit-level characterization of the BitVec operation used there,
the same pinned repository contains:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Lines 141-146 prove, for every width and bit index:
theorem BitVec.getElem!_or {w} (x y : BitVec w) (i : Nat) :
(x ||| y)[i]! = (x[i]! || y[i]!) := by
by_cases i < w
. simp only [getElem!_eq_getElem, getElem_or, *]
. simp_all only [not_lt, getElem!_eq_false, Bool.or_self]
Therefore `x ||| y` on Std.U64 constructs the unique 64-bit vector whose bit
at every position is the Boolean disjunction of the corresponding operand
bits. It is total and introduces neither overflow nor a failure condition.
reference/model-evidence/u64-shl-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x << count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shl.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shl preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shl. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a bounded U64 shift, and all U32 counts at least
64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790260978718245524.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790260978718245524.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790260978718245524.json
The exact U64 Shl entry in that fresh index is:
name: U64.Insts.CoreOpsBitShlU32U64.shl
extracted_signature: : Std.U64 → Std.U32 → Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl
source: /rustc/library/core/src/ops/bit.rs, lines 489:12-489:41
raw_declaration_sha256: e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shl<u32, u64> for u64}::shl]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 489:12-489:41
Name pattern: [core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shl<u64, u32, u64>}::shl"]
axiom U64.Insts.CoreOpsBitShlU32U64.shl
: Std.U64 → Std.U32 → Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShlU32U64.shl") | .source_utf8' \
.trellis/scratch/inspect-native-1790260978718245524.json | sha256sum
Output:
e025ae44955b09fe95d7d8e997cb0ecafdfeea85b78bf40427e6f9bb14bb985d -
Thus this boundary is specifically u64 shifted by u32, and its extracted
codomain is the Aeneas Result used below to distinguish normal return from
checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '479,520p'
Lines 479-498 define the implementation macro:
macro_rules! shl_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shl<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shl(self, other: $f) -> $t {
self << other
}
}
forward_ref_binop! { impl Shl, shl for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 500-518 apply `shl_impl! { $t, u32 }` to every type in
`shl_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shl_impl_all {
($($t:ty)*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
shl_impl! { $t, u64 }
shl_impl! { $t, u128 }
shl_impl! { $t, usize }
...
)*)
}
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shl<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self << other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shl-probe.rs
with SHA-256:
a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8
It places the same primitive expression `x << count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shl-probe.rs -o u64-shl-probe
./u64-shl-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shl-probe.mir \
../../reference/model-evidence/u64-shl-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shl-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x0000000000000002
count=52 ok=0x0010000000000000
count=63 ok=0x8000000000000000
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift left by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shl(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shl` operation and returns its bounded 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with the
expected truncation to 64 bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 17-21 and 29-31 define:
def UScalar.shiftLeft {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.shiftLeft s ⟩
else fail .integerOverflow
def UScalar.shiftLeft_UScalar {ty tys} (x : UScalar ty) (s : UScalar tys) :
Result (UScalar ty) :=
x.shiftLeft s.val
Lines 81-82 resolve the notation used by Tablet/ModelU64Shl.lean:
instance {ty0 ty1} : HShiftLeft (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftLeft x y := UScalar.shiftLeft_UScalar x y
Consequently `x <<< y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the 64-bit vector shift; at least 64 it is
exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftLeft_spec`, lines 193-205, proves the successful
branch has both equivalent bounded descriptions:
theorem UScalar.ShiftLeft_spec ... (hy : y.val < ty0.numBits) ... :
(x <<< y) ⦃ z =>
z.val = (x.val <<< y.val) % size ∧
z.bv = x.bv <<< y.val ⦄
For U64, `size` is `2^64`; hence the returned natural value is the mathematical
left shift reduced modulo `2^64`, and the returned carrier is exactly the
corresponding 64-bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 248-266 give the bit-level characterization: every result bit below
the shift count (or outside the fixed width) is false, and every in-width bit at
or above the count equals the corresponding input bit at index `i - n`:
theorem BitVec.getElem!_shiftLeft_false ...
(h : i < n ∨ w ≤ i) : (v <<< n)[i]! = false
theorem BitVec.getElem!_shiftLeft_eq ...
(h : n ≤ i ∧ i < w) : (v <<< n)[i]! = v[i - n]!
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive U64 shift. The Aeneas branch condition also succeeds and returns
`ok` of `BitVec.shiftLeft n`. `UScalar.ShiftLeft_spec` and the BitVec lemmas
identify both results as the same 64-bit word, equivalently `(x * 2^n) mod
2^64`, with discarded high bits and zero-filled low bits.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shl preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
reference/model-evidence/u64-shr-probe.rs
use std::panic::{catch_unwind, AssertUnwindSafe};
#[inline(never)]
fn shift(x: u64, count: u32) -> u64 {
x >> count
}
fn observe(x: u64, count: u32) {
match catch_unwind(AssertUnwindSafe(|| shift(x, count))) {
Ok(value) => println!("count={count} ok={value:#018x}"),
Err(_) => println!("count={count} panic"),
}
}
fn main() {
std::panic::set_hook(Box::new(|_| {}));
let x = 0x8000_0000_0000_0001_u64;
for count in [0, 1, 52, 63, 64, 65, u32::MAX] {
observe(x, count);
}
}
reference/model-evidence/u64-shr.txt
Historical predecessor record (retained raw evidence)
----------------------------------------------------
The body below records the predecessor extraction and experiments. Its
45b5027c generated.lean hash, whole-source hashes and old inspection paths
are historical identities, not current provenance or checks run by task 11.
The four exact predecessor probe sources are restored in the reserved paths.
Current declarations, signatures, Rust symbols, declaration and binding
digests, complete relevant call inventories, compiler/library/configuration
identities, freshly run commands, exit statuses and raw reproduction results
are recorded separately in
reference/model-evidence/P89_T2_current-applicability.txt.
That supplement checks reuse against current 438af839 generated.lean; neither
this notice nor an earlier worker self-report is preservation certification.
U64 Shr preservation evidence
=============================
Scope
-----
This record pins the source-to-model chain for the external declaration bound
to Tablet/ModelU64Shr. The commands below were run from the repository root on
2026-09-24. They use the frozen generated.lean, extraction configuration, and
approved tools recorded in modeling-input/manifest.json and
modeling-input/tool-identities.json. The two semantic cases are both in scope:
all U32 counts below 64 return a logical U64 right shift, and all U32 counts at
least 64 encounter the enabled checked-shift failure.
1. Fresh native-boundary inspection
-----------------------------------
Command:
python3 .trellis/scripts/pv_modeling.py inspect-native .
The command reported 24 declarations and wrote its full index to:
.trellis/scratch/inspect-native-1790262316075577976.json
SHA-256 identities:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9 generated.lean
1e4419e9c0fff857cbff6848d8e4d0b54267d4f2f3307ee139f058f88930ee77 .trellis/scratch/inspect-native-1790262316075577976.json
These identities are reproduced with:
sha256sum generated.lean \
.trellis/scratch/inspect-native-1790262316075577976.json
The exact U64 Shr entry in that fresh index is:
name: U64.Insts.CoreOpsBitShrU32U64.shr
extracted_signature: : Std.U64 -> Std.U32 -> Result Std.U64
rust_symbol: core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr
source: /rustc/library/core/src/ops/bit.rs, lines 612:12-612:41
raw_declaration_sha256: 77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f
The indexed raw declaration is:
/-- [core::ops::bit::{impl core::ops::bit::Shr<u32, u64> for u64}::shr]:
Source: '/rustc/library/core/src/ops/bit.rs', lines 612:12-612:41
Name pattern: [core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr]
Visibility: public -/
@[rust_fun "core::ops::bit::{core::ops::bit::Shr<u64, u32, u64>}::shr"]
axiom U64.Insts.CoreOpsBitShrU32U64.shr
: Std.U64 -> Std.U32 -> Result Std.U64
The declaration hash is reproduced directly from the fresh JSON index by:
jq -jr '.declarations[] | select(.name ==
"U64.Insts.CoreOpsBitShrU32U64.shr") | .source_utf8' \
.trellis/scratch/inspect-native-1790262316075577976.json | sha256sum
Output:
77bb0909a8e98b3624eb10ad550c04968db2c68776dcd3da10fb338b029a7c1f -
Tablet/model-support.json binds precisely this indexed declaration and
signature to dec2flt_model.ModelU64Shr. Thus the boundary is specifically u64
shifted by u32, and its extracted codomain is the Aeneas Result used below to
distinguish normal return from checked overflow.
2. Approved Rust implementation and build mode
-----------------------------------------------
Toolchain and compiler identity:
toolchain: nightly-2026-06-01-x86_64-unknown-linux-gnu
rustc path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
rustc SHA-256: 162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
rustc 1.98.0-nightly (14210df0e 2026-05-31)
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
host: x86_64-unknown-linux-gnu
Reproduction commands:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
"$RUSTC" -vV
"$RUSTC" --print sysroot
sha256sum "$RUSTC"
The installed rust-src component is under that same sysroot. Its relevant
file and identity are:
path: /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs
SHA-256: 31db8c3d227e01a9f60f37221d258dc1b2c8274163264602837bb3f3851c2a4d
The file identity and source are reproduced with:
RUSTSRC="$($RUSTC --print sysroot)/lib/rustlib/src/rust/library/core/src/ops/bit.rs"
sha256sum "$RUSTSRC"
nl -ba "$RUSTSRC" | sed -n '602,641p'
Lines 602-620 define the implementation macro:
macro_rules! shr_impl {
($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Shr<$f> for $t {
type Output = $t;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn shr(self, other: $f) -> $t {
self >> other
}
}
forward_ref_binop! { impl Shr, shr for $t, $f,
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
};
}
Lines 623-641 apply `shr_impl! { $t, u32 }` to every type in
`shr_impl_all!`, and instantiate that outer macro with `u64` among its types:
macro_rules! shr_impl_all {
($($t:ty)*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
shr_impl! { $t, u64 }
shr_impl! { $t, u128 }
shr_impl! { $t, usize }
...
)*)
}
shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
Therefore the inspected symbol has exactly this method body for `Shr<u32> for
u64`, and `#[rustc_inherit_overflow_checks]` makes its primitive `self >> other`
use the calling crate's overflow-check mode.
The frozen configuration identities are:
2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8 crate/Cargo.toml
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
68fc7ab89dac4e5389a286b36d919fde5481b2c5673fc7006c7f693afd6ceedf modeling-input/tool-identities.json
They are reproduced by `sha256sum` on those four paths. Cargo.toml lines
18-22 set `overflow-checks = true` in both the development and release
profiles. modeling-input/SETUP.md lines 17-22 record that extraction uses the
development profile with overflow checks enabled. The frozen
modeling-input/extraction.json is:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
so no extraction argument disables that setting. The manifest pins
`RUSTUP_TOOLCHAIN=nightly-2026-06-01` and the exact cargo/rustc toolchain. There
is no `panic` override in Cargo.toml; the approved rustc's default target cfg,
reproduced by `"$RUSTC" --print cfg`, includes:
panic="unwind"
target_arch="x86_64"
target_pointer_width="64"
Thus the frozen build uses checked shifts and unwinding panics.
3. Same-toolchain checked-shift probe and MIR
---------------------------------------------
The durable probe source is:
reference/model-evidence/u64-shr-probe.rs
with SHA-256:
11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee
It places the same primitive expression `x >> count` in a non-inlined function,
runs it on representative boundary counts while catching unwinding panics, and
does not mask or reduce the count. Reproduce it from the repository root with:
RUSTC=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
cd .trellis/scratch
"$RUSTC" -C overflow-checks=yes -C panic=unwind \
../../reference/model-evidence/u64-shr-probe.rs -o u64-shr-probe
./u64-shr-probe
"$RUSTC" -C overflow-checks=yes -C panic=unwind --emit=mir=u64-shr-probe.mir \
../../reference/model-evidence/u64-shr-probe.rs
sed -n '/fn shift(/,/^}/p' u64-shr-probe.mir
Runtime output:
count=0 ok=0x8000000000000001
count=1 ok=0x4000000000000000
count=52 ok=0x0000000000000800
count=63 ok=0x0000000000000001
count=64 panic
count=65 panic
count=4294967295 panic
The same invocation emits this MIR for the complete dynamic-count function:
fn shift(_1: u64, _2: u32) -> u64 {
debug x => _1;
debug count => _2;
let mut _0: u64;
let mut _3: bool;
bb0: {
_3 = Lt(copy _2, const 64_u32);
assert(move _3, "attempt to shift right by `{}`, which would overflow", copy _2) -> [success: bb1, unwind continue];
}
bb1: {
_0 = Shr(copy _1, copy _2);
return;
}
}
The MIR is general in both arguments: exactly when `count < 64`, control reaches
the U64 `Shr` operation and returns its logical 64-bit result; otherwise the
assertion takes its unwind edge. The runtime boundary observations confirm
that the configured panic strategy makes that failure catchable at 64, 65, and
the largest U32 count, while counts 0, 1, 52, and 63 return normally with
zero-filled high bits.
4. Pinned Aeneas carrier and shift meaning
------------------------------------------
Repository and translator identity:
repository: https://github.com/AeneasVerif/aeneas.git
revision: fa699427cdfa8f604b891fb0223ef42883dd7dc4
aeneas binary SHA-256: 9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922
Reproduction commands (substitute each relative path below for PATH):
AENEAS=/home/leanagent/pv_spike/tools/aeneas
git -C "$AENEAS" rev-parse HEAD
git -C "$AENEAS" remote -v
sha256sum "$AENEAS/bin/aeneas"
git -C "$AENEAS" diff --quiet fa699427cdfa8f604b891fb0223ef42883dd7dc4 -- PATH
sha256sum "$AENEAS/PATH"
git -C "$AENEAS" ls-tree fa699427cdfa8f604b891fb0223ef42883dd7dc4 PATH
The `git diff --quiet` command returned status 0 for every file below, so each
inspected worktree file is the file at the pinned revision.
File:
backends/lean/Aeneas/Std/Scalar/Core.lean
SHA-256: a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e
git blob: f8582928fe49a0ce75e143b46bb0a8826d7fddae
Lines 28-34, 45-53, 65-71, 90-95, and 650-656 define:
inductive UScalarTy where
| Usize
| U8
| U16
| U32
| U64
| U128
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
irreducible_def UScalar.size (ty : UScalarTy) : Nat := 2^ty.numBits
abbrev U32 := UScalar .U32
abbrev U64 := UScalar .U64
Thus Std.U64 contains exactly a 64-bit vector, Std.U32 contains exactly a
32-bit vector, and the count's `val` ranges over the full U32 domain.
File:
backends/lean/Aeneas/Std/Scalar/Bitwise.lean
SHA-256: 63e4b1d0906c972fb4fef953d8d8a60410dcf5313261d2583b1170b4a1a5ce29
git blob: d3eb5022efc22d1d6c3ac055965f612c7f2fbca9
Lines 23-35 define:
def UScalar.shiftRight {ty : UScalarTy} (x : UScalar ty) (s : Nat) :
Result (UScalar ty) :=
if s < ty.numBits then
ok ⟨ x.bv.ushiftRight s ⟩
else fail .integerOverflow
def UScalar.shiftRight_UScalar {ty tys} (x : UScalar ty)
(s : UScalar tys) : Result (UScalar ty) :=
x.shiftRight s.val
Lines 93-94 resolve the notation used by Tablet/ModelU64Shr.lean:
instance {ty0 ty1} : HShiftRight (UScalar ty0) (UScalar ty1)
(Result (UScalar ty0)) where
hShiftRight x y := UScalar.shiftRight_UScalar x y
Consequently `x >>> y` for `x : Std.U64` and `y : Std.U32` tests exactly
`y.val < 64`: below 64 it is `ok` of the unsigned 64-bit vector shift; at least
64 it is exactly `fail .integerOverflow`.
The same file's `UScalar.ShiftRight_spec`, lines 166-174, proves the successful
branch has both equivalent logical-shift descriptions:
theorem UScalar.ShiftRight_spec ... (hy : y.val < ty0.numBits) :
(x >>> y) ⦃ z =>
z.val = x.val >>> y.val ∧
z.bv = x.bv >>> y.val ⦄
Here natural-number `>>>` is division by `2^y.val`, so the returned numeric
value is `floor(x.val / 2^y.val)`, and the returned carrier is exactly the
unsigned shift of the fixed-width bit vector.
File:
backends/lean/Aeneas/Data/BitVec.lean
SHA-256: 66d6e1922a45beff2d75e71e10dc6e8294c7cbf69f95b22dc22f98c5667382a7
git blob: f7bc57109569cdd0fb0c3323021c73673dcfcd33
Its lines 268-283 give the bit-level logical zero-fill characterization. For
every result position, the total bit lookup is the input bit at the offset
position; positions whose offset is outside the 64-bit input are false:
theorem BitVec.getElem!_shiftRight {w} (v : BitVec w) (n i : Nat) :
(v >>> n)[i]! = v[n + i]!
theorem BitVec.getElem_shiftRight_false {m n : Nat} (v : BitVec m)
(hm : i < m) (h : m <= n + i) :
(v >>> n)[i]'hm = false
Together with `BitVec.getElem_shiftRight_lt`, this states that every in-range
source bit moves downward by the count and every newly exposed high bit is
zero. Because the carrier is unsigned, there is no sign extension.
Finally, the model's failure constructor is pinned in:
backends/lean/Aeneas/Std/Primitives.lean
SHA-256: f3e9dc9ee62646d579b97747725c07f18760498601b5a37e48031d2f4893035a
git blob: e5733a774268c8dee71bd4ba402240d151bb8cb8
Lines 50-64 include the distinct `Error.integerOverflow` constructor and
`Result.fail`. Therefore the at-least-64 branch is the explicit Aeneas checked
integer-overflow failure, not a wrapping or masked shift.
5. Case-by-case preservation conclusion
----------------------------------------
Let x be any source/model U64 word and n any source/model U32 count; the carrier
definitions above identify their bits and numeric values exactly.
If n < 64, the Rust checked-shift assertion succeeds and the source method runs
the primitive unsigned U64 right shift. The Aeneas branch condition also
succeeds and returns `ok` of `BitVec.ushiftRight n`. `UScalar.ShiftRight_spec`
and the BitVec lemmas identify both results as the same 64-bit word,
equivalently `floor(x / 2^n)`, with every newly exposed high bit filled by zero.
If n >= 64, the configured Rust operation takes the checked-overflow panic
edge. The Aeneas branch condition fails and returns `fail .integerOverflow`,
the extracted Result representation of that checked shift failure. This holds
for the entire remaining U32 range, including counts larger than 64; it is not
restricted to counts reached by current parser executions.
Thus Tablet/ModelU64Shr preserves both the normal result and checked-failure
observations of the exact extracted Rust operation on its full U64 x U32 input
domain.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:93494d9972bc3b17c2d46e5426c6d6abe6aa3b3b83408e455138ce34aa31fcd1 |
| Preservation current fingerprint | preservation-v1:93494d9972bc3b17c2d46e5426c6d6abe6aa3b3b83408e455138ce34aa31fcd1 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"b1acfb8165af94d85410cf245ba8dbf65d464f291a1039e04c18d2f5ea85084d","lean_semantic_closure":"5349be58b873e6d08852eee2f11df105ddeed2f30137980765295434e1a849e8","lean_relevant_definition_descendants":{"DecimalGoalVocabulary":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["DecimalGoalVocabulary","DecimalLexeme","F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"b1acfb8165af94d85410cf245ba8dbf65d464f291a1039e04c18d2f5ea85084d","lean_semantic_closure":"5349be58b873e6d08852eee2f11df105ddeed2f30137980765295434e1a849e8","lean_relevant_definition_descendants":{"DecimalGoalVocabulary":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["DecimalGoalVocabulary","DecimalLexeme","F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "701c48e62f1b8089a201ab17a18289a683b51c38c37983214884a111ff8d8d19",
"dep_statement_hashes": {
"DecimalGoalVocabulary": "a7ea90f3fe39b9537113f20fb793064a8bd6b3cada2fec542f2a0a72d168d0ae",
"DecimalLexeme": "0d398ff0a3cfd467bc80f4937b3cebbf4fb3734b961ce22a0cf856a5753a92f1",
"F64": "85219d015e60d047232e878573a12a94c958bf92ebff46024b4602e427a15588",
"NumberHelperScientificClassificationSourceLength": "e9ea8000031bcfb91142b2a8c27762a7d30693be1cb3e514ba9fffc5a89b32a2",
"P9_T1_ExponentFoldBounds": "c168c2102b89ade20de387c88cb0b4e77313bfa05315086ea326d47f37b9f1ff",
"P9_T1_ScientificVocabularyFold": "773773ea63bf02ab021bdb428709c8f9ce764530e2e4b2accf0d38ed76bdab2d",
"SourceValidByteSlice": "52522ae5b8602c6279dde2af31f94e21db249400641f5d3e951f68a74c3c11e2"
},
"combined_sound_fp": "preservation-v1:93494d9972bc3b17c2d46e5426c6d6abe6aa3b3b83408e455138ce34aa31fcd1"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"sha256": "c525bf0a597763fba686f2fce551b436a16d406f2e10942a23665eadc676988b",
"cited_by": [
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/P89_T2_current-applicability.txt",
"sha256": "aefdc935645f37c69a2c3f2e7c2fb00baad81970455148f3dbb591b0eeabced3",
"cited_by": [
"reference/model-evidence/u64-bitor.txt",
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt",
"reference/model-evidence/u64-bitand.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/aeneas-slice-observations.txt",
"sha256": "566b151c7c5eee54bbc634b117f85b80c8adf7a0ba4362759a076caca6c61c38",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/lean-utf8.txt",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/aeneas-string-bytes.txt",
"sha256": "132e19fa71c736d030b3e5cb788cf2bb1e99c60742ac19ad6860855f7ced21b6",
"cited_by": [
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation-probe.rs",
"sha256": "268c01d8621efcf8e3771004f3b6f1f4c390f8fb133eb188540f67c7848342e5",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/binary64-negation.txt"
]
},
{
"path": "reference/model-evidence/binary64-negation.txt",
"sha256": "e19a2cd2283c8435f6d6107d06ccc798cbba4d63f0220b32b5216e43ad071aac",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/float-carriers.txt",
"sha256": "4367b150c75a979015e2a6063d4080d3f0a1681c640421692ff9ac8c139632e5",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/lean-utf8.txt",
"sha256": "e56898d7a38eb24d65160e9ca1e70c72b92d95d5ff22bc8cf16abd68b5cb66ed",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/aeneas-slice-observations.txt",
"reference/model-evidence/lean-utf8.txt",
"reference/model-evidence/P89_T1_PrimitiveApplicability.txt",
"reference/model-evidence/aeneas-string-bytes.txt"
]
},
{
"path": "reference/model-evidence/u64-bitand.txt",
"sha256": "6a48b1a79f8a52a27fb06a0b25cda9de24f68395d66ab668ecac721806883f54",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-bitor.txt",
"sha256": "f3dadaec6c4ebc98d0d3178bf29df7436e52998b6b97e8d108ca97a6f8092e70",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl-probe.rs",
"sha256": "a0f0f822b3ea216799bb900835341f6117d47b59b9d6ad3d9cbc3af07e2792a8",
"cited_by": [
"reference/model-evidence/u64-shl.txt",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shl.txt",
"sha256": "e4cacfd29333a91c1258524a520e849325a85a05cf50b0065ffbf91d7977f69c",
"cited_by": [
"Tablet/DecimalGoalVocabularyDefault.tex",
"committed_node_kinds / pv_tablet.json",
"reference/model-evidence/P89_T2_current-applicability.txt"
]
},
{
"path": "reference/model-evidence/u64-shr-probe.rs",
"sha256": "11f10c4d4eb07e9aaa518e6e08a52796814b6f29d09e2ada5138e61f70551fee",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt",
"reference/model-evidence/u64-shr.txt"
]
},
{
"path": "reference/model-evidence/u64-shr.txt",
"sha256": "c0295af2452a4748bc1a642580414acfc76285ba87b6203b6cbff7ff9924b6ad",
"cited_by": [
"reference/model-evidence/P89_T2_current-applicability.txt"
]
}
]DecimalLexeme
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalLexeme]
structure DecimalLexeme where
-- BODY
leadingSign : Option Bool
integerDigits : List Nat
fractionDigits : Option (List Nat)
exponent : Option (Bool × Option Bool × List Nat)
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
none,
some false, or some true. Each ASCII digit byte is encoded
uniquely by its value in 0,\ldots,9. Absence of a decimal point is encoded by
fractionDigits = none; a present point is encoded by
fractionDigits = some ds, including when the following digit list
ds is empty. Absence of an exponent is encoded by exponent = none.
A present exponent is encoded by a triple that records lowercase
e as false and uppercase E as true, records its absent, plus,
or minus sign as none, some false, or some true,
and contains its entire digit list. Projecting such an encoding recovers every
one of these components, and two decimal-lexeme records are equal exactly when
their four fields are componentwise equal.Proof
e/E exponent with
its optional sign and digit list
(reference/model-evidence/goal-vocabulary.txt). The three sign
cases go to distinct constructors or Boolean values. ASCII digit bytes are
exactly 48,\ldots,57, so subtracting 48 maps them bijectively and in order to
0,\ldots,9; adding 48 is the inverse on this domain. Mapping a list applies
these mutually inverse operations at every position and therefore loses no
digit or order.some retains all following digits and may be empty.
For the exponent, the outer option separates absence from presence; in the
present triple the first Boolean separates the two marker cases, the inner
option and Boolean separate all three sign cases, and the list retains every
exponent digit. Reading the four record fields and applying the inverse sign,
marker, and digit tables therefore recovers the original decomposition.
Finally, equality of structure values is equivalent to equality of each named
field, and equality of the option, product, Boolean, and list components is
componentwise; hence record equality has exactly the stated characterization.Decimal records, or source execution
behavior.Authored arguments for individual requirements
Requirement: parser totality
Requirement: parser numeric acceptance
Requirement: parser invalid rejection
Err.Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Decimal arguments have already discarded lexical distinctions; this carrier asserts no component compliance, call-site precondition, or result.Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
leadingSign = none; its exponent sign is still retained independently. Unsigned validity, rendering, byte-domain coverage, acceptance, and Some remain outside this carrier.Requirement: number helper rejection
None claim.Requirement: number helper record bounds
Decimal record, mantissa, many_digits, returned option, or execution observation, so record bounds and negativity are noninterfering.Requirement: number helper accumulated value
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Requirement: native correct or defer
Decimal records, whereas this carrier supplies no source record or conversion value. It is noninterfering and provides no lexeme witness, deferral, many_digits, rounding, or return claim.Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
BiasedFp, bit operation, assembled word, float, or source-call field and is noninterfering with unrestricted assembly.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
DecimalLexeme · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:64f4a6581b972ee3eba8776b30abafd874405413ef54aa8a296838b3a8404e53 |
| Preservation current fingerprint | preservation-v1:64f4a6581b972ee3eba8776b30abafd874405413ef54aa8a296838b3a8404e53 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","lean_semantic_closure":"88a55d30e14969c279ce18cf88b25a016c40d52cad5a1a166d71f5f189370a56","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","lean_semantic_closure":"88a55d30e14969c279ce18cf88b25a016c40d52cad5a1a166d71f5f189370a56","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "0ebd56ff9e6c688c714c81a22b063ad7cba6c267103bb2162a40457806980c44",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:64f4a6581b972ee3eba8776b30abafd874405413ef54aa8a296838b3a8404e53"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"Tablet/DecimalLexeme.tex",
"committed_node_kinds / pv_tablet.json"
]
}
]DispatchContracts
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_AbstractComponents
import Tablet.DecimalGoalVocabularyDefault
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContracts]
structure DispatchContracts (C : P9_T1_AbstractComponents) : Prop where
-- BODY
number_accept : forall (body : Slice Std.U8) (x : DecimalLexeme),
SourceValidByteSlice body -> body.val ≠ [] ->
body.val.length <= 3458764513820540928 ->
x.leadingSign = none -> DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body ->
exists d, C.parseNumber body = some d
number_reject : forall body : Slice Std.U8,
SourceValidByteSlice body -> body.val ≠ [] ->
body.val.length <= 3458764513820540928 ->
(¬ exists x : DecimalLexeme, x.leadingSign = none /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body) ->
C.parseNumber body = none
record_bounds : forall (body : Slice Std.U8) d,
SourceValidByteSlice body -> body.val ≠ [] ->
C.parseNumber body = some d -> d.negative = false /\ d.mantissa.val < 10 ^ 19
record_accumulated : forall (body : Slice Std.U8) (x : DecimalLexeme) d,
SourceValidByteSlice body -> body.val.length <= 3458764513820540928 ->
x.leadingSign = none -> DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body ->
C.parseNumber body = some d ->
if d.many_digits then
DecimalGoalVocabularyDefault.decimalMagnitude d <= DecimalGoalVocabularyDefault.accumulatedMagnitude x /\
DecimalGoalVocabularyDefault.accumulatedMagnitude x <
(((d.mantissa.val + 1 : Nat) : Real) * (10 : Real) ^ d.exponent.val)
else DecimalGoalVocabularyDefault.decimalMagnitude d = DecimalGoalVocabularyDefault.accumulatedMagnitude x
exact_transport : forall (body : Slice Std.U8) (x : DecimalLexeme),
SourceValidByteSlice body -> body.val.length <= 576460752303421440 ->
x.leadingSign = none -> DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body ->
forall target : F64,
DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.accumulatedMagnitude x) target ↔
DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.exactMagnitude x) target
special_infinity : forall (body : Slice Std.U8) negative,
SourceValidByteSlice body ->
DecimalGoalVocabularyDefault.specialLiteral (DecimalGoalVocabularyDefault.bytes body) none false ->
exists f, C.parseSpecial body negative = some f /\ DecimalGoalVocabularyDefault.isInfinity negative f
special_nan : forall (body : Slice Std.U8) negative,
SourceValidByteSlice body ->
DecimalGoalVocabularyDefault.specialLiteral (DecimalGoalVocabularyDefault.bytes body) none true ->
exists f, C.parseSpecial body negative = some f /\ DecimalGoalVocabularyDefault.isNan f
special_reject : forall (body : Slice Std.U8) negative,
SourceValidByteSlice body ->
(¬ exists nan, DecimalGoalVocabularyDefault.specialLiteral (DecimalGoalVocabularyDefault.bytes body) none nan) ->
C.parseSpecial body negative = none
native_normal : forall d f, C.native d = some f ->
d.many_digits = false /\ exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.decimalMagnitude d) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude d.negative magnitude f
integer_normal : forall (q : Std.I64) (w : Std.U64),
let fp := C.integer q w
fp.p_biased.val < 0 ∨
(DecimalGoalVocabularyDefault.roundsMagnitude
((w.val : Real) * (10 : Real) ^ q.val) (C.assemble fp) /\
(C.assemble fp).val < 2 ^ 63)
slow_normal : forall (body : Slice Std.U8) (x : DecimalLexeme),
SourceValidByteSlice body -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body ->
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x) (C.assemble (C.slow body)) /\
(C.assemble (C.slow body)).val < 2 ^ 63
assembly_all : forall fp, DecimalGoalVocabularyDefault.assembledWord fp (C.assemble fp)
negate_all : forall f : F64,
(C.negate f).val = if f.val < 2 ^ 63 then f.val + 2 ^ 63 else f.val - 2 ^ 63
end dec2flt_model
Why this model is faithful
Definition
DispatchContracts\,(C). Operations are data; these laws are a
separate proposition. Put A=3458764513820540928 and
B=576460752303421440 bytes. Every slice domain below is source-valid
as in SourceValidByteSlice, without a UTF-8 premise.
Grammar, byte rendering, all-digit magnitudes, rounding, signs and raw-word
assembly are exactly DecimalGoalVocabularyDefault.Preservation argument
Claim
Proof
special_all refinement condition. Native's None/Some alternatives,
record sign and many_digits restriction describe normal actual values on
every Decimal, including the disguised path. Integer correctness keeps
every I64/U64 input and its on-normal negative-biased-exponent deferral
alternative, otherwise requiring the clear-sign exact scalar target.
There is no universal upper bound on raw pair exponents.
Slow correctness keeps every source-valid unsigned numeric slice, with
no A/B bound, full significand and bounded accumulated explicit exponent;
it is on normal actual return, not unrestricted liveness.assembly_all refinement equation, not a premise of the direct
assembly goal. The negation value law toggles bit 63 on every word;
negate_all separately requires the actual normal equation.
Defining these conditions proves none of them for actual components.Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
record_bounds names the conditional value law; it requires
no proof of acceptance and has no A limit.Requirement: special helper infinity
special_infinity value law and the separately required
special_all normal equation retain both parts of the actual goal;
neither is established merely by defining them.Requirement: special helper nan
special_nan value law and the separately required
special_all normal equation retain the normal Some conclusion,
rather than weakening it to a law of successful outputs.Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.
The special_reject value law and the separately required
special_all normal equation retain normal None, not a conditional
law about whatever result happened to return.Requirement: native correct or defer
native_normal value law does not make the actual normal
hypothesis true; it constrains a value only when that return is given.Requirement: integer correct or defer
integer_normal value law imposes neither unrestricted
concrete termination nor a well-formedness bound on every raw pair.Requirement: slow accumulated rounding
slow_normal value law uses this full source-valid domain;
the B exact-transport clause does not narrow or change it.Requirement: assembly correspondence
assembly_all word law and the separate refinement equation
retain the required actual normal return; a total abstract assembly
function alone is not its proof.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
number_accept value law together with the required bounded
normal equation represents this actual conclusion, not a hypothesis
that parsing has already succeeded.Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.
The number_reject value law together with the required bounded
normal equation represents normal None, not outer failure or an assumed
return.Requirement: parser exact rounding
exact_transport condition is B-bounded; it neither asserts
exact rounding on all longer inputs nor proves actual transport.Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
record_accumulated and unrestricted slow value laws retain
this diagnostic value rather than the ordinary exact value.Requirement: parser equal target rounding
Requirement: number helper accumulated value
record_accumulated field retains exactly this returned-record
qualification and these two representation alternatives.Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
DispatchContracts · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (7)
- Conditional abstract composition
- Conditional component compliance
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional numeric acceptance
All 7 entries
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:effa21c2e8b07f381656a35702d30524a2fa1ba8c32e0f79dddc103dd13f1d5c |
| Preservation current fingerprint | preservation-v1:effa21c2e8b07f381656a35702d30524a2fa1ba8c32e0f79dddc103dd13f1d5c |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"9b556328440e14cf66813eee0b4d75ea1d4219b50877c74437f4dcc64f309ab3","lean_semantic_closure":"0983ac7e3ce5be57453e9d3ff18769ce63592f34d4fe09b210b10211d47fc94a","lean_relevant_definition_descendants":{"DecimalGoalVocabulary":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","DecimalGoalVocabularyDefault":"b1acfb8165af94d85410cf245ba8dbf65d464f291a1039e04c18d2f5ea85084d","DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","P9_T1_AbstractComponents":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","SourceValidByteSlice":"d736148659be38528d8040160c92286f94c9e3a163bf026d5bef1af084b422bd"},"lean_relevant_dependencies":["DecimalGoalVocabulary","DecimalGoalVocabularyDefault","DecimalLexeme","F64","P9_T1_AbstractComponents","SourceValidByteSlice","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"9b556328440e14cf66813eee0b4d75ea1d4219b50877c74437f4dcc64f309ab3","lean_semantic_closure":"0983ac7e3ce5be57453e9d3ff18769ce63592f34d4fe09b210b10211d47fc94a","lean_relevant_definition_descendants":{"DecimalGoalVocabulary":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","DecimalGoalVocabularyDefault":"b1acfb8165af94d85410cf245ba8dbf65d464f291a1039e04c18d2f5ea85084d","DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","P9_T1_AbstractComponents":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","SourceValidByteSlice":"d736148659be38528d8040160c92286f94c9e3a163bf026d5bef1af084b422bd"},"lean_relevant_dependencies":["DecimalGoalVocabulary","DecimalGoalVocabularyDefault","DecimalLexeme","F64","P9_T1_AbstractComponents","SourceValidByteSlice","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "2158a3969fe9995215996666b54249b4222bb3e186c7d66aaac9cf3e2a4e06c9",
"dep_statement_hashes": {
"DecimalGoalVocabularyDefault": "32a84a43f71314245b7cbbbce3aefa2bde7d8120fb1fddb93ff7b90796f8a87b",
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af",
"P9_T1_NormalComponentRefinement": "61854b616ff5f2274356aef080c0e3ddd5c82dfdafe53715b78d3366280ea20e",
"SourceValidByteSlice": "52522ae5b8602c6279dde2af31f94e21db249400641f5d3e951f68a74c3c11e2"
},
"combined_sound_fp": "preservation-v1:effa21c2e8b07f381656a35702d30524a2fa1ba8c32e0f79dddc103dd13f1d5c"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/DispatchContracts.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]F64
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: F64]
abbrev F64 : Type :=
-- BODY
Std.U64
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
f64 by its complete to_bits word loses
no source encoding or public bit-level observation: on the full 64-bit domain,
including every NaN encoding, from_bits interprets every carrier word
and is inverse to to_bits at the level of raw encodings.Proof
f64 specialization sets Int = u64; its
to_bits method calls f64::to_bits, and its
from_u64_bits method passes the complete u64 to
f64::from_bits. Rust implements those two operations as the opposite
same-size transmutations and explicitly specifies exact-bit preservation,
including NaN payloads. The exact excerpts, hashes, tool identities, and
reproduction commands are recorded in
reference/model-evidence/float-carriers.txt.f64 with raw memory
word w. Transmutation by to_bits returns that same w, and
transmutation of w by from_bits creates an f64 with the
same raw memory word. Thus
from_bits(to_bits(x)) has exactly the encoding of x; this is a
bitwise statement and does not incorrectly use Rust floating-point equality on
NaNs. For the other direction, take any of the 2^{64} words w.
from_bits(w) creates the float encoding w, so applying
to_bits returns exactly w. This includes all words with an
all-ones exponent and nonzero fraction, regardless of sign, quiet/signaling
bit, or payload.Std.U64 a structure with one
BitVec 64 field, and every such bit vector is admitted. Therefore the
model carrier contains exactly the words in the two inverse arguments. The
carrier correspondence retains every raw encoding; meanings of classification
and operations on those words are supplied by their separate bindings.Authored arguments for individual requirements
Requirement: parser totality
f64 intermediate and result in a parser execution has exactly one carrier word, and every carrier word represents a source f64 encoding. Thus this representation adds neither a restriction on those values nor a representation failure. Panic versus normal return, Ok versus Err, floating-point operation behavior, and control choices are established by the separate operation-binding and dispatcher preservation owners, not by this bijection.Requirement: parser numeric acceptance
f64 intermediate and result in a numeric parse has exactly one carrier word, and every carrier word represents a source f64 encoding, so the representation adds no restriction or failure. Normal return, production of Ok, operation behavior, and branch choices remain obligations of the separate operation-binding and dispatcher preservation owners.Requirement: parser invalid rejection
f64 intermediate produced before rejection has exactly one carrier word, every carrier word is source-representable, and an Err payload itself contains no float. Hence the carrier creates no representation restriction or failure; whether the parser returns normally with Err, and the operations and control choices leading there, are left to their separate preservation owners.Requirement: parser nan acceptance
Ok, and the operations constructing the result are left to their separate preservation owners.Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
f64 intermediate or result has exactly one retained word, and every carrier word, including every binary64 rounding target of DecimalGoalVocabularyDefault, is representable by a source f64. Thus comparison with the exact target introduces no carrier restriction or representation failure. Successful return and rounding-operation correctness are left to their separate preservation owners.Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
f64 intermediate and result used by the native arithmetic, assembly, sign operation, and dispatcher has exactly one carrier word, and every carrier word represents a source f64 encoding. Hence the representation adds no restriction or representation failure to any contract implementation. Component behavior, normal returns, operation semantics, and dispatcher control choices are left to their separate preservation owners.Requirement: dispatch component compliance
f64 intermediate and result of the actual native, assembly, negation, and dispatcher calls has exactly one carrier word, and every carrier word is source-representable. Thus representing component values and rounding targets introduces no restriction or representation failure. Agreement of actual calls with their contracts, normal-return and deferral distinctions, operation behavior, and call-site control choices are left to the separate operation-binding and dispatcher preservation owners.Requirement: parser accumulated rounding
f64 intermediate and result has exactly one retained word, and every accumulated-value rounding target of DecimalGoalVocabularyDefault is a carrier word representable by a source f64. Hence target comparison adds no representation restriction or failure. Successful return and rounding correctness are left to their separate preservation owners.Requirement: parser equal target rounding
f64 intermediate and result has exactly one retained word, and every exact- or accumulated-value target of DecimalGoalVocabularyDefault is source-representable. Equality of targets and observation of the result are therefore exact complete-word observations with no representation restriction or failure. Successful return, rounding, and lexical-sign application are left to their separate preservation owners.Requirement: number helper acceptance
Requirement: number helper rejection
Requirement: number helper record bounds
negative, mantissa, and other fields are distinct source observations and do not use this float carrier.Requirement: number helper accumulated value
Requirement: special helper infinity
Some, and construction of the infinity are left to their separate preservation owners.Requirement: special helper nan
Some, and result construction are left to their separate preservation owners.Requirement: special helper rejection
None result contains no float, and any source f64 intermediate has exactly one carrier word with no representation failure. The carrier claim does not establish that the helper returns normally with None; that outcome and the branch behavior leading to it are left to their separate preservation owners.Requirement: native correct or defer
f64 input, arithmetic intermediate, and Some result in either native path has exactly one carrier word, and every carrier word, including each rounding target of DecimalGoalVocabularyDefault, is source-representable. Thus the carrier adds no value restriction or representation failure. Multiplication, division, sign application, normal return, and None/Some behavior are left to their separate operation-binding preservation owners.Requirement: integer correct or defer
f64, so interpreting a nondeferred pair adds no restriction or representation failure. The integer computation, deferral test, and correctness of the assembly operation are left to their separate preservation owners.Requirement: slow accumulated rounding
f64; its bits are retained exactly for comparison with the accumulated-value target. Thus interpretation adds no restriction or representation failure. Normal return, raw-pair computation, and assembly behavior are left to their separate preservation owners.Requirement: assembly correspondence
f64, and the returned float has that unique retained word. Hence the carrier adds no well-formedness condition or representation failure. Normal return and correctness of the cast, shift, OR, and from_bits operations are left to their separate operation-binding preservation owners.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
f64, so the carrier places no additional restriction on the target relation. Existence of a target is a property of that separate mathematical relation, not a consequence of the carrier bijection.Requirement: rounding determinism
f64; the bijection neither identifies distinct words nor excludes any word. Thus target equality is preserved exactly, while uniqueness itself remains a property of the separate rounding relation.Requirement: exponent value agreement
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
F64 · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/float-carriers.txt
Primary evidence for the F64 raw-word carrier
Scope
-----
This record supports only the representation claim that the source f64
specialization and the authored F64 carrier have the same set of 64-bit
encodings. It does not supply arithmetic or classification semantics.
All commands below were run from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0001/dec2flt-r0001
Tool and input identities
-------------------------
Command:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
Raw result:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Command:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean --version
Raw result:
Lean (version 4.30.0-rc2, x86_64-unknown-linux-gnu, commit 3dc1a088b6d2d8eafe25a7cd7ec7b58d731bd7cc, Release)
Command:
git -C /home/leanagent/pv_spike/tools/aeneas rev-parse HEAD
Raw result:
fa699427cdfa8f604b891fb0223ef42883dd7dc4
Command:
git -C /home/leanagent/pv_spike/tools/aeneas status --short
Raw result: empty (the pinned Aeneas checkout was clean).
Command:
sha256sum upstream/traits.rs modeling-input/manifest.json \
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs \
/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
Raw result:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2 modeling-input/manifest.json
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean
The manifest's effective_tools entry selects the rustc and Lean paths above,
and its effective_tools.lean_paths begins with the displayed Aeneas checkout.
Frozen f64 specialization
-------------------------
Command:
nl -ba upstream/traits.rs | sed -n '264,295p'
Raw result:
264 impl Float for f64 {
265 type Int = u64;
266
267 const INFINITY: Self = Self::INFINITY;
268 const NEG_INFINITY: Self = Self::NEG_INFINITY;
269 const NAN: Self = Self::NAN;
270 const NEG_NAN: Self = -Self::NAN;
271
272 const BITS: u32 = 64;
273 const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
274 const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
275 const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
276
277 const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
278 const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
279 const SMALLEST_POWER_OF_TEN: i32 = -342;
280
281 fn to_bits(self) -> Self::Int {
282 self.to_bits()
283 }
284
285 fn classify(self) -> FpCategory {
286 self.classify()
287 }
288 }
289
290 impl FloatExt for f64 {
291 #[inline]
292 fn from_u64_bits(v: u64) -> Self {
293 f64::from_bits(v)
294 }
295 }
Thus the exact specialization boundary uses u64 in both directions: its
observation calls f64::to_bits, and its constructor calls f64::from_bits with
the complete u64, without a mask or numeric cast.
Pinned Rust exact-bit operations
--------------------------------
The source path was obtained with this command:
printf '%s/lib/rustlib/src/rust/library/core/src/num/f64.rs\n' \
"$(/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc --print sysroot)"
Raw result:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs
Command (with F equal to that raw result):
nl -ba "$F" | sed -n '1201,1273p'
Raw result:
1201 /// Raw transmutation to `u64`.
1202 ///
1203 /// This is currently identical to `transmute::<f64, u64>(self)` on all platforms.
1204 ///
1205 /// See [`from_bits`](Self::from_bits) for some discussion of the
1206 /// portability of this operation (there are almost no issues).
1207 ///
1208 /// Note that this function is distinct from `as` casting, which attempts to
1209 /// preserve the *numeric* value, and not the bitwise value.
1210 ///
1211 /// # Examples
1212 ///
1213 /// ```
1214 /// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
1215 /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
1216 /// ```
1217 #[must_use = "this returns the result of the operation, \
1218 without modifying the original"]
1219 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1220 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1221 #[allow(unnecessary_transmutes)]
1222 #[inline]
1223 pub const fn to_bits(self) -> u64 {
1224 // SAFETY: `u64` is a plain old datatype so we can always transmute to it.
1225 unsafe { mem::transmute(self) }
1226 }
1227
1228 /// Raw transmutation from `u64`.
1229 ///
1230 /// This is currently identical to `transmute::<u64, f64>(v)` on all platforms.
1231 /// It turns out this is incredibly portable, for two reasons:
1232 ///
1233 /// * Floats and Ints have the same endianness on all supported platforms.
1234 /// * IEEE 754 very precisely specifies the bit layout of floats.
1235 ///
1236 /// However there is one caveat: prior to the 2008 version of IEEE 754, how
1237 /// to interpret the NaN signaling bit wasn't actually specified. Most platforms
1238 /// (notably x86 and ARM) picked the interpretation that was ultimately
1239 /// standardized in 2008, but some didn't (notably MIPS). As a result, all
1240 /// signaling NaNs on MIPS are quiet NaNs on x86, and vice-versa.
1241 ///
1242 /// Rather than trying to preserve signaling-ness cross-platform, this
1243 /// implementation favors preserving the exact bits. This means that
1244 /// any payloads encoded in NaNs will be preserved even if the result of
1245 /// this method is sent over the network from an x86 machine to a MIPS one.
1246 ///
1247 /// If the results of this method are only manipulated by the same
1248 /// architecture that produced them, then there is no portability concern.
1249 ///
1250 /// If the input isn't NaN, then there is no portability concern.
1251 ///
1252 /// If you don't care about signaling-ness (very likely), then there is no
1253 /// portability concern.
1254 ///
1255 /// Note that this function is distinct from `as` casting, which attempts to
1256 /// preserve the *numeric* value, and not the bitwise value.
1257 ///
1258 /// # Examples
1259 ///
1260 /// ```
1261 /// let v = f64::from_bits(0x4029000000000000);
1262 /// assert_eq!(v, 12.5);
1263 /// ```
1264 #[stable(feature = "float_bits_conv", since = "1.20.0")]
1265 #[rustc_const_stable(feature = "const_float_bits_conv", since = "1.83.0")]
1266 #[must_use]
1267 #[inline]
1268 #[allow(unnecessary_transmutes)]
1269 pub const fn from_bits(v: u64) -> Self {
1270 // It turns out the safety issues with sNaN were overblown! Hooray!
1271 // SAFETY: `u64` is a plain old datatype so we can always transmute from it.
1272 unsafe { mem::transmute(v) }
1273 }
These are opposite same-size transmutations, and the source explicitly chooses
exact bit preservation for NaNs, including their payloads.
Pinned Aeneas 64-bit carrier
----------------------------
Command:
nl -ba /home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std/Scalar/Core.lean \
| sed -n '27,34p;45,53p;65,69p;650,656p;1089,1094p'
Raw result:
27 /-- Kinds of unsigned integers -/
28 inductive UScalarTy where
29 | Usize
30 | U8
31 | U16
32 | U32
33 | U64
34 | U128
45 @[implicit_reducible]
46 def UScalarTy.numBits (ty : UScalarTy) : Nat :=
47 match ty with
48 | Usize => System.Platform.numBits
49 | U8 => 8
50 | U16 => 16
51 | U32 => 32
52 | U64 => 64
53 | U128 => 128
65 /-- Unsigned integer -/
66 structure UScalar (ty : UScalarTy) where
67 /- The internal representation is a bit-vector -/
68 bv : BitVec ty.numBits
69 deriving Repr, BEq, DecidableEq
650 /-! The scalar types. -/
651 abbrev Usize := UScalar .Usize
652 abbrev U8 := UScalar .U8
653 abbrev U16 := UScalar .U16
654 abbrev U32 := UScalar .U32
655 abbrev U64 := UScalar .U64
656 abbrev U128 := UScalar .U128
1089 abbrev U8.bv (x : U8) : BitVec 8 := UScalar.bv x
1090 abbrev U16.bv (x : U16) : BitVec 16 := UScalar.bv x
1091 abbrev U32.bv (x : U32) : BitVec 32 := UScalar.bv x
1092 abbrev U64.bv (x : U64) : BitVec 64 := UScalar.bv x
1093 abbrev U128.bv (x : U128) : BitVec 128 := UScalar.bv x
1094 abbrev Usize.bv (x : Usize) : BitVec System.Platform.numBits := UScalar.bv x
Consequently Std.U64 is a one-field structure whose field ranges over every
BitVec 64. There is neither a validity predicate nor a quotient that could
remove, merge, or add raw words.
Requirements depending on this item (32)
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
All 32 entries
- Assembly correspondence
- Classification determinism
- Significand digit
- Classification totality
- Conditional abstract composition
- Conditional component compliance
- Exponent agreement
- Correctness or defer
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected exponent range
- Selected magnitude sign
- Signed zero
- Conditional totality
- Rounding determinism
- Rounding totality
- Full-significand diagnostic
- Infinity
- NaN
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:1e148bcabf23b5c56cb39160057c6a865f47cdadb78b20ab340b1df4116948ea |
| Preservation current fingerprint | preservation-v1:1e148bcabf23b5c56cb39160057c6a865f47cdadb78b20ab340b1df4116948ea |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","lean_semantic_closure":"e635794078f5dc661ee0333607027ee168a5c0cdc88af5c09543d1d251ae951a","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","lean_semantic_closure":"e635794078f5dc661ee0333607027ee168a5c0cdc88af5c09543d1d251ae951a","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "79fd9348225e1bf9cbc47ccb99d3a2e93854e3562527d26b794e6091122c7efd",
"dep_statement_hashes": {
"DecimalGoalVocabularyDefault": "32a84a43f71314245b7cbbbce3aefa2bde7d8120fb1fddb93ff7b90796f8a87b"
},
"combined_sound_fp": "preservation-v1:1e148bcabf23b5c56cb39160057c6a865f47cdadb78b20ab340b1df4116948ea"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/float-carriers.txt",
"sha256": "4367b150c75a979015e2a6063d4080d3f0a1681c640421692ff9ac8c139632e5",
"cited_by": [
"Tablet/F64.tex",
"committed_node_kinds / pv_tablet.json"
]
}
]P9_T1_AbstractComponents
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_DispatchOperations
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P9_T1_AbstractComponents]
structure P9_T1_AbstractComponents where
-- BODY
parseNumber : Slice Std.U8 -> Option num.imp.dec2flt.decimal.Decimal
parseSpecial : Slice Std.U8 -> Bool -> Option F64
native : num.imp.dec2flt.decimal.Decimal -> Option F64
integer : Std.I64 -> Std.U64 -> num.imp.dec2flt.common.BiasedFp
slow : Slice Std.U8 -> num.imp.dec2flt.common.BiasedFp
assemble : num.imp.dec2flt.common.BiasedFp -> F64
negate : F64 -> F64
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.Requirement: native correct or defer
Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.Requirement: parser exact rounding
Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
AbstractComponents · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (7)
- Conditional abstract composition
- Conditional component compliance
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional numeric acceptance
All 7 entries
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:c6aa1593474d801cb3a4a5eb48e0bd2b4a9abf8e9aaf0b6bfab2709a024168b3 |
| Preservation current fingerprint | preservation-v1:c6aa1593474d801cb3a4a5eb48e0bd2b4a9abf8e9aaf0b6bfab2709a024168b3 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","lean_semantic_closure":"9912a3ac2a133e9dadef39d2abf049c3af2f9e1d408be964844909afa4398c79","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","lean_semantic_closure":"9912a3ac2a133e9dadef39d2abf049c3af2f9e1d408be964844909afa4398c79","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "bb110816b0d85d9dc818b61b5b5c49bd958aa7168a60b1ea854a270fe784eb9c",
"dep_statement_hashes": {
"DispatchContracts": "4515ac9357cf79a45937c80584897befcb3040702c14d0c55f1a5adeccc02d25",
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af",
"P9_T1_ActualDispatchOperations": "1baa06e80d4c83541df27d1ac51e01b9cb5f94f595d433880a623af7ba2a1b68",
"P9_T1_DispatchOperations": "9ba41cd8008aa941532d645a6bb8796d262a98adc0bc81bfac1da69442393d60"
},
"combined_sound_fp": "preservation-v1:c6aa1593474d801cb3a4a5eb48e0bd2b4a9abf8e9aaf0b6bfab2709a024168b3"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_AbstractComponents.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]P9_T1_ActualDispatchOperations
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_DispatchOperations
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.num_imp_dec2flt_dec2flt_with_trace
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
noncomputable section
namespace dec2flt_model
-- [TABLET NODE: P9_T1_ActualDispatchOperations]
def P9_T1_ActualDispatchOperations : P9_T1_DispatchOperations :=
-- BODY
{ parseNumber := num.imp.dec2flt.parse.parse_number
parseSpecial := num.imp.dec2flt.parse.parse_inf_nan F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst
native := num.imp.dec2flt.decimal.Decimal.try_fast_path
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64
integer := num.imp.dec2flt.lemire.compute_float F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst
slow := num.imp.dec2flt.slow.parse_long_mantissa F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst
assemble := num.imp.dec2flt.biased_fp_to_float F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst
negate := F64.Insts.CoreOpsArithNegF64.neg }
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
parse_number; special is parse_inf_nan with the extracted
f64 Float instance and the unchanged separate sign. Native is
Decimal.try_fast_path with the extracted Lemire and Div/Mul/Neg
instances. Integer and slow use that same instance's Float component;
assembly uses its FloatExt component; negation is the extracted f64
negation instance. No body, scalar, record field or trait argument is
changed. Field application is therefore definitionally the original
Result-valued helper call, not just its value on success.ok none, fail and div remain
different. The unconditional ActualDispatchFrameEquality
identifies the frame on this record with the extracted traced parser;
projecting the trace away yields the same public Rust result or outer
failure/divergence. Neither identification uses a component contract,
source-validity, a length bound or a normal-return premise.
The current source/extraction and call evidence are in
reference/model-evidence/dispatch-contracts.txt.Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.Requirement: native correct or defer
Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.Requirement: parser exact rounding
Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ActualDispatchOperations · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (19)
- Conditional abstract composition
- Conditional component compliance
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
All 19 entries
- Conditional abstract composition
- Conditional component compliance
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Signed zero
- Conditional totality
- Full-significand diagnostic
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:817f6c94df7fc548c903101f91de521c7c3dab0ab88e2f281f10edc9ca80db54 |
| Preservation current fingerprint | preservation-v1:817f6c94df7fc548c903101f91de521c7c3dab0ab88e2f281f10edc9ca80db54 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"b578349cf5d69fb995f5a78081f2c0ea8f0e59bb869b24c632422c2ff625a698","lean_semantic_closure":"168ab9860e62d34ae9b0455b169bb2b1695971fefabbfcbdcb230a3440836e06","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelOptionBranch":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","ModelOptionFromResidual":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","ModelSliceSplitFirst":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","ModelU8IsAsciiDigit":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelOptionBranch","ModelOptionFromResidual","ModelSliceSplitFirst","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","ModelU8IsAsciiDigit","P9_T1_DispatchOperations","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_biased_fp_to_float","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_zero_pow2","num_imp_dec2flt_common_is_8digits","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_decimal_Decimal_can_use_fast_path","num_imp_dec2flt_decimal_Decimal_try_fast_path","num_imp_dec2flt_decimal_INT_POW10","num_imp_dec2flt_decimal_seq_DecimalSeq","num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE","num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW","num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_round","num_imp_dec2flt_decimal_seq_DecimalSeq_trim","num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit","num_imp_dec2flt_decimal_seq_count_trailing_zeros","num_imp_dec2flt_decimal_seq_final_decimal_point","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5","num_imp_dec2flt_decimal_seq_parse_decimal_seq","num_imp_dec2flt_decimal_seq_parse_digits_into_seq","num_imp_dec2flt_fpu_fpu_precision_set_precision","num_imp_dec2flt_lemire_compute_float","num_imp_dec2flt_lemire_compute_product_approx","num_imp_dec2flt_lemire_full_multiplication","num_imp_dec2flt_lemire_power","num_imp_dec2flt_parse_MIN_19DIGIT_INT","num_imp_dec2flt_parse_adjust_many_digit_count","num_imp_dec2flt_parse_parse_8digits","num_imp_dec2flt_parse_parse_8digits_MASK","num_imp_dec2flt_parse_parse_8digits_MUL1","num_imp_dec2flt_parse_parse_8digits_MUL2","num_imp_dec2flt_parse_parse_inf_nan","num_imp_dec2flt_parse_parse_many_digits","num_imp_dec2flt_parse_parse_number","num_imp_dec2flt_parse_parse_partial_number","num_imp_dec2flt_parse_parse_scientific","num_imp_dec2flt_parse_try_parse_19digits","num_imp_dec2flt_parse_try_parse_digits","num_imp_dec2flt_slow_parse_long_mantissa","num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT","num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_closure","num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call","num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE","num_imp_dec2flt_table_POWER_OF_FIVE_128","num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"b578349cf5d69fb995f5a78081f2c0ea8f0e59bb869b24c632422c2ff625a698","lean_semantic_closure":"168ab9860e62d34ae9b0455b169bb2b1695971fefabbfcbdcb230a3440836e06","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelOptionBranch":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","ModelOptionFromResidual":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","ModelSliceSplitFirst":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","ModelU8IsAsciiDigit":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelOptionBranch","ModelOptionFromResidual","ModelSliceSplitFirst","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","ModelU8IsAsciiDigit","P9_T1_DispatchOperations","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_biased_fp_to_float","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_zero_pow2","num_imp_dec2flt_common_is_8digits","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_decimal_Decimal_can_use_fast_path","num_imp_dec2flt_decimal_Decimal_try_fast_path","num_imp_dec2flt_decimal_INT_POW10","num_imp_dec2flt_decimal_seq_DecimalSeq","num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE","num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW","num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_round","num_imp_dec2flt_decimal_seq_DecimalSeq_trim","num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit","num_imp_dec2flt_decimal_seq_count_trailing_zeros","num_imp_dec2flt_decimal_seq_final_decimal_point","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5","num_imp_dec2flt_decimal_seq_parse_decimal_seq","num_imp_dec2flt_decimal_seq_parse_digits_into_seq","num_imp_dec2flt_fpu_fpu_precision_set_precision","num_imp_dec2flt_lemire_compute_float","num_imp_dec2flt_lemire_compute_product_approx","num_imp_dec2flt_lemire_full_multiplication","num_imp_dec2flt_lemire_power","num_imp_dec2flt_parse_MIN_19DIGIT_INT","num_imp_dec2flt_parse_adjust_many_digit_count","num_imp_dec2flt_parse_parse_8digits","num_imp_dec2flt_parse_parse_8digits_MASK","num_imp_dec2flt_parse_parse_8digits_MUL1","num_imp_dec2flt_parse_parse_8digits_MUL2","num_imp_dec2flt_parse_parse_inf_nan","num_imp_dec2flt_parse_parse_many_digits","num_imp_dec2flt_parse_parse_number","num_imp_dec2flt_parse_parse_partial_number","num_imp_dec2flt_parse_parse_scientific","num_imp_dec2flt_parse_try_parse_19digits","num_imp_dec2flt_parse_try_parse_digits","num_imp_dec2flt_slow_parse_long_mantissa","num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT","num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_closure","num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call","num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE","num_imp_dec2flt_table_POWER_OF_FIVE_128","num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "dfb399217d22d39a7741f95432f0372afffb7931ee5f86f14c88c67b8e2058eb",
"dep_statement_hashes": {
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af"
},
"combined_sound_fp": "preservation-v1:817f6c94df7fc548c903101f91de521c7c3dab0ab88e2f281f10edc9ca80db54"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_ActualDispatchOperations.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]P9_T1_DispatchCall
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_DispatchOperations
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P9_T1_DispatchCall]
inductive P9_T1_DispatchCall where
-- BODY
| number : Slice Std.U8 -> Bool -> P9_T1_DispatchCall
| special : Slice Std.U8 -> Bool -> P9_T1_DispatchCall
| native : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal -> P9_T1_DispatchCall
| first : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal -> P9_T1_DispatchCall
| increment : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal ->
num.imp.dec2flt.common.BiasedFp -> P9_T1_DispatchCall
| second : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal ->
num.imp.dec2flt.common.BiasedFp -> Std.U64 -> P9_T1_DispatchCall
| compare : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal ->
num.imp.dec2flt.common.BiasedFp -> num.imp.dec2flt.common.BiasedFp -> P9_T1_DispatchCall
| post : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal ->
num.imp.dec2flt.common.BiasedFp -> P9_T1_DispatchCall
| slow : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal ->
num.imp.dec2flt.common.BiasedFp -> P9_T1_DispatchCall
| assemble : Slice Std.U8 -> Bool -> num.imp.dec2flt.decimal.Decimal ->
num.imp.dec2flt.common.BiasedFp -> P9_T1_DispatchCall
| negate : Slice Std.U8 -> num.imp.dec2flt.decimal.Decimal ->
num.imp.dec2flt.common.BiasedFp -> F64 -> P9_T1_DispatchCall
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.Requirement: native correct or defer
Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.Requirement: parser exact rounding
Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
DispatchCall · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (6)
- Conditional component compliance
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional numeric acceptance
- Conditional totality
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:0f2e2a302d8427773650f5a9e32c4bdb63f6d39b47c46975decaf9c4d9a2261d |
| Preservation current fingerprint | preservation-v1:0f2e2a302d8427773650f5a9e32c4bdb63f6d39b47c46975decaf9c4d9a2261d |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"aafbab5720f9f1f1be1a4f1ad90751b052013f2f548a12cb89c762ad2f57d702","lean_semantic_closure":"e23c56175565aa5d51a6b00464a21c803e795e4e272b0ef32e6524095f1bfa8e","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"aafbab5720f9f1f1be1a4f1ad90751b052013f2f548a12cb89c762ad2f57d702","lean_semantic_closure":"e23c56175565aa5d51a6b00464a21c803e795e4e272b0ef32e6524095f1bfa8e","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "4071ab3ae83f09f8076ddfb74f282714d014e8988a266d785c509aa46206623d",
"dep_statement_hashes": {
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af"
},
"combined_sound_fp": "preservation-v1:0f2e2a302d8427773650f5a9e32c4bdb63f6d39b47c46975decaf9c4d9a2261d"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_DispatchCall.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]P9_T1_DispatchFrame
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_DispatchOperations
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.num_imp_dec2flt_dec2flt_with_trace
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
noncomputable section
namespace dec2flt_model
-- [TABLET NODE: P9_T1_DispatchFrame]
def P9_T1_DispatchFrame (ops : P9_T1_DispatchOperations) (s : Str) :
Result ((core.result.Result F64 num.float_parse.ParseFloatError) ×
num.imp.dec2flt.Dec2FltTrace F64) :=
-- BODY
do
let body ← core.str.Str.as_bytes s
let o ← core.slice.Slice.first body
match o with
| none =>
let pfe ← num.imp.dec2flt.pfe_empty
ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
| some c =>
let body1 ←
if c = 45#u8
then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
{ start := 1#usize }
else
if c = 43#u8
then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
{ start := 1#usize }
else ok body
let b ← core.slice.Slice.is_empty body1
if b
then
let pfe ← num.imp.dec2flt.pfe_invalid
ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
body1 (c = 45#u8))
else
let parse_number_result ← ops.parseNumber body1
match parse_number_result with
| none =>
let parse_inf_nan_result ←
ops.parseSpecial body1 (c = 45#u8)
match parse_inf_nan_result with
| none =>
let pfe ← num.imp.dec2flt.pfe_invalid
ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
body1 (c = 45#u8) none none)
| some value =>
ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
body1 (c = 45#u8) none parse_inf_nan_result value)
| some r =>
let fast_path_result ←
ops.native
{ r with negative := (c = 45#u8) }
match fast_path_result with
| none =>
let first_compute_result ←
ops.integer r.exponent r.mantissa
let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
if r.many_digits
then
ok (true, true, first_compute_result, first_compute_result,
first_compute_result.p_biased >= 0#i32)
else
ok (false, false, first_compute_result, first_compute_result,
false)
let (post_comparison_pair, second_compute_exponent,
second_compute_mantissa, second_compute_result,
second_equals_first, forced_deferral) ←
if second_compute_guard
then
do
let mantissa ← r.mantissa + 1#u64
let second ←
ops.integer r.exponent mantissa
let equal ←
num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
fp second
let (bf, b3) ←
if equal
then ok (fp, false)
else ok ({ fp with p_biased := (-1)#i32 }, true)
ok (bf, some r.exponent, some mantissa, some second, some equal,
b3)
else ok (fp, none, none, none, none, false)
let (selected_pair, slow_path_guard, slow_path_result) ←
if post_comparison_pair.p_biased < 0#i32
then
do
let replacement ←
ops.slow body1
ok (replacement, true, some replacement)
else ok (post_comparison_pair, false, none)
let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
let i1 ← F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let assembled_word ← lift (selected_pair.m ||| i2)
let assembly_result ←
ops.assemble
selected_pair
if c = 45#u8
then
let result ← ops.negate assembly_result
ok (core.result.Result.Ok result,
num.imp.dec2flt.Dec2FltTrace.Assembled
{
body := body1,
negative := true,
parse_number_result := (some { r with many_digits := b1 }),
fast_path_input :=
{ r with negative := true, many_digits := b2 },
fast_path_result := none,
first_compute_exponent := r.exponent,
first_compute_mantissa := r.mantissa,
first_compute_result := first_compute_result1,
second_compute_guard,
second_compute_exponent,
second_compute_mantissa,
second_compute_result,
second_equals_first,
forced_deferral,
post_comparison_pair,
slow_path_guard,
slow_path_result,
selected_pair,
assembled_word,
assembly_result,
lexical_sign_applied := true,
result
})
else
ok (core.result.Result.Ok assembly_result,
num.imp.dec2flt.Dec2FltTrace.Assembled
{
body := body1,
negative := false,
parse_number_result := (some { r with many_digits := b1 }),
fast_path_input :=
{ r with negative := false, many_digits := b2 },
fast_path_result := none,
first_compute_exponent := r.exponent,
first_compute_mantissa := r.mantissa,
first_compute_result := first_compute_result1,
second_compute_guard,
second_compute_exponent,
second_compute_mantissa,
second_compute_result,
second_equals_first,
forced_deferral,
post_comparison_pair,
slow_path_guard,
slow_path_result,
selected_pair,
assembled_word,
assembly_result,
lexical_sign_applied := false,
result := assembly_result
})
| some value =>
ok (core.result.Result.Ok value,
num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
parse_number_result { r with negative := (c = 45#u8) }
fast_path_result value)
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
dec2flt_with_trace.
Only the seven helper expressions are parameterized. Byte observation,
leading-sign stripping, empty/sign-only Rust errors, numeric-before-special
order, and the sign-only overwrite of the native input are unchanged.
Native Some is a direct return. Native None uses the original numeric
exponent and mantissa in the first integer call.Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.Requirement: native correct or defer
Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.Requirement: parser exact rounding
Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
DispatchFrame · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (7)
- Conditional abstract composition
- Conditional component compliance
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional numeric acceptance
All 7 entries
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:02458c742e2bc5cbb69dae87b0a5a2ad36070d5039e43fc69c71b9bd49035eb6 |
| Preservation current fingerprint | preservation-v1:02458c742e2bc5cbb69dae87b0a5a2ad36070d5039e43fc69c71b9bd49035eb6 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"57fd51c5bdd9d478bbd6dd8b1e2646017d8aa418a1bc2e1a7a42bfa796e065ca","lean_semantic_closure":"00201a956b98acde116009b1f6adb151228362bea02c2e464b9d20c73e6a6970","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelSliceFirst":"daa1d788720f27eca31e722db51d2d3e6e80bb4fb62e35d6bc6d9686e17ab381","ModelStrAsBytes":"7df2b5123e579ab4bfb5510ea39ca58bceb2387aa50af74f44127e51a1e7f281","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelSliceFirst","ModelStrAsBytes","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","P9_T1_DispatchOperations","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_float_parse_FloatErrorKind","num_float_parse_ParseFloatError","num_imp_dec2flt_Dec2FltAssemblyTrace","num_imp_dec2flt_Dec2FltTrace","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_pfe_empty","num_imp_dec2flt_pfe_invalid","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"57fd51c5bdd9d478bbd6dd8b1e2646017d8aa418a1bc2e1a7a42bfa796e065ca","lean_semantic_closure":"00201a956b98acde116009b1f6adb151228362bea02c2e464b9d20c73e6a6970","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelSliceFirst":"daa1d788720f27eca31e722db51d2d3e6e80bb4fb62e35d6bc6d9686e17ab381","ModelStrAsBytes":"7df2b5123e579ab4bfb5510ea39ca58bceb2387aa50af74f44127e51a1e7f281","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelSliceFirst","ModelStrAsBytes","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","P9_T1_DispatchOperations","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_float_parse_FloatErrorKind","num_float_parse_ParseFloatError","num_imp_dec2flt_Dec2FltAssemblyTrace","num_imp_dec2flt_Dec2FltTrace","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_pfe_empty","num_imp_dec2flt_pfe_invalid","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "a9e65cf2f21f7f3b471ef78929278240e49c1efb1302a8309f3f3b7e7ce662a5",
"dep_statement_hashes": {
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af"
},
"combined_sound_fp": "preservation-v1:02458c742e2bc5cbb69dae87b0a5a2ad36070d5039e43fc69c71b9bd49035eb6"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_DispatchFrame.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]P9_T1_DispatchOperations
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.F64
import Tablet.num_imp_dec2flt_decimal_Decimal
import Tablet.num_imp_dec2flt_common_BiasedFp
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P9_T1_DispatchOperations]
structure P9_T1_DispatchOperations where
-- BODY
parseNumber : Slice Std.U8 -> Result (Option num.imp.dec2flt.decimal.Decimal)
parseSpecial : Slice Std.U8 -> Bool -> Result (Option F64)
native : num.imp.dec2flt.decimal.Decimal -> Result (Option F64)
integer : Std.I64 -> Std.U64 -> Result num.imp.dec2flt.common.BiasedFp
slow : Slice Std.U8 -> Result num.imp.dec2flt.common.BiasedFp
assemble : num.imp.dec2flt.common.BiasedFp -> Result F64
negate : F64 -> Result F64
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
ok none is a normal helper refusal, not fail or
div. Merely collecting functions of these types evaluates no call
and equates none of these outcomes.Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.Requirement: native correct or defer
Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.Requirement: parser exact rounding
Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
DispatchOperations · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (19)
- Conditional abstract composition
- Conditional component compliance
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
All 19 entries
- Conditional abstract composition
- Conditional component compliance
- Native correctness or defer
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Infinity
- Conditional invalid rejection
- NaN acceptance
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Signed zero
- Conditional totality
- Full-significand diagnostic
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:0748124e8294a22bbb2138c56f26cb1bfbcd71459a9a34779dc35080bd90c8c0 |
| Preservation current fingerprint | preservation-v1:0748124e8294a22bbb2138c56f26cb1bfbcd71459a9a34779dc35080bd90c8c0 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366","lean_semantic_closure":"d9a103536031cfe9ea744aa409ec45da297fe18699fe6a17bde2836c77e92b58","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366","lean_semantic_closure":"d9a103536031cfe9ea744aa409ec45da297fe18699fe6a17bde2836c77e92b58","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2"},"lean_relevant_dependencies":["F64","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "e176a174c2cb155f3e900a50a1f0203d0b242c60bf785d5f6103211f551f89d9",
"dep_statement_hashes": {
"DecimalGoalVocabularyDefault": "32a84a43f71314245b7cbbbce3aefa2bde7d8120fb1fddb93ff7b90796f8a87b",
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af",
"SourceValidByteSlice": "52522ae5b8602c6279dde2af31f94e21db249400641f5d3e951f68a74c3c11e2"
},
"combined_sound_fp": "preservation-v1:0748124e8294a22bbb2138c56f26cb1bfbcd71459a9a34779dc35080bd90c8c0"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_DispatchOperations.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]P9_T1_EmbedComponents
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_AbstractComponents
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P9_T1_EmbedComponents]
def P9_T1_EmbedComponents (C : P9_T1_AbstractComponents) : P9_T1_DispatchOperations :=
-- BODY
{ parseNumber := fun s => ok (C.parseNumber s)
parseSpecial := fun s negative => ok (C.parseSpecial s negative)
native := fun d => ok (C.native d)
integer := fun q w => ok (C.integer q w)
slow := fun s => ok (C.slow s)
assemble := fun fp => ok (C.assemble fp)
negate := fun f => ok (C.negate f) }
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
ok of that abstract field applied to exactly the supplied
arguments. Hence an abstract None becomes ok none; the definition
does not inspect a concrete Result and has no branch completing
fail or div. All machine operands, record fields,
unrestricted assembly pairs and words are retained.Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.Requirement: native correct or defer
Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.Requirement: parser exact rounding
Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
EmbedComponents · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (6)
- Conditional abstract composition
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional numeric acceptance
- Conditional totality
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:a33a9d76c21841d131a82f0fca731edd23e657ce48490f0dd71263bc87bed4cb |
| Preservation current fingerprint | preservation-v1:a33a9d76c21841d131a82f0fca731edd23e657ce48490f0dd71263bc87bed4cb |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"447d8149f8a9b68ea402fa612235fa6e753744f275c0dbf470dcb5c486045e4a","lean_semantic_closure":"7b30dc79fe3f3d2f6a765c5602fefa7bd22515c55caa1b9614cf7705888a82f7","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","P9_T1_AbstractComponents":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["F64","P9_T1_AbstractComponents","P9_T1_DispatchOperations","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"447d8149f8a9b68ea402fa612235fa6e753744f275c0dbf470dcb5c486045e4a","lean_semantic_closure":"7b30dc79fe3f3d2f6a765c5602fefa7bd22515c55caa1b9614cf7705888a82f7","lean_relevant_definition_descendants":{"F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","P9_T1_AbstractComponents":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["F64","P9_T1_AbstractComponents","P9_T1_DispatchOperations","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_decimal_Decimal"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "249d442e548fe51953c223d0615741bbdd86f8c69c9d8f4d4e95a997fd1c68ff",
"dep_statement_hashes": {
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af",
"P9_T1_DispatchFrame": "9c8534245e042036f0736480d142a007a6fd6a417572dd00c6c15eb95f8e0c98"
},
"combined_sound_fp": "preservation-v1:a33a9d76c21841d131a82f0fca731edd23e657ce48490f0dd71263bc87bed4cb"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_EmbedComponents.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]P9_T1_NormalComponentRefinement
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_ActualDispatchOperations
import Tablet.P9_T1_AbstractComponents
import Tablet.DecimalGoalVocabularyDefault
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P9_T1_NormalComponentRefinement]
structure P9_T1_NormalComponentRefinement (C : P9_T1_AbstractComponents) : Prop where
-- BODY
number_normal : forall (body : Slice Std.U8) out,
SourceValidByteSlice body -> body.val ≠ [] ->
P9_T1_ActualDispatchOperations.parseNumber body = ok out -> out = C.parseNumber body
number_bounded : forall body : Slice Std.U8,
SourceValidByteSlice body -> body.val ≠ [] ->
body.val.length <= 3458764513820540928 ->
P9_T1_ActualDispatchOperations.parseNumber body = ok (C.parseNumber body)
special_all : forall (body : Slice Std.U8) negative,
SourceValidByteSlice body ->
P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (C.parseSpecial body negative)
native_normal : forall d out,
P9_T1_ActualDispatchOperations.native d = ok out -> out = C.native d
integer_normal : forall q w out,
P9_T1_ActualDispatchOperations.integer q w = ok out -> out = C.integer q w
slow_normal : forall (body : Slice Std.U8) (x : DecimalLexeme) out,
SourceValidByteSlice body -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body ->
P9_T1_ActualDispatchOperations.slow body = ok out -> out = C.slow body
assembly_all : forall fp,
P9_T1_ActualDispatchOperations.assemble fp = ok (C.assemble fp)
negate_all : forall f, P9_T1_ActualDispatchOperations.negate f = ok (C.negate f)
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
number_normal, native_normal,
integer_normal and slow_normal each have an actual
equation to ok out as a hypothesis, followed by equality of
out with the abstract value. They apply respectively to every
nonempty source-valid slice, every Decimal, every I64/U64 pair, and every
source-valid unsigned numeric slice with no A/B restriction. Failure or
divergence supplies no such hypothesis. These fields alone prove no return.number_bounded requires
actual numeric parsing to equal ok of the abstract value on every
nonempty source-valid slice through A=3458764513820540928.
special_all requires the analogous equation on every source-valid
slice and either independent sign. assembly_all requires it on
every unrestricted BiasedFp and negate_all on every word.
None has a normal-return premise. Proving that the actual components
refine a compatible package must establish all these equations; declaring
the relation or choosing total abstract functions does not establish them.
The compatible value laws, package inhabitability and normal realization
at every A-bounded reached call remain separate theorem obligations.Authored arguments for individual requirements
Requirement: parser nan acceptance
number_normal nor a declared refinement relation
supplies acceptance; the necessary actual normal equations and special
value laws must be proved.Requirement: parser infinity
special_all is a normal-return condition to
establish, not an assumed successful special call.Requirement: parser non nan results
Requirement: parser numeric sign
negate_all requires a normal actual equation, but neither
declaring it nor conditional value equality proves the sign law.Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
number_normal equality may transport the record once its
normal Some return is supplied; it supplies no acceptance premise.Requirement: special helper infinity
special_all equation requires normal return for this
slice and sign, with no success premise; it is an obligation of actual
compliance.Requirement: special helper nan
special_all equation requires the actual normal return;
the compatible NaN value law is also still to be established.Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.
The special_all equation requires normal return also on
nonkeywords; it does not merely compare values after successful calls.Requirement: native correct or defer
native_normal clause compares only supplied
normal optional results; no unrestricted native liveness condition
is inserted.Requirement: integer correct or defer
integer_normal clause is conditional equality
of a supplied actual normal pair, not a normal-return assertion for
every scalar input.Requirement: slow accumulated rounding
slow_normal clause compares supplied actual
normal results on this unrestricted source-valid domain; it is not
A/B-bounded realization or unrestricted slow liveness.Requirement: assembly correspondence
assembly_all equation has no normal-return
hypothesis. Actual compliance must establish that equation on every
pair as well as the compatible assembly word law.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
number_normal, native_normal,
integer_normal and slow_normal compare supplied
normal results, whereas number_bounded, special_all,
assembly_all and negate_all require normal equations.
All are conditions of the existentially required refinement, not
preservation assumptions.Requirement: number helper acceptance
number_bounded, unlike number_normal, requires
the actual normal equation. Establishing it and the compatible
acceptance law remains theorem work.Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.
Here number_bounded requires normal agreement on invalid as
well as valid slices; number_normal alone cannot supply None or
normal return.Requirement: parser exact rounding
Requirement: parser invalid rejection
number_bounded and special_all equations require
normal actual results. They cannot be justified by assuming the Err
whose existence is being required.Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
number_normal clause transports the supplied normal
record; compatible representation is an additional law to prove,
not a consequence of declaring refinement.Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
NormalComponentRefinement · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (7)
- Conditional abstract composition
- Conditional component compliance
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional numeric acceptance
All 7 entries
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:bc3b92fed5ffbadb9d54199a259d019eec06f646e387ebad459127340712c9ef |
| Preservation current fingerprint | preservation-v1:bc3b92fed5ffbadb9d54199a259d019eec06f646e387ebad459127340712c9ef |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"e80616f8d68bca577892d9049531eb2ec9ff24b2751b78fe66e243d24fe18d4b","lean_semantic_closure":"476e011c400a05749ca9edeba316439cca714ca9431d3f5aef616d4528582a3d","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","DecimalGoalVocabulary":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","DecimalGoalVocabularyDefault":"b1acfb8165af94d85410cf245ba8dbf65d464f291a1039e04c18d2f5ea85084d","DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelOptionBranch":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","ModelOptionFromResidual":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","ModelSliceSplitFirst":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","ModelU8IsAsciiDigit":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","P9_T1_AbstractComponents":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","P9_T1_ActualDispatchOperations":"b578349cf5d69fb995f5a78081f2c0ea8f0e59bb869b24c632422c2ff625a698","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366","SourceValidByteSlice":"d736148659be38528d8040160c92286f94c9e3a163bf026d5bef1af084b422bd"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","DecimalGoalVocabulary","DecimalGoalVocabularyDefault","DecimalLexeme","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelOptionBranch","ModelOptionFromResidual","ModelSliceSplitFirst","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","ModelU8IsAsciiDigit","P9_T1_AbstractComponents","P9_T1_ActualDispatchOperations","P9_T1_DispatchOperations","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64","SourceValidByteSlice","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_biased_fp_to_float","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_zero_pow2","num_imp_dec2flt_common_is_8digits","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_decimal_Decimal_can_use_fast_path","num_imp_dec2flt_decimal_Decimal_try_fast_path","num_imp_dec2flt_decimal_INT_POW10","num_imp_dec2flt_decimal_seq_DecimalSeq","num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE","num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW","num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_round","num_imp_dec2flt_decimal_seq_DecimalSeq_trim","num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit","num_imp_dec2flt_decimal_seq_count_trailing_zeros","num_imp_dec2flt_decimal_seq_final_decimal_point","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5","num_imp_dec2flt_decimal_seq_parse_decimal_seq","num_imp_dec2flt_decimal_seq_parse_digits_into_seq","num_imp_dec2flt_fpu_fpu_precision_set_precision","num_imp_dec2flt_lemire_compute_float","num_imp_dec2flt_lemire_compute_product_approx","num_imp_dec2flt_lemire_full_multiplication","num_imp_dec2flt_lemire_power","num_imp_dec2flt_parse_MIN_19DIGIT_INT","num_imp_dec2flt_parse_adjust_many_digit_count","num_imp_dec2flt_parse_parse_8digits","num_imp_dec2flt_parse_parse_8digits_MASK","num_imp_dec2flt_parse_parse_8digits_MUL1","num_imp_dec2flt_parse_parse_8digits_MUL2","num_imp_dec2flt_parse_parse_inf_nan","num_imp_dec2flt_parse_parse_many_digits","num_imp_dec2flt_parse_parse_number","num_imp_dec2flt_parse_parse_partial_number","num_imp_dec2flt_parse_parse_scientific","num_imp_dec2flt_parse_try_parse_19digits","num_imp_dec2flt_parse_try_parse_digits","num_imp_dec2flt_slow_parse_long_mantissa","num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT","num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_closure","num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call","num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE","num_imp_dec2flt_table_POWER_OF_FIVE_128","num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"e80616f8d68bca577892d9049531eb2ec9ff24b2751b78fe66e243d24fe18d4b","lean_semantic_closure":"476e011c400a05749ca9edeba316439cca714ca9431d3f5aef616d4528582a3d","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","DecimalGoalVocabulary":"93815606c510afb8f425bb3ef618e21f81033cc552e15695a4d443dbb7010103","DecimalGoalVocabularyDefault":"b1acfb8165af94d85410cf245ba8dbf65d464f291a1039e04c18d2f5ea85084d","DecimalLexeme":"aeeeec41a307a5fb7e3916c9c4899c4077abccd652062c92a252fc65a8e7d7a6","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelOptionBranch":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","ModelOptionFromResidual":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","ModelSliceSplitFirst":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","ModelU8IsAsciiDigit":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","P9_T1_AbstractComponents":"38875a81b8b9371756b4b1a0b05cdbbbca7fd9405dbed4ef094d08ebefa929e8","P9_T1_ActualDispatchOperations":"b578349cf5d69fb995f5a78081f2c0ea8f0e59bb869b24c632422c2ff625a698","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366","SourceValidByteSlice":"d736148659be38528d8040160c92286f94c9e3a163bf026d5bef1af084b422bd"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","DecimalGoalVocabulary","DecimalGoalVocabularyDefault","DecimalLexeme","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelOptionBranch","ModelOptionFromResidual","ModelSliceSplitFirst","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","ModelU8IsAsciiDigit","P9_T1_AbstractComponents","P9_T1_ActualDispatchOperations","P9_T1_DispatchOperations","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64","SourceValidByteSlice","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_biased_fp_to_float","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_zero_pow2","num_imp_dec2flt_common_is_8digits","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_decimal_Decimal_can_use_fast_path","num_imp_dec2flt_decimal_Decimal_try_fast_path","num_imp_dec2flt_decimal_INT_POW10","num_imp_dec2flt_decimal_seq_DecimalSeq","num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE","num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW","num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_round","num_imp_dec2flt_decimal_seq_DecimalSeq_trim","num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit","num_imp_dec2flt_decimal_seq_count_trailing_zeros","num_imp_dec2flt_decimal_seq_final_decimal_point","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5","num_imp_dec2flt_decimal_seq_parse_decimal_seq","num_imp_dec2flt_decimal_seq_parse_digits_into_seq","num_imp_dec2flt_fpu_fpu_precision_set_precision","num_imp_dec2flt_lemire_compute_float","num_imp_dec2flt_lemire_compute_product_approx","num_imp_dec2flt_lemire_full_multiplication","num_imp_dec2flt_lemire_power","num_imp_dec2flt_parse_MIN_19DIGIT_INT","num_imp_dec2flt_parse_adjust_many_digit_count","num_imp_dec2flt_parse_parse_8digits","num_imp_dec2flt_parse_parse_8digits_MASK","num_imp_dec2flt_parse_parse_8digits_MUL1","num_imp_dec2flt_parse_parse_8digits_MUL2","num_imp_dec2flt_parse_parse_inf_nan","num_imp_dec2flt_parse_parse_many_digits","num_imp_dec2flt_parse_parse_number","num_imp_dec2flt_parse_parse_partial_number","num_imp_dec2flt_parse_parse_scientific","num_imp_dec2flt_parse_try_parse_19digits","num_imp_dec2flt_parse_try_parse_digits","num_imp_dec2flt_slow_parse_long_mantissa","num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT","num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_closure","num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call","num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE","num_imp_dec2flt_table_POWER_OF_FIVE_128","num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "28d2705f667ca38bdb750f7a449156e9b9e38ddc8387fdde66366f2af89b3034",
"dep_statement_hashes": {
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af"
},
"combined_sound_fp": "preservation-v1:bc3b92fed5ffbadb9d54199a259d019eec06f646e387ebad459127340712c9ef"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_NormalComponentRefinement.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]P9_T1_ReachedDispatchCall
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Tablet.P9_T1_DispatchCall
import Tablet.P9_T1_ActualDispatchOperations
import Tablet.num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P9_T1_ReachedDispatchCall]
inductive P9_T1_ReachedDispatchCall (s : Str) : P9_T1_DispatchCall -> Prop where
-- BODY
| number (c : Std.U8) (tail : List Std.U8) (body : Slice Std.U8)
(hs : s.val = c :: tail)
(hb : body.val = if c = 45#u8 ∨ c = 43#u8 then tail else s.val)
(hne : body.val ≠ []) :
P9_T1_ReachedDispatchCall s (.number body (c = 45#u8))
| special (body : Slice Std.U8) (neg : Bool)
(hprev : P9_T1_ReachedDispatchCall s (.number body neg))
(h : P9_T1_ActualDispatchOperations.parseNumber body = ok none) :
P9_T1_ReachedDispatchCall s (.special body neg)
| native (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(hprev : P9_T1_ReachedDispatchCall s (.number body neg))
(h : P9_T1_ActualDispatchOperations.parseNumber body = ok (some d)) :
P9_T1_ReachedDispatchCall s (.native body neg d)
| first (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(hprev : P9_T1_ReachedDispatchCall s (.native body neg d))
(h : P9_T1_ActualDispatchOperations.native { d with negative := neg } = ok none) :
P9_T1_ReachedDispatchCall s (.first body neg d)
| increment (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(fp : num.imp.dec2flt.common.BiasedFp)
(hprev : P9_T1_ReachedDispatchCall s (.first body neg d))
(h : P9_T1_ActualDispatchOperations.integer d.exponent d.mantissa = ok fp)
(hguard : d.many_digits = true ∧ 0 <= fp.p_biased.val) :
P9_T1_ReachedDispatchCall s (.increment body neg d fp)
| second (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(fp : num.imp.dec2flt.common.BiasedFp) (next : Std.U64)
(hprev : P9_T1_ReachedDispatchCall s (.increment body neg d fp))
(h : d.mantissa + 1#u64 = ok next) :
P9_T1_ReachedDispatchCall s (.second body neg d fp next)
| compare (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(fp second : num.imp.dec2flt.common.BiasedFp) (next : Std.U64)
(hprev : P9_T1_ReachedDispatchCall s (.second body neg d fp next))
(h : P9_T1_ActualDispatchOperations.integer d.exponent next = ok second) :
P9_T1_ReachedDispatchCall s (.compare body neg d fp second)
| post_direct (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(fp : num.imp.dec2flt.common.BiasedFp)
(hprev : P9_T1_ReachedDispatchCall s (.first body neg d))
(h : P9_T1_ActualDispatchOperations.integer d.exponent d.mantissa = ok fp)
(hguard : ¬ (d.many_digits = true ∧ 0 <= fp.p_biased.val)) :
P9_T1_ReachedDispatchCall s (.post body neg d fp)
| post_compared (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(fp second : num.imp.dec2flt.common.BiasedFp) (equal : Bool)
(hprev : P9_T1_ReachedDispatchCall s (.compare body neg d fp second))
(h : num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq fp second = ok equal) :
P9_T1_ReachedDispatchCall s
(.post body neg d (if equal then fp else { fp with p_biased := (-1)#i32 }))
| slow (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(post : num.imp.dec2flt.common.BiasedFp)
(hprev : P9_T1_ReachedDispatchCall s (.post body neg d post))
(hguard : post.p_biased.val < 0) :
P9_T1_ReachedDispatchCall s (.slow body neg d post)
| assemble_direct (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(post : num.imp.dec2flt.common.BiasedFp)
(hprev : P9_T1_ReachedDispatchCall s (.post body neg d post))
(hguard : 0 <= post.p_biased.val) :
P9_T1_ReachedDispatchCall s (.assemble body neg d post)
| assemble_slow (body : Slice Std.U8) (neg : Bool) (d : num.imp.dec2flt.decimal.Decimal)
(post selected : num.imp.dec2flt.common.BiasedFp)
(hprev : P9_T1_ReachedDispatchCall s (.slow body neg d post))
(h : P9_T1_ActualDispatchOperations.slow body = ok selected) :
P9_T1_ReachedDispatchCall s (.assemble body neg d selected)
| negate (body : Slice Std.U8) (d : num.imp.dec2flt.decimal.Decimal)
(selected : num.imp.dec2flt.common.BiasedFp) (magnitude : F64)
(hprev : P9_T1_ReachedDispatchCall s (.assemble body true d selected))
(h : P9_T1_ActualDispatchOperations.assemble selected = ok magnitude) :
P9_T1_ReachedDispatchCall s (.negate body d selected magnitude)
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
Proof
ok none reaches special;
numeric ok (some d) reaches native on the sign-overwritten record;
native ok none reaches first integer conversion on the original
record exponent and mantissa. Each of these equations concerns a
prior call.Authored arguments for individual requirements
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: number helper record bounds
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
ok none conclusion is not outer failure or divergence;
the direct obligation is not conditioned on a reached or successful call.Requirement: native correct or defer
Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: number helper acceptance
Requirement: number helper rejection
ok none, outer checked failure and divergence
remain distinct outcomes.Requirement: parser exact rounding
Requirement: parser invalid rejection
Requirement: parser numeric acceptance
Requirement: parser totality
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper accumulated value
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
ReachedDispatchCall · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/dispatch-contracts.txt
CURRENT REQUEST-9 SOURCE AND EXTRACTION EVIDENCE
Date: 2026-10-09. This section supersedes predecessor identity records below.
No GOAL classification or source correctness is inferred from these excerpts.
Source/package configuration: modeling-input/SETUP.md and manifest.json.
Transparent extraction scope and all 24 external bindings were inspected with
python3 .trellis/scripts/pv_modeling.py inspect-native .
and checked with python3 .trellis/scripts/pv_modeling.py compose-native . --check.
Composition reports matches=true, changed=false, no mismatched files,
170 frozen extracted modules, 24 bindings, raw extraction SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
This is a composition identity result, not a Lean closure certificate.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: nl -ba upstream/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 let num = s.read_u64();
35 if is_8digits(num) {
36 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
37 s = &s[8..];
38 } else {
39 break;
40 }
41 }
42
43 s = s.parse_digits(|digit| {
44 x = x.wrapping_mul(10).wrapping_add(digit as _);
45 });
46
47 (s, x)
48 }
49
50 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
51 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
52 let mut s = *s_ref;
53
54 while *x < MIN_19DIGIT_INT {
55 if let Some((c, s_next)) = s.split_first() {
56 let digit = c.wrapping_sub(b'0');
57
58 if digit < 10 {
59 *x = (*x * 10) + digit as u64; // no overflows here
60 s = s_next;
61 } else {
62 break;
63 }
64 } else {
65 break;
66 }
67 }
68
69 *s_ref = s;
70 }
71
72 /// Parse the scientific notation component of a float.
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
103 /// significant digits and the decimal exponent.
104 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
105 debug_assert!(!s.is_empty());
106
107 // parse initial digits before dot
108 let mut mantissa = 0_u64;
109 let start = s;
110 let tmp = try_parse_digits(s, mantissa);
111 s = tmp.0;
112 mantissa = tmp.1;
113 let mut n_digits = s.offset_from(start);
114
115 // handle dot with the following digits
116 let mut n_after_dot = 0;
117 let mut exponent = 0_i64;
118 let int_end = s;
119
120 if let Some((&b'.', s_next)) = s.split_first() {
121 s = s_next;
122 let before = s;
123 let tmp = try_parse_digits(s, mantissa);
124 s = tmp.0;
125 mantissa = tmp.1;
126 n_after_dot = s.offset_from(before);
127 exponent = -n_after_dot as i64;
128 }
129
130 n_digits += n_after_dot;
131 if n_digits == 0 {
132 return None;
133 }
134
135 // handle scientific format
136 let mut exp_number = 0_i64;
137 if let Some((&c, s_next)) = s.split_first() {
138 if c == b'e' || c == b'E' {
139 s = s_next;
140 // If None, we have no trailing digits after exponent, or an invalid float.
141 exp_number = parse_scientific(&mut s)?;
142 exponent += exp_number;
143 }
144 }
145
146 let len = s.offset_from(start) as _;
147
148 // handle uncommon case with many digits
149 if n_digits <= 19 {
150 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
151 }
152
153 n_digits -= 19;
154 let mut many_digits = false;
155 let mut p = start;
156 while let Some((&c, p_next)) = p.split_first() {
157 if c == b'.' || c == b'0' {
158 n_digits -= c.saturating_sub(b'0' - 1) as isize;
159 p = p_next;
160 } else {
161 break;
162 }
163 }
164 if n_digits > 0 {
165 // at this point we have more than 19 significant digits, let's try again
166 many_digits = true;
167 mantissa = 0;
168 let mut s = start;
169 try_parse_19digits(&mut s, &mut mantissa);
170 exponent = if mantissa >= MIN_19DIGIT_INT {
171 // big int
172 int_end.offset_from(s)
173 } else {
174 s = &s[1..];
175 let before = s;
176 try_parse_19digits(&mut s, &mut mantissa);
177 -s.offset_from(before)
178 } as i64;
179 // add back the explicit part
180 exponent += exp_number;
181 }
182
183 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
184 }
185
186 /// Try to parse a non-special floating point number,
187 /// as well as two slices with integer and fractional parts
188 /// and the parsed exponent.
189 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
190 if let Some((float, rest)) = parse_partial_number(s) {
191 if rest == s.len() {
192 return Some(float);
193 }
194 }
195 None
196 }
197
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 #[derive(Clone, Debug, PartialEq)]
19 pub struct DecimalSeq {
20 /// The number of significant digits in the decimal.
21 pub num_digits: usize,
22 /// The offset of the decimal point in the significant digits.
23 pub decimal_point: i32,
24 /// If the number of significant digits stored in the decimal is truncated.
25 pub truncated: bool,
26 /// Buffer of the raw digits, in the range [0, 9].
27 pub digits: [u8; Self::MAX_DIGITS],
28 }
29
30 impl Default for DecimalSeq {
31 fn default() -> Self {
32 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
33 }
34 }
35
36 impl DecimalSeq {
37 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
38 ///
39 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
40 ///
41 /// We can exactly represent a float in radix `b` from radix 2 if
42 /// `b` is divisible by 2. This function calculates the exact number of
43 /// digits required to exactly represent that float.
44 ///
45 /// According to the "Handbook of Floating Point Arithmetic",
46 /// for IEEE754, with `emin` being the min exponent, `p2` being the
47 /// precision, and `b` being the radix, the number of digits follows as:
48 ///
49 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
50 ///
51 /// For f32, this follows as:
52 /// emin = -126
53 /// p2 = 24
54 ///
55 /// For f64, this follows as:
56 /// emin = -1022
57 /// p2 = 53
58 ///
59 /// In Python:
60 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
61 pub const MAX_DIGITS: usize = 768;
62
63 /// The max decimal digits that can be exactly represented in a 64-bit integer.
64 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
65 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
66
67 /// Append a digit to the buffer if it fits.
68 // FIXME(tgross35): it may be better for this to return an option
69 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
70 // seems incorrect.
71 pub(super) fn try_add_digit(&mut self, digit: u8) {
72 if self.num_digits < Self::MAX_DIGITS {
73 self.digits[self.num_digits] = digit;
74 }
75 self.num_digits += 1;
76 }
77
78 /// Trim trailing zeros from the buffer.
79 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
80 pub fn trim(&mut self) {
81 // All of the following calls to `DecimalSeq::trim` can't panic because:
82 //
83 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
84 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
85 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
86 //
87 // Trim is only called in `right_shift` and `left_shift`.
88 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
89 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
90 self.num_digits -= 1;
91 }
92 }
93
94 pub(super) fn round(&self) -> u64 {
95 if self.num_digits == 0 || self.decimal_point < 0 {
96 return 0;
97 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
98 return 0xFFFF_FFFF_FFFF_FFFF_u64;
99 }
100
101 let dp = self.decimal_point as usize;
102 let mut n = 0_u64;
103
104 for i in 0..dp {
105 n *= 10;
106 if i < self.num_digits {
107 n += self.digits[i] as u64;
108 }
109 }
110
111 let mut round_up = false;
112
113 if dp < self.num_digits {
114 round_up = self.digits[dp] >= 5;
115 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
116 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
117 }
118 }
119
120 if round_up {
121 n += 1;
122 }
123 n
124 }
125
126 /// Computes decimal * 2^shift.
127 pub(super) fn left_shift(&mut self, shift: usize) {
128 if self.num_digits == 0 {
129 return;
130 }
131 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
132 let mut read_index = self.num_digits;
133 let mut write_index = self.num_digits + num_new_digits;
134 let mut n = 0_u64;
135
136 while read_index != 0 {
137 read_index -= 1;
138 write_index -= 1;
139 n += (self.digits[read_index] as u64) << shift;
140 let quotient = n / 10;
141 let remainder = n - (10 * quotient);
142 if write_index < Self::MAX_DIGITS {
143 self.digits[write_index] = remainder as u8;
144 } else if remainder > 0 {
145 self.truncated = true;
146 }
147 n = quotient;
148 }
149
150 while n > 0 {
151 write_index -= 1;
152 let quotient = n / 10;
153 let remainder = n - (10 * quotient);
154 if write_index < Self::MAX_DIGITS {
155 self.digits[write_index] = remainder as u8;
156 } else if remainder > 0 {
157 self.truncated = true;
158 }
159 n = quotient;
160 }
161
162 self.num_digits += num_new_digits;
163
164 if self.num_digits > Self::MAX_DIGITS {
165 self.num_digits = Self::MAX_DIGITS;
166 }
167
168 self.decimal_point += num_new_digits as i32;
169 self.trim();
170 }
171
172 /// Computes decimal * 2^-shift.
173 pub(super) fn right_shift(&mut self, shift: usize) {
174 let mut read_index = 0;
175 let mut write_index = 0;
176 let mut n = 0_u64;
177 while (n >> shift) == 0 {
178 if read_index < self.num_digits {
179 n = (10 * n) + self.digits[read_index] as u64;
180 read_index += 1;
181 } else if n == 0 {
182 return;
183 } else {
184 while (n >> shift) == 0 {
185 n *= 10;
186 read_index += 1;
187 }
188 break;
189 }
190 }
191 self.decimal_point -= read_index as i32 - 1;
192 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
193 // `self = Self::Default()`, but without the overhead of clearing `digits`.
194 self.num_digits = 0;
195 self.decimal_point = 0;
196 self.truncated = false;
197 return;
198 }
199 let mask = (1_u64 << shift) - 1;
200 while read_index < self.num_digits {
201 let new_digit = (n >> shift) as u8;
202 n = (10 * (n & mask)) + self.digits[read_index] as u64;
203 read_index += 1;
204 self.digits[write_index] = new_digit;
205 write_index += 1;
206 }
207 while n > 0 {
208 let new_digit = (n >> shift) as u8;
209 n = 10 * (n & mask);
210 if write_index < Self::MAX_DIGITS {
211 self.digits[write_index] = new_digit;
212 write_index += 1;
213 } else if new_digit > 0 {
214 self.truncated = true;
215 }
216 }
217 self.num_digits = write_index;
218 self.trim();
219 }
220 }
221
222 /// Combine counts in i64 and clamp before casting to i32.
223 #[inline]
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
305
306 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
307 #[rustfmt::skip]
308 const TABLE: [u16; 65] = [
309 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
310 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
311 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
312 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
313 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
314 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
315 ];
316 #[rustfmt::skip]
317 const TABLE_POW5: [u8; 0x051C] = [
318 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
319 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
320 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
321 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
322 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
323 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
324 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
325 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
326 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
327 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
328 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
329 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
330 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
331 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
332 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
333 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
334 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
335 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
336 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
337 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
338 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
339 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
340 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
341 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
342 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
343 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
344 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
345 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
346 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
347 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
348 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
349 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
350 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
351 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
352 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
353 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
354 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
355 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
356 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
357 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
358 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
359 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
360 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
361 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
362 ];
363
364 shift &= 63;
365 let x_a = TABLE[shift];
366 let x_b = TABLE[shift + 1];
367 let num_new_digits = (x_a >> 11) as _;
368 let pow5_a = (0x7FF & x_a) as usize;
369 let pow5_b = (0x7FF & x_b) as usize;
370 let pow5 = &TABLE_POW5[pow5_a..];
371
372 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
373 if i >= d.num_digits {
374 return num_new_digits - 1;
375 } else if d.digits[i] == p5 {
376 continue;
377 } else if d.digits[i] < p5 {
378 return num_new_digits - 1;
379 } else {
380 return num_new_digits;
381 }
382 }
383
384 num_new_digits
385 }
COMMAND: nl -ba crate/dec2flt/parse.rs
1 //! Functions to parse floating-point numbers.
2
3 use dec2flt::common::{ByteSlice, is_8digits};
4 use dec2flt::decimal::Decimal;
5
6 use crate::num::imp::{Float, dec2flt};
7
8 const MIN_19DIGIT_INT: u64 = 100_0000_0000_0000_0000;
9
10 /// Parse 8 digits, loaded as bytes in little-endian order.
11 ///
12 /// This uses the trick where every digit is in [0x030, 0x39],
13 /// and therefore can be parsed in 3 multiplications, much
14 /// faster than the normal 8.
15 ///
16 /// This is based off the algorithm described in "Fast numeric string to
17 /// int", available here: <https://johnnylee-sde.github.io/Fast-numeric-string-to-int/>.
18 fn parse_8digits(mut v: u64) -> u64 {
19 const MASK: u64 = 0x0000_00FF_0000_00FF;
20 const MUL1: u64 = 0x000F_4240_0000_0064;
21 const MUL2: u64 = 0x0000_2710_0000_0001;
22 v -= 0x3030_3030_3030_3030;
23 v = (v * 10) + (v >> 8); // will not overflow, fits in 63 bits
24 let v1 = (v & MASK).wrapping_mul(MUL1);
25 let v2 = ((v >> 16) & MASK).wrapping_mul(MUL2);
26 ((v1.wrapping_add(v2) >> 32) as u32) as u64
27 }
28
29 /// Parse digits until a non-digit character is found.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {
31 // may cause overflows, to be handled later
32
33 while s.len() >= 8 {
34 // `chunk` is the source's local `num` under a nonconflicting name.
35 // The rename has no Rust effect and prevents the Lean backend from
36 // resolving `num.imp...` as a field projection on this local value.
37 let chunk = s.read_u64();
38 if is_8digits(chunk) {
39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
40 s = &s[8..];
41 } else {
42 break;
43 }
44 }
45
46 // This is the removed `ByteSlice::parse_digits` call specialized to this
47 // accumulator: identical wrapping digit classification, accumulator
48 // update, and first-nondigit stop, without an unsupported closure state.
49 let mut count = 0;
50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
51 let digit = s[count].wrapping_sub(b'0');
52 x = x.wrapping_mul(10).wrapping_add(digit as _);
53 count += 1;
54 }
55 s = &s[count..];
56
57 (s, x)
58 }
59
60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).
61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
62 let mut s = *s_ref;
63
64 while *x < MIN_19DIGIT_INT {
65 if let Some((c, s_next)) = s.split_first() {
66 let digit = c.wrapping_sub(b'0');
67
68 if digit < 10 {
69 *x = (*x * 10) + digit as u64; // no overflows here
70 s = s_next;
71 } else {
72 break;
73 }
74 } else {
75 break;
76 }
77 }
78
79 *s_ref = s;
80 }
81
82 // This is the source prefix scan isolated from `parse_partial_number` because
83 // Aeneas cannot join its loop context while the enclosing function's other
84 // slice borrows are live. It visits the same bytes, in order, and performs
85 // the identical checked `isize` subtraction for every leading dot or zero.
86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
87 let mut scan_index = 0;
88 let mut scanning = true;
89 while scan_index < start.len() && scanning {
90 let c = start[scan_index];
91 if c == b'.' || c == b'0' {
92 n_digits -= c.saturating_sub(b'0' - 1) as isize;
93 scan_index += 1;
94 } else {
95 scanning = false;
96 }
97 }
98 n_digits
99 }
100
101 // This is the source many-digit retry as a transparent helper. Isolating its
102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,
103 // the offset arithmetic, and the explicit-exponent addition are unchanged.
104 fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
105 let mut mantissa = 0;
106 let mut s = start;
107 try_parse_19digits(&mut s, &mut mantissa);
108 let mut exponent = if mantissa >= MIN_19DIGIT_INT {
109 int_end.offset_from(s)
110 } else {
111 s = &s[1..];
112 let before = s;
113 try_parse_19digits(&mut s, &mut mantissa);
114 -s.offset_from(before)
115 } as i64;
116 exponent += exp_number;
117 (mantissa, exponent)
118 }
119
120 /// Parse the scientific notation component of a float.
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
159
160 /// Parse a partial, non-special floating point number.
161 ///
162 /// This creates a representation of the float as the
163 /// significant digits and the decimal exponent.
164 fn parse_partial_number(mut s: &[u8]) -> Option<(Decimal, usize)> {
165 debug_assert!(!s.is_empty());
166
167 // parse initial digits before dot
168 let mut mantissa = 0_u64;
169 let start = s;
170 let tmp = try_parse_digits(s, mantissa);
171 s = tmp.0;
172 mantissa = tmp.1;
173 let mut n_digits = s.offset_from(start);
174
175 // handle dot with the following digits
176 let mut n_after_dot = 0;
177 let mut exponent = 0_i64;
178 let int_end = s;
179
180 if let Some((&b'.', s_next)) = s.split_first() {
181 s = s_next;
182 let before = s;
183 let tmp = try_parse_digits(s, mantissa);
184 s = tmp.0;
185 mantissa = tmp.1;
186 n_after_dot = s.offset_from(before);
187 exponent = -n_after_dot as i64;
188 }
189
190 n_digits += n_after_dot;
191 if n_digits == 0 {
192 return None;
193 }
194
195 // handle scientific format
196 let mut exp_number = 0_i64;
197 if let Some((&c, s_next)) = s.split_first() {
198 if c == b'e' || c == b'E' {
199 s = s_next;
200 // If None, we have no trailing digits after exponent, or an invalid float.
201 exp_number = parse_scientific(&mut s)?;
202 exponent += exp_number;
203 }
204 }
205
206 let len = s.offset_from(start) as _;
207
208 // handle uncommon case with many digits
209 if n_digits <= 19 {
210 return Some((Decimal { exponent, mantissa, negative: false, many_digits: false }, len));
211 }
212
213 n_digits -= 19;
214 let mut many_digits = false;
215 // The indexed loop is equivalent to the source `while let split_first`:
216 // it tests nonemptiness before the same byte read and consumes one byte
217 // only on the two source continuation cases. This avoids Aeneas's loop
218 // context mismatch without changing checked subtraction or slice bounds.
219 n_digits = adjust_many_digit_count(start, n_digits);
220 if n_digits > 0 {
221 // at this point we have more than 19 significant digits, let's try again
222 many_digits = true;
223 let retried = parse_many_digits(start, int_end, exp_number);
224 mantissa = retried.0;
225 exponent = retried.1;
226 }
227
228 Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
229 }
230
231 /// Try to parse a non-special floating point number,
232 /// as well as two slices with integer and fractional parts
233 /// and the parsed exponent.
234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {
235 if let Some((float, rest)) = parse_partial_number(s) {
236 if rest == s.len() {
237 return Some(float);
238 }
239 }
240 None
241 }
242
243 /// Try to parse a special, non-finite float.
244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
245 // Since a valid string has at most the length 8, we can load
246 // all relevant characters into a u64 and work from there.
247 // This also generates much better code.
248
249 let mut register;
250 let len: usize;
251
252 // All valid strings are either of length 8 or 3.
253 if s.len() == 8 {
254 register = s.read_u64();
255 len = 8;
256 } else if s.len() == 3 {
257 let a = s[0] as u64;
258 let b = s[1] as u64;
259 let c = s[2] as u64;
260 register = (c << 16) | (b << 8) | a;
261 len = 3;
262 } else {
263 return None;
264 }
265
266 // Clear out the bits which turn ASCII uppercase characters into
267 // lowercase characters. The resulting string is all uppercase.
268 // What happens to other characters is irrelevant.
269 register &= 0xDFDFDFDFDFDFDFDF;
270
271 // u64 values corresponding to relevant cases
272 const INF_3: u64 = 0x464E49; // "INF"
273 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
274 const NAN: u64 = 0x4E414E; // "NAN"
275
276 // Match register value to constant to parse string.
277 // Also match on the string length to catch edge cases
278 // like "inf\0\0\0\0\0".
279 let float = match (register, len) {
280 (INF_3, 3) => F::INFINITY,
281 (INF_8, 8) => F::INFINITY,
282 (NAN, 3) => F::NAN,
283 _ => return None,
284 };
285
286 if negative { Some(-float) } else { Some(float) }
287 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs
1 //! Arbitrary-precision decimal type used by fallback algorithms.
2 //!
3 //! This is only used if the fast-path (native floats) and
4 //! the Eisel-Lemire algorithm are unable to unambiguously
5 //! determine the float.
6 //!
7 //! The technique used is "Simple Decimal Conversion", developed
8 //! by Nigel Tao and Ken Thompson. A detailed description of the
9 //! algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
10 //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
11
12 use dec2flt::common::{ByteSlice, is_8digits};
13 use dec2flt::parse::parse_scientific;
14
15 use crate::num::imp::dec2flt;
16
17 /// A decimal floating-point number, represented as a sequence of decimal digits.
18 // Debug output is absent from the scoped observations. Removing only that
19 // implementation preserves the representation, Clone/PartialEq behavior, and
20 // every fallback operation independently of GOAL truth.
21 #[derive(Clone, PartialEq)]
22 pub struct DecimalSeq {
23 /// The number of significant digits in the decimal.
24 pub num_digits: usize,
25 /// The offset of the decimal point in the significant digits.
26 pub decimal_point: i32,
27 /// If the number of significant digits stored in the decimal is truncated.
28 pub truncated: bool,
29 /// Buffer of the raw digits, in the range [0, 9].
30 pub digits: [u8; Self::MAX_DIGITS],
31 }
32
33 impl Default for DecimalSeq {
34 fn default() -> Self {
35 Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
36 }
37 }
38
39 impl DecimalSeq {
40 /// The maximum number of digits required to unambiguously round up to a 64-bit float.
41 ///
42 /// For an IEEE 754 binary64 float, this required 767 digits. So we store the max digits + 1.
43 ///
44 /// We can exactly represent a float in radix `b` from radix 2 if
45 /// `b` is divisible by 2. This function calculates the exact number of
46 /// digits required to exactly represent that float.
47 ///
48 /// According to the "Handbook of Floating Point Arithmetic",
49 /// for IEEE754, with `emin` being the min exponent, `p2` being the
50 /// precision, and `b` being the radix, the number of digits follows as:
51 ///
52 /// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
53 ///
54 /// For f32, this follows as:
55 /// emin = -126
56 /// p2 = 24
57 ///
58 /// For f64, this follows as:
59 /// emin = -1022
60 /// p2 = 53
61 ///
62 /// In Python:
63 /// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
64 pub const MAX_DIGITS: usize = 768;
65
66 /// The max decimal digits that can be exactly represented in a 64-bit integer.
67 pub(super) const MAX_DIGITS_WITHOUT_OVERFLOW: usize = 19;
68 pub(super) const DECIMAL_POINT_RANGE: i32 = 2047;
69
70 /// Append a digit to the buffer if it fits.
71 // FIXME(tgross35): it may be better for this to return an option
72 // FIXME(tgross35): incrementing the digit counter even if we don't push anything
73 // seems incorrect.
74 pub(super) fn try_add_digit(&mut self, digit: u8) {
75 if self.num_digits < Self::MAX_DIGITS {
76 self.digits[self.num_digits] = digit;
77 }
78 self.num_digits += 1;
79 }
80
81 /// Trim trailing zeros from the buffer.
82 // FIXME(tgross35): this could be `.rev().position()` if perf is okay
83 pub fn trim(&mut self) {
84 // All of the following calls to `DecimalSeq::trim` can't panic because:
85 //
86 // 1. `parse_decimal` sets `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
87 // 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
88 // 3. `left_shift` `num_digits` to a max of `DecimalSeq::MAX_DIGITS`.
89 //
90 // Trim is only called in `right_shift` and `left_shift`.
91 debug_assert!(self.num_digits <= Self::MAX_DIGITS);
92 while self.num_digits != 0 && self.digits[self.num_digits - 1] == 0 {
93 self.num_digits -= 1;
94 }
95 }
96
97 pub(super) fn round(&self) -> u64 {
98 if self.num_digits == 0 || self.decimal_point < 0 {
99 return 0;
100 } else if self.decimal_point >= Self::MAX_DIGITS_WITHOUT_OVERFLOW as i32 {
101 return 0xFFFF_FFFF_FFFF_FFFF_u64;
102 }
103
104 let dp = self.decimal_point as usize;
105 let mut n = 0_u64;
106
107 for i in 0..dp {
108 n *= 10;
109 if i < self.num_digits {
110 n += self.digits[i] as u64;
111 }
112 }
113
114 let mut round_up = false;
115
116 if dp < self.num_digits {
117 round_up = self.digits[dp] >= 5;
118 if self.digits[dp] == 5 && dp + 1 == self.num_digits {
119 round_up = self.truncated || ((dp != 0) && (1 & self.digits[dp - 1] != 0))
120 }
121 }
122
123 if round_up {
124 n += 1;
125 }
126 n
127 }
128
129 /// Computes decimal * 2^shift.
130 pub(super) fn left_shift(&mut self, shift: usize) {
131 if self.num_digits == 0 {
132 return;
133 }
134 let num_new_digits = number_of_digits_decimal_left_shift(self, shift);
135 let mut read_index = self.num_digits;
136 let mut write_index = self.num_digits + num_new_digits;
137 let mut n = 0_u64;
138
139 while read_index != 0 {
140 read_index -= 1;
141 write_index -= 1;
142 n += (self.digits[read_index] as u64) << shift;
143 let quotient = n / 10;
144 let remainder = n - (10 * quotient);
145 if write_index < Self::MAX_DIGITS {
146 self.digits[write_index] = remainder as u8;
147 } else if remainder > 0 {
148 self.truncated = true;
149 }
150 n = quotient;
151 }
152
153 while n > 0 {
154 write_index -= 1;
155 let quotient = n / 10;
156 let remainder = n - (10 * quotient);
157 if write_index < Self::MAX_DIGITS {
158 self.digits[write_index] = remainder as u8;
159 } else if remainder > 0 {
160 self.truncated = true;
161 }
162 n = quotient;
163 }
164
165 self.num_digits += num_new_digits;
166
167 if self.num_digits > Self::MAX_DIGITS {
168 self.num_digits = Self::MAX_DIGITS;
169 }
170
171 self.decimal_point += num_new_digits as i32;
172 self.trim();
173 }
174
175 /// Computes decimal * 2^-shift.
176 pub(super) fn right_shift(&mut self, shift: usize) {
177 let mut read_index = 0;
178 let mut write_index = 0;
179 let mut n = 0_u64;
180 let mut all_zero = false;
181 while (n >> shift) == 0 && !all_zero {
182 if read_index < self.num_digits {
183 n = (10 * n) + self.digits[read_index] as u64;
184 read_index += 1;
185 } else if n == 0 {
186 // The source returns here from inside the loop. Recording the
187 // condition and returning immediately after the loop executes
188 // no intervening operation and preserves the unchanged value.
189 all_zero = true;
190 } else {
191 while (n >> shift) == 0 {
192 n *= 10;
193 read_index += 1;
194 }
195 break;
196 }
197 }
198 if all_zero {
199 return;
200 }
201 self.decimal_point -= read_index as i32 - 1;
202 if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
203 // `self = Self::Default()`, but without the overhead of clearing `digits`.
204 self.num_digits = 0;
205 self.decimal_point = 0;
206 self.truncated = false;
207 return;
208 }
209 let mask = (1_u64 << shift) - 1;
210 while read_index < self.num_digits {
211 let new_digit = (n >> shift) as u8;
212 n = (10 * (n & mask)) + self.digits[read_index] as u64;
213 read_index += 1;
214 self.digits[write_index] = new_digit;
215 write_index += 1;
216 }
217 while n > 0 {
218 let new_digit = (n >> shift) as u8;
219 n = 10 * (n & mask);
220 if write_index < Self::MAX_DIGITS {
221 self.digits[write_index] = new_digit;
222 write_index += 1;
223 } else if new_digit > 0 {
224 self.truncated = true;
225 }
226 }
227 self.num_digits = write_index;
228 self.trim();
229 }
230 }
231
232 // This is exactly the source reverse scan over the already-consumed prefix.
233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
234 // retains its other slice borrows. The downward index has the same visitation
235 // order and counts precisely the same zero bytes while ignoring dots.
236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
237 let mut n_trailing_zeros = 0;
238 let mut i = consumed_len;
239 let mut scanning = true;
240 while i != 0 && scanning {
241 let c = start[i - 1];
242 if c == b'0' || c == b'.' {
243 i -= 1;
244 if c == b'0' {
245 n_trailing_zeros += 1;
246 }
247 } else {
248 scanning = false;
249 }
250 }
251 n_trailing_zeros
252 }
253
254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
255 // An explicit index keeps the closure's mutable borrow out of the enclosing
256 // parser context while retaining the same wrapping digit test and updates.
257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
258 let mut count = 0;
259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
260 let digit = s[count].wrapping_sub(b'0');
261 d.try_add_digit(digit);
262 count += 1;
263 }
264 &s[count..]
265 }
266
267 /// Combine counts in i64 and clamp before casting to i32.
268 #[inline]
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
374
375 fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usize {
376 #[rustfmt::skip]
377 const TABLE: [u16; 65] = [
378 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
379 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, 0x3073, 0x3080, 0x388E, 0x389C,
380 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169,
381 0x5180, 0x5998, 0x59B0, 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B,
382 0x72AA, 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, 0x8C02,
383 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, 0x051C, 0x051C,
384 ];
385 #[rustfmt::skip]
386 const TABLE_POW5: [u8; 0x051C] = [
387 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9, 0, 6, 2, 5, 1,
388 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5,
389 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2,
390 5, 1, 5, 2, 5, 8, 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6,
391 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,
392 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9,
393 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6,
394 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1,
395 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2,
396 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,
397 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5,
398 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2,
399 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5,
400 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4,
401 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,
402 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0,
403 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, 0, 3, 1, 2, 5, 3,
404 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8,
405 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4,
406 7, 0, 1, 7, 7, 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,
407 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3, 7, 3, 6, 7, 5,
408 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7,
409 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8,
410 8, 6, 0, 8, 0, 8, 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0,
411 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,
412 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1,
413 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2,
414 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8,
415 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0,
416 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,
417 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2,
418 6, 1, 6, 1, 6, 9, 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4,
419 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1,
420 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8,
421 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,
422 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1,
423 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, 3, 8, 7, 7, 7, 8,
424 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0,
425 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2,
426 5, 5, 6, 7, 6, 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,
427 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1, 7, 3, 4, 7, 2,
428 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3,
429 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2,
430 2, 4, 0, 6, 9, 5, 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5,
431 ];
432
433 shift &= 63;
434 let x_a = TABLE[shift];
435 let x_b = TABLE[shift + 1];
436 let num_new_digits = (x_a >> 11) as _;
437 let pow5_a = (0x7FF & x_a) as usize;
438 let pow5_b = (0x7FF & x_b) as usize;
439 let pow5 = &TABLE_POW5[pow5_a..];
440
441 for (i, &p5) in pow5.iter().enumerate().take(pow5_b - pow5_a) {
442 if i >= d.num_digits {
443 return num_new_digits - 1;
444 } else if d.digits[i] == p5 {
445 continue;
446 } else if d.digits[i] < p5 {
447 return num_new_digits - 1;
448 } else {
449 return num_new_digits;
450 }
451 }
452
453 num_new_digits
454 }
COMMAND: nl -ba upstream/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64 = {
119 let log2_5 = f64::consts::LOG2_10 - 1.0;
120 (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
121 };
122
123 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
124 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
125
126 /// Maximum exponent that can be represented for a disguised-fast path case.
127 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
128 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
129 Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
130
131 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
132 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
133
134 /// Gets a small power-of-ten for fast-path multiplication.
135 fn pow10_fast_path(exponent: usize) -> Self;
136
137 /// Converts integer into float through an as cast.
138 /// This is only called in the fast-path algorithm, and therefore
139 /// will not lose precision, since the value will always have
140 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
141 fn from_u64(v: u64) -> Self;
142 }
143
144 #[cfg(target_has_reliable_f16)]
145 impl Lemire for f16 {
146 fn pow10_fast_path(exponent: usize) -> Self {
147 #[allow(clippy::use_self)]
148 const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
149 TABLE[exponent & 7]
150 }
151
152 #[inline]
153 fn from_u64(v: u64) -> Self {
154 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
155 v as _
156 }
157 }
158
159 impl Lemire for f32 {
160 fn pow10_fast_path(exponent: usize) -> Self {
161 #[allow(clippy::use_self)]
162 const TABLE: [f32; 16] =
163 [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
164 TABLE[exponent & 15]
165 }
166
167 #[inline]
168 fn from_u64(v: u64) -> Self {
169 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
170 v as _
171 }
172 }
173
174 impl Lemire for f64 {
175 fn pow10_fast_path(exponent: usize) -> Self {
176 const TABLE: [f64; 32] = [
177 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
178 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
179 ];
180 TABLE[exponent & 31]
181 }
182
183 #[inline]
184 fn from_u64(v: u64) -> Self {
185 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
186 v as _
187 }
188 }
189
190 #[inline]
191 pub(super) fn pfe_empty() -> ParseFloatError {
192 ParseFloatError { kind: FloatErrorKind::Empty }
193 }
194
195 // Used in unit tests, keep public.
196 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
197 #[inline]
198 pub fn pfe_invalid() -> ParseFloatError {
199 ParseFloatError { kind: FloatErrorKind::Invalid }
200 }
201
202 /// Converts a `BiasedFp` to the closest machine float type.
203 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
204 let mut word = x.m;
205 word |= (x.p_biased as u64) << F::SIG_BITS;
206 F::from_u64_bits(word)
207 }
208
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
256 }
COMMAND: nl -ba crate/dec2flt/mod.rs
1 //! Converting decimal strings into IEEE 754 binary floating point numbers.
2 //!
3 //! # Problem statement
4 //!
5 //! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
6 //! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as a
7 //! default value (1 or 0) when missing.
8 //!
9 //! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
10 //! string. It is well-known that many decimal strings do not have terminating representations in
11 //! base two, so we round to 0.5 units in the last place (in other words, as well as possible).
12 //! Ties, decimal values exactly half-way between two consecutive floats, are resolved with the
13 //! half-to-even strategy, also known as banker's rounding.
14 //!
15 //! Needless to say, this is quite hard, both in terms of implementation complexity and in terms
16 //! of CPU cycles taken.
17 //!
18 //! # Implementation
19 //!
20 //! First, we ignore signs. Or rather, we remove it at the very beginning of the conversion
21 //! process and re-apply it at the very end. This is correct in all edge cases since IEEE
22 //! floats are symmetric around zero, negating one simply flips the first bit.
23 //!
24 //! Then we remove the decimal point by adjusting the exponent: Conceptually, `12.34e56` turns
25 //! into `1234e54`, which we describe with a positive integer `f = 1234` and an integer `e = 54`.
26 //! The `(f, e)` representation is used by almost all code past the parsing stage.
27 //!
28 //! We then try a long chain of progressively more general and expensive special cases using
29 //! machine-sized integers and small, fixed-sized floating point numbers (first `f32`/`f64`, then
30 //! a type with 64 bit significand). The extended-precision algorithm
31 //! uses the Eisel-Lemire algorithm, which uses a 128-bit (or 192-bit)
32 //! representation that can accurately and quickly compute the vast majority
33 //! of floats. When all these fail, we bite the bullet and resort to using
34 //! a large-decimal representation, shifting the digits into range, calculating
35 //! the upper significant bits and exactly round to the nearest representation.
36 //!
37 //! Another aspect that needs attention is the ``RawFloat`` trait by which almost all functions
38 //! are parametrized. One might think that it's enough to parse to `f64` and cast the result to
39 //! `f32`. Unfortunately this is not the world we live in, and this has nothing to do with using
40 //! base two or half-to-even rounding.
41 //!
42 //! Consider for example two types `d2` and `d4` representing a decimal type with two decimal
43 //! digits and four decimal digits each and take "0.01499" as input. Let's use half-up rounding.
44 //! Going directly to two decimal digits gives `0.01`, but if we round to four digits first,
45 //! we get `0.0150`, which is then rounded up to `0.02`. The same principle applies to other
46 //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision
47 //! and round *exactly once, at the end*, by considering all truncated bits at once.
48 //!
49 //! Primarily, this module and its children implement the algorithms described in:
50 //! "Number Parsing at a Gigabyte per Second", available online:
51 //! <https://arxiv.org/abs/2101.11408>.
52 //!
53 //! # Other
54 //!
55 //! The conversion should *never* panic. There are assertions and explicit panics in the code,
56 //! but they should never be triggered and only serve as internal sanity checks. Any panics should
57 //! be considered a bug.
58 //!
59 //! There are unit tests but they are woefully inadequate at ensuring correctness, they only cover
60 //! a small percentage of possible errors. Far more extensive tests are located in the directory
61 //! `src/tools/test-float-parse` as a Rust program.
62 //!
63 //! A note on integer overflow: Many parts of this file perform arithmetic with the decimal
64 //! exponent `e`. Primarily, we shift the decimal point around: Before the first decimal digit,
65 //! after the last decimal digit, and so on. This could overflow if done carelessly. We rely on
66 //! the parsing submodule to only hand out sufficiently small exponents, where "sufficient" means
67 //! "such that the exponent +/- the number of decimal digits fits into a 64 bit integer".
68 //! Larger exponents are accepted, but we don't do arithmetic with them, they are immediately
69 //! turned into {positive,negative} {zero,infinity}.
70 //!
71 //! # Notation
72 //!
73 //! This module uses the same notation as the Lemire paper:
74 //!
75 //! - `m`: binary mantissa; always nonnegative
76 //! - `p`: binary exponent; a signed integer
77 //! - `w`: decimal significand; always nonnegative
78 //! - `q`: decimal exponent; a signed integer
79 //!
80 //! This gives `m * 2^p` for the binary floating-point number, with `w * 10^q` as the decimal
81 //! equivalent.
82
83 #![doc(hidden)]
84 #![unstable(
85 feature = "dec2flt",
86 reason = "internal routines only exposed for testing",
87 issue = "none"
88 )]
89
90 pub use common::BiasedFp;
91 use lemire::compute_float;
92 use parse::{parse_inf_nan, parse_number};
93 use slow::parse_long_mantissa;
94
95 use crate::f64;
96 use crate::num::ParseFloatError;
97 use crate::num::float_parse::FloatErrorKind;
98 use crate::num::imp::FloatExt;
99
100 mod common;
101 pub mod decimal;
102 pub mod decimal_seq;
103 mod fpu;
104 pub mod lemire;
105 pub mod parse;
106 mod slow;
107 mod table;
108
109 /// Extension to `Float` that are necessary for parsing using the Lemire method.
110 ///
111 /// See the parent module's doc comment for why this is necessary.
112 ///
113 /// Not intended for use outside of the `dec2flt` module.
114 #[doc(hidden)]
115 pub trait Lemire: FloatExt {
116 /// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
117 // assuming FLT_EVAL_METHOD = 0
118 const MAX_EXPONENT_FAST_PATH: i64;
119
120 /// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
121 const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
122
123 /// Maximum exponent that can be represented for a disguised-fast path case.
124 /// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
125 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
126
127 /// Maximum mantissa for the fast-path (`1 << 53` for f64).
128 const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
129
130 /// Gets a small power-of-ten for fast-path multiplication.
131 fn pow10_fast_path(exponent: usize) -> Self;
132
133 /// Converts integer into float through an as cast.
134 /// This is only called in the fast-path algorithm, and therefore
135 /// will not lose precision, since the value will always have
136 /// only if the value is <= Self::MAX_MANTISSA_FAST_PATH.
137 fn from_u64(v: u64) -> Self;
138 }
139
140 #[cfg(target_has_reliable_f16)]
141 // The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
142 // leaves every retained f64 parser/helper/trace body, native decision, checked
143 // operation, debug assertion, return value, and scoped observation unchanged.
144 #[cfg(any())]
145 impl Lemire for f16 {
146 // These are the exact integer results of the upstream compile-time float
147 // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
148 // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
149 // float arithmetic without changing either fast-path guard.
150 const MAX_EXPONENT_FAST_PATH: i64 = 4;
151 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
152
153 fn pow10_fast_path(exponent: usize) -> Self {
154 // Each integer is the exact IEEE encoding of the corresponding
155 // upstream table literal; the masked lookup and fallback zeros are
156 // unchanged. Aeneas cannot translate arrays containing float values.
157 match exponent & 7 {
158 0 => f16::from_bits(0x3C00),
159 1 => f16::from_bits(0x4900),
160 2 => f16::from_bits(0x5640),
161 3 => f16::from_bits(0x63D0),
162 4 => f16::from_bits(0x70E2),
163 _ => f16::from_bits(0),
164 }
165 }
166
167 #[inline]
168 // This method is exactly the upstream primitive `u64 as f16` conversion.
169 // Charon extracts the cast, but Aeneas reports it unreachable; making only
170 // this primitive boundary opaque preserves all guards and dispatcher logic.
171 #[charon::opaque]
172 fn from_u64(v: u64) -> Self {
173 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
174 v as _
175 }
176 }
177
178 // The f32 Lemire instance is likewise unused by the retained f64
179 // specialization, so disabling it cannot affect any retained body or observed
180 // f64 execution independently of the correctness GOALs.
181 #[cfg(any())]
182 impl Lemire for f32 {
183 // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
184 const MAX_EXPONENT_FAST_PATH: i64 = 10;
185 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
186
187 fn pow10_fast_path(exponent: usize) -> Self {
188 // Bit constructors preserve the exact table values and masked lookup,
189 // while avoiding Aeneas's unsupported float-valued array constants.
190 match exponent & 15 {
191 0 => f32::from_bits(0x3F80_0000),
192 1 => f32::from_bits(0x4120_0000),
193 2 => f32::from_bits(0x42C8_0000),
194 3 => f32::from_bits(0x447A_0000),
195 4 => f32::from_bits(0x461C_4000),
196 5 => f32::from_bits(0x47C3_5000),
197 6 => f32::from_bits(0x4974_2400),
198 7 => f32::from_bits(0x4B18_9680),
199 8 => f32::from_bits(0x4CBE_BC20),
200 9 => f32::from_bits(0x4E6E_6B28),
201 10 => f32::from_bits(0x5015_02F9),
202 _ => f32::from_bits(0),
203 }
204 }
205
206 #[inline]
207 // This is exactly the source `u64 as f32` conversion. The narrow opaque
208 // boundary is required because Aeneas rejects the primitive cast itself;
209 // its input guard and every caller remain transparent.
210 #[charon::opaque]
211 fn from_u64(v: u64) -> Self {
212 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
213 v as _
214 }
215 }
216
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
268
269 #[inline]
270 pub(super) fn pfe_empty() -> ParseFloatError {
271 ParseFloatError { kind: FloatErrorKind::Empty }
272 }
273
274 // Used in unit tests, keep public.
275 // This is much better than making FloatErrorKind and ParseFloatError::kind public.
276 #[inline]
277 pub fn pfe_invalid() -> ParseFloatError {
278 ParseFloatError { kind: FloatErrorKind::Invalid }
279 }
280
281 /// Converts a `BiasedFp` to the closest machine float type.
282 fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
283 let mut word = x.m;
284 word |= (x.p_biased as u64) << F::SIG_BITS;
285 F::from_u64_bits(word)
286 }
287
288 /// Observable control-flow record for a dispatcher execution.
289 ///
290 /// These variants add no decisions to the conversion: each stores values
291 /// already computed at the corresponding source branch. In particular, the
292 /// first component returned by `dec2flt_with_trace` is the ordinary parser
293 /// result, so projecting it preserves every public source observation without
294 /// assuming any correctness goal.
295 pub enum Dec2FltTrace<'a, F> {
296 /// The original string was empty; no helper was called.
297 EmptyInput,
298 /// Removing one lexical sign left an empty body; no helper was called.
299 SignOnly { body: &'a [u8], negative: bool },
300 /// Both lexical helpers returned `None`; no raw pair was selected.
301 Invalid {
302 body: &'a [u8],
303 negative: bool,
304 parse_number_result: Option<decimal::Decimal>,
305 parse_inf_nan_result: Option<F>,
306 },
307 /// The special helper supplied the directly returned value; no pair was selected.
308 Special {
309 body: &'a [u8],
310 negative: bool,
311 parse_number_result: Option<decimal::Decimal>,
312 parse_inf_nan_result: Option<F>,
313 result: F,
314 },
315 /// The ordinary native shortcut supplied the directly returned value.
316 FastPath {
317 body: &'a [u8],
318 negative: bool,
319 parse_number_result: Option<decimal::Decimal>,
320 fast_path_input: decimal::Decimal,
321 fast_path_result: Option<F>,
322 result: F,
323 },
324 /// The integer/slow path selected and assembled one raw pair.
325 Assembled(Dec2FltAssemblyTrace<'a, F>),
326 }
327
328 /// Full observation record for the dispatcher path that performs final assembly.
329 pub struct Dec2FltAssemblyTrace<'a, F> {
330 pub body: &'a [u8],
331 pub negative: bool,
332 pub parse_number_result: Option<decimal::Decimal>,
333 pub fast_path_input: decimal::Decimal,
334 pub fast_path_result: Option<F>,
335 pub first_compute_exponent: i64,
336 pub first_compute_mantissa: u64,
337 pub first_compute_result: BiasedFp,
338 pub second_compute_guard: bool,
339 pub second_compute_exponent: Option<i64>,
340 pub second_compute_mantissa: Option<u64>,
341 pub second_compute_result: Option<BiasedFp>,
342 pub second_equals_first: Option<bool>,
343 pub forced_deferral: bool,
344 pub post_comparison_pair: BiasedFp,
345 pub slow_path_guard: bool,
346 pub slow_path_result: Option<BiasedFp>,
347 pub selected_pair: BiasedFp,
348 pub assembled_word: u64,
349 pub assembly_result: F,
350 pub lexical_sign_applied: bool,
351 pub result: F,
352 }
353
354 /// Run the actual dispatcher while retaining its goal-relevant internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
HISTORICAL PREDECESSOR RECORDS BELOW, NOT CURRENT-SOURCE SUPPORT
Dispatcher contract and trace evidence
Files inspected (SHA-256 from sha256sum 9.1):
upstream/dec2flt/mod.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
upstream/dec2flt/parse.rs
9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean
fc6b6d0c31c801820e9e1981a1a777701b6a70dac0892b22ace44edbca4eeeb7
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
e1021975d4efe22771953025dd5145bc3f1305f2046a4cf20790ff9ff633c520
Reproduction commands:
sha256sum upstream/dec2flt/mod.rs crate/dec2flt/mod.rs \
upstream/dec2flt/parse.rs crate/dec2flt/parse.rs \
Tablet/num_imp_dec2flt_dec2flt_with_trace.lean \
Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean
nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
Raw source observations:
upstream lines 212-225 convert the string to bytes, strip at most one leading
sign, reject an empty body, call parse_number first, and call parse_inf_nan
only after parse_number returns None.
upstream lines 227-232 overwrite Decimal.negative with the lexical sign and
return a Some result from try_fast_path directly.
upstream lines 238-249 call compute_float(exponent, mantissa), call
compute_float(exponent, mantissa + 1) exactly when many_digits and the first
biased exponent is nonnegative, set that exponent to -1 on disagreement, and
replace every negative-exponent current pair with parse_long_mantissa(body).
upstream lines 251-255 assemble the selected pair, negate only after
assembly when Decimal.negative is true, and return the resulting float.
upstream parse.rs lines 199-241 show the special helper's length branches,
register construction and masking, keyword match, and final sign branch.
They locate the helper body called by the dispatcher; this excerpt alone is
not used to establish a DispatchContracts semantic law.
Raw adapted-source observations:
crate lines 354-504 are the traced dispatcher. Its sign/body and lexical
branches are lines 364-403; the native call and direct return are lines
405-421; and integer calls, comparison/deferral, slow fallback, assembly,
final sign, and trace construction are lines 424-503. These lines record
branch order, call boundaries, and already-computed observations; they do not
establish the semantic contracts of the called helpers.
crate lines 506-523 define the public dispatcher as the first projection of
the one traced implementation, with the projection call at line 522.
crate parse.rs lines 241-283 retain that special-parser control structure:
the same length split, case mask, three constants and matches, rejection
branch, selected branch value, and final sign branch appear at lines 249-283.
Concrete satisfaction of the abstract special-parser laws is not inferred
from this syntactic comparison.
Raw extracted-model observations:
num_imp_dec2flt_dec2flt_with_trace.lean lines 36-77 retain the sign-removal,
empty/sign-only, parse_number, parse_inf_nan, invalid, and special branches.
Lines 78-115 retain the native call, first integer call, exact second-call
guard, checked U64 addition, second call, equality comparison, and exponent
-1 update. Lines 116-194 retain the slow replacement, Rust cast/shift/OR
assembled word, biased_fp_to_float call, optional negation, and every trace
field in both sign branches.
num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 list, in order, the
body and sign; parsed and fast-path values; first and second integer values;
comparison and deferral values; post-comparison, slow, and selected pairs;
and assembly, sign, and final-result values used by the paired contracts.
Scope of this evidence:
The excerpts below support only branch order, helper call boundaries, the
observations recorded by the trace, and the fact that public dec2flt projects
the result of the single traced computation. Seeing a helper call or its
source body is not evidence that the extracted helper returns normally or
satisfies a DispatchContracts semantic law. Those facts belong to the
separate dispatch_component_compliance obligation.
Captured excerpts (command output, with trailing whitespace removed):
--- upstream/dec2flt/mod.rs lines 209-255 ---
$ nl -ba upstream/dec2flt/mod.rs | sed -n '209,255p'
209 /// Converts a decimal string into a floating point number.
210 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
211 pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
212 let mut s = s.as_bytes();
213 let Some(&c) = s.first() else { return Err(pfe_empty()) };
214 let negative = c == b'-';
215 if c == b'-' || c == b'+' {
216 s = &s[1..];
217 }
218 if s.is_empty() {
219 return Err(pfe_invalid());
220 }
221
222 let mut num = match parse_number(s) {
223 Some(r) => r,
224 None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
225 None => return Err(pfe_invalid()),
226 };
227 num.negative = negative;
228 if !cfg!(feature = "optimize_for_size") {
229 if let Some(value) = num.try_fast_path::<F>() {
230 return Ok(value);
231 }
232 }
233
234 // If significant digits were truncated, then we can have rounding error
235 // only if `mantissa + 1` produces a different result. We also avoid
236 // redundantly using the Eisel-Lemire algorithm if it was unable to
237 // correctly round on the first pass.
238 let mut fp = compute_float::<F>(num.exponent, num.mantissa);
239 if num.many_digits
240 && fp.p_biased >= 0
241 && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
242 {
243 fp.p_biased = -1;
244 }
245 // Unable to correctly round the float using the Eisel-Lemire algorithm.
246 // Fallback to a slower, but always correct algorithm.
247 if fp.p_biased < 0 {
248 fp = parse_long_mantissa::<F>(s);
249 }
250
251 let mut float = biased_fp_to_float::<F>(fp);
252 if num.negative {
253 float = -float;
254 }
255 Ok(float)
--- crate/dec2flt/mod.rs lines 354-523 ---
$ nl -ba crate/dec2flt/mod.rs | sed -n '354,523p'
354 /// Run the actual dispatcher while retaining its approved internal observations.
355 pub fn dec2flt_with_trace<
356 'a,
357 F: Lemire
358 + core::ops::Div<Output = F>
359 + core::ops::Mul<Output = F>
360 + core::ops::Neg<Output = F>,
361 >(
362 s: &'a str,
363 ) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
364 let mut body = s.as_bytes();
365 let Some(&c) = body.first() else {
366 return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
367 };
368 let negative = c == b'-';
369 if c == b'-' || c == b'+' {
370 body = &body[1..];
371 }
372 if body.is_empty() {
373 return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
374 }
375
376 let parse_number_result = parse_number(body);
377 let parsed = match parse_number_result {
378 Some(r) => r,
379 None => {
380 let parse_inf_nan_result = parse_inf_nan(body, negative);
381 return match parse_inf_nan_result {
382 Some(value) => (
383 Ok(value),
384 Dec2FltTrace::Special {
385 body,
386 negative,
387 parse_number_result,
388 parse_inf_nan_result,
389 result: value,
390 },
391 ),
392 None => (
393 Err(pfe_invalid()),
394 Dec2FltTrace::Invalid {
395 body,
396 negative,
397 parse_number_result,
398 parse_inf_nan_result,
399 },
400 ),
401 };
402 }
403 };
404
405 let mut num = parsed;
406 num.negative = negative;
407 if !cfg!(feature = "optimize_for_size") {
408 let fast_path_result = num.try_fast_path::<F>();
409 if let Some(value) = fast_path_result {
410 return (
411 Ok(value),
412 Dec2FltTrace::FastPath {
413 body,
414 negative,
415 parse_number_result,
416 fast_path_input: num,
417 fast_path_result,
418 result: value,
419 },
420 );
421 }
422 }
423
424 let first_compute_exponent = num.exponent;
425 let first_compute_mantissa = num.mantissa;
426 let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
427 let mut fp = first_compute_result;
428
429 // This expands the source short-circuit conjunction without moving the
430 // checked `mantissa + 1`: that addition and the second helper call still
431 // occur exactly when `many_digits && fp.p_biased >= 0`.
432 let second_compute_guard = num.many_digits && fp.p_biased >= 0;
433 let mut second_compute_exponent = None;
434 let mut second_compute_mantissa = None;
435 let mut second_compute_result = None;
436 let mut second_equals_first = None;
437 let mut forced_deferral = false;
438 if second_compute_guard {
439 let exponent = num.exponent;
440 let mantissa = num.mantissa + 1;
441 let second = compute_float::<F>(exponent, mantissa);
442 let equal = fp == second;
443 second_compute_exponent = Some(exponent);
444 second_compute_mantissa = Some(mantissa);
445 second_compute_result = Some(second);
446 second_equals_first = Some(equal);
447 if !equal {
448 fp.p_biased = -1;
449 forced_deferral = true;
450 }
451 }
452 let post_comparison_pair = fp;
453
454 let slow_path_guard = fp.p_biased < 0;
455 let mut slow_path_result = None;
456 if slow_path_guard {
457 // The exact slow-path input is the trace's common `body`; the guard
458 // records whether this call occurred, avoiding a duplicate live slice
459 // reference that Aeneas cannot join across this branch.
460 let replacement = parse_long_mantissa::<F>(body);
461 slow_path_result = Some(replacement);
462 fp = replacement;
463 }
464
465 let selected_pair = fp;
466 // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
467 // it neither changes the selected pair nor introduces a new branch or call.
468 let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
469 let assembly_result = biased_fp_to_float::<F>(fp);
470 let lexical_sign_applied = num.negative;
471 let result = if lexical_sign_applied {
472 core::ops::Neg::neg(assembly_result)
473 } else {
474 assembly_result
475 };
476
477 (
478 Ok(result),
479 Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
480 body,
481 negative,
482 parse_number_result,
483 fast_path_input: num,
484 fast_path_result: None,
485 first_compute_exponent,
486 first_compute_mantissa,
487 first_compute_result,
488 second_compute_guard,
489 second_compute_exponent,
490 second_compute_mantissa,
491 second_compute_result,
492 second_equals_first,
493 forced_deferral,
494 post_comparison_pair,
495 slow_path_guard,
496 slow_path_result,
497 selected_pair,
498 assembled_word,
499 assembly_result,
500 lexical_sign_applied,
501 result,
502 }),
503 )
504 }
505
506 /// Converts a decimal string into a floating point number.
507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
508 pub fn dec2flt<
509 F: Lemire
510 + core::ops::Div<Output = F>
511 + core::ops::Mul<Output = F>
512 + core::ops::Neg<Output = F>,
513 >(
514 s: &str,
515 ) -> Result<F, ParseFloatError> {
516 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
517 // clause admits exactly the same instances and lets Charon resolve the
518 // explicit, source-equivalent final negation.
519 // The public function is now exactly the result projection of the single
520 // instrumented implementation. No conversion step is duplicated, and
521 // discarding the trace cannot affect Rust evaluation or the returned bits.
522 dec2flt_with_trace::<F>(s).0
523 }
--- upstream/dec2flt/parse.rs lines 198-242 ---
$ nl -ba upstream/dec2flt/parse.rs | sed -n '198,242p'
198 /// Try to parse a special, non-finite float.
199 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
200 // Since a valid string has at most the length 8, we can load
201 // all relevant characters into a u64 and work from there.
202 // This also generates much better code.
203
204 let mut register;
205 let len: usize;
206
207 // All valid strings are either of length 8 or 3.
208 if s.len() == 8 {
209 register = s.read_u64();
210 len = 8;
211 } else if s.len() == 3 {
212 let a = s[0] as u64;
213 let b = s[1] as u64;
214 let c = s[2] as u64;
215 register = (c << 16) | (b << 8) | a;
216 len = 3;
217 } else {
218 return None;
219 }
220
221 // Clear out the bits which turn ASCII uppercase characters into
222 // lowercase characters. The resulting string is all uppercase.
223 // What happens to other characters is irrelevant.
224 register &= 0xDFDFDFDFDFDFDFDF;
225
226 // u64 values corresponding to relevant cases
227 const INF_3: u64 = 0x464E49; // "INF"
228 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
229 const NAN: u64 = 0x4E414E; // "NAN"
230
231 // Match register value to constant to parse string.
232 // Also match on the string length to catch edge cases
233 // like "inf\0\0\0\0\0".
234 let float = match (register, len) {
235 (INF_3, 3) => F::INFINITY,
236 (INF_8, 8) => F::INFINITY,
237 (NAN, 3) => F::NAN,
238 _ => return None,
239 };
240
241 if negative { Some(-float) } else { Some(float) }
242 }
--- crate/dec2flt/parse.rs lines 240-284 ---
$ nl -ba crate/dec2flt/parse.rs | sed -n '240,284p'
240 /// Try to parse a special, non-finite float.
241 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {
242 // Since a valid string has at most the length 8, we can load
243 // all relevant characters into a u64 and work from there.
244 // This also generates much better code.
245
246 let mut register;
247 let len: usize;
248
249 // All valid strings are either of length 8 or 3.
250 if s.len() == 8 {
251 register = s.read_u64();
252 len = 8;
253 } else if s.len() == 3 {
254 let a = s[0] as u64;
255 let b = s[1] as u64;
256 let c = s[2] as u64;
257 register = (c << 16) | (b << 8) | a;
258 len = 3;
259 } else {
260 return None;
261 }
262
263 // Clear out the bits which turn ASCII uppercase characters into
264 // lowercase characters. The resulting string is all uppercase.
265 // What happens to other characters is irrelevant.
266 register &= 0xDFDFDFDFDFDFDFDF;
267
268 // u64 values corresponding to relevant cases
269 const INF_3: u64 = 0x464E49; // "INF"
270 const INF_8: u64 = 0x5954494E49464E49; // "INFINITY"
271 const NAN: u64 = 0x4E414E; // "NAN"
272
273 // Match register value to constant to parse string.
274 // Also match on the string length to catch edge cases
275 // like "inf\0\0\0\0\0".
276 let float = match (register, len) {
277 (INF_3, 3) => F::INFINITY,
278 (INF_8, 8) => F::INFINITY,
279 (NAN, 3) => F::NAN,
280 _ => return None,
281 };
282
283 if negative { Some(-float) } else { Some(float) }
284 }
--- Tablet/num_imp_dec2flt_dec2flt_with_trace.lean lines 36-194 ---
$ nl -ba Tablet/num_imp_dec2flt_dec2flt_with_trace.lean | sed -n '36,194p'
36 do
37 let body ← core.str.Str.as_bytes s
38 let o ← core.slice.Slice.first body
39 match o with
40 | none =>
41 let pfe ← num.imp.dec2flt.pfe_empty
42 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.EmptyInput)
43 | some c =>
44 let body1 ←
45 if c = 45#u8
46 then
47 core.slice.index.Slice.index
48 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
49 { start := 1#usize }
50 else
51 if c = 43#u8
52 then
53 core.slice.index.Slice.index
54 (core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) body
55 { start := 1#usize }
56 else ok body
57 let b ← core.slice.Slice.is_empty body1
58 if b
59 then
60 let pfe ← num.imp.dec2flt.pfe_invalid
61 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.SignOnly
62 body1 (c = 45#u8))
63 else
64 let parse_number_result ← num.imp.dec2flt.parse.parse_number body1
65 match parse_number_result with
66 | none =>
67 let parse_inf_nan_result ←
68 num.imp.dec2flt.parse.parse_inf_nan
69 LemireInst.traitsFloatExtInst.FloatInst body1 (c = 45#u8)
70 match parse_inf_nan_result with
71 | none =>
72 let pfe ← num.imp.dec2flt.pfe_invalid
73 ok (core.result.Result.Err pfe, num.imp.dec2flt.Dec2FltTrace.Invalid
74 body1 (c = 45#u8) none none)
75 | some value =>
76 ok (core.result.Result.Ok value, num.imp.dec2flt.Dec2FltTrace.Special
77 body1 (c = 45#u8) none parse_inf_nan_result value)
78 | some r =>
79 let fast_path_result ←
80 num.imp.dec2flt.decimal.Decimal.try_fast_path LemireInst
81 coreopsarithDivInst coreopsarithMulInst coreopsarithNegInst
82 { r with negative := (c = 45#u8) }
83 match fast_path_result with
84 | none =>
85 let first_compute_result ←
86 num.imp.dec2flt.lemire.compute_float
87 LemireInst.traitsFloatExtInst.FloatInst r.exponent r.mantissa
88 let (b1, b2, first_compute_result1, fp, second_compute_guard) ←
89 if r.many_digits
90 then
91 ok (true, true, first_compute_result, first_compute_result,
92 first_compute_result.p_biased >= 0#i32)
93 else
94 ok (false, false, first_compute_result, first_compute_result,
95 false)
96 let (post_comparison_pair, second_compute_exponent,
97 second_compute_mantissa, second_compute_result,
98 second_equals_first, forced_deferral) ←
99 if second_compute_guard
100 then
101 do
102 let mantissa ← r.mantissa + 1#u64
103 let second ←
104 num.imp.dec2flt.lemire.compute_float
105 LemireInst.traitsFloatExtInst.FloatInst r.exponent mantissa
106 let equal ←
107 num.imp.dec2flt.common.BiasedFp.Insts.CoreCmpPartialEqBiasedFp.eq
108 fp second
109 let (bf, b3) ←
110 if equal
111 then ok (fp, false)
112 else ok ({ fp with p_biased := (-1)#i32 }, true)
113 ok (bf, some r.exponent, some mantissa, some second, some equal,
114 b3)
115 else ok (fp, none, none, none, none, false)
116 let (selected_pair, slow_path_guard, slow_path_result) ←
117 if post_comparison_pair.p_biased < 0#i32
118 then
119 do
120 let replacement ←
121 num.imp.dec2flt.slow.parse_long_mantissa
122 LemireInst.traitsFloatExtInst.FloatInst body1
123 ok (replacement, true, some replacement)
124 else ok (post_comparison_pair, false, none)
125 let i ← lift (IScalar.hcast .U64 selected_pair.p_biased)
126 let i1 ← LemireInst.traitsFloatExtInst.FloatInst.SIG_BITS
127 let i2 ← i <<< i1
128 let assembled_word ← lift (selected_pair.m ||| i2)
129 let assembly_result ←
130 num.imp.dec2flt.biased_fp_to_float LemireInst.traitsFloatExtInst
131 selected_pair
132 if c = 45#u8
133 then
134 let result ← coreopsarithNegInst.neg assembly_result
135 ok (core.result.Result.Ok result,
136 num.imp.dec2flt.Dec2FltTrace.Assembled
137 {
138 body := body1,
139 negative := true,
140 parse_number_result := (some { r with many_digits := b1 }),
141 fast_path_input :=
142 { r with negative := true, many_digits := b2 },
143 fast_path_result := none,
144 first_compute_exponent := r.exponent,
145 first_compute_mantissa := r.mantissa,
146 first_compute_result := first_compute_result1,
147 second_compute_guard,
148 second_compute_exponent,
149 second_compute_mantissa,
150 second_compute_result,
151 second_equals_first,
152 forced_deferral,
153 post_comparison_pair,
154 slow_path_guard,
155 slow_path_result,
156 selected_pair,
157 assembled_word,
158 assembly_result,
159 lexical_sign_applied := true,
160 result
161 })
162 else
163 ok (core.result.Result.Ok assembly_result,
164 num.imp.dec2flt.Dec2FltTrace.Assembled
165 {
166 body := body1,
167 negative := false,
168 parse_number_result := (some { r with many_digits := b1 }),
169 fast_path_input :=
170 { r with negative := false, many_digits := b2 },
171 fast_path_result := none,
172 first_compute_exponent := r.exponent,
173 first_compute_mantissa := r.mantissa,
174 first_compute_result := first_compute_result1,
175 second_compute_guard,
176 second_compute_exponent,
177 second_compute_mantissa,
178 second_compute_result,
179 second_equals_first,
180 forced_deferral,
181 post_comparison_pair,
182 slow_path_guard,
183 slow_path_result,
184 selected_pair,
185 assembled_word,
186 assembly_result,
187 lexical_sign_applied := false,
188 result := assembly_result
189 })
190 | some value =>
191 ok (core.result.Result.Ok value,
192 num.imp.dec2flt.Dec2FltTrace.FastPath body1 (c = 45#u8)
193 parse_number_result { r with negative := (c = 45#u8) }
194 fast_path_result value)
--- Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean lines 31-52 ---
$ nl -ba Tablet/num_imp_dec2flt_Dec2FltAssemblyTrace.lean | sed -n '31,52p'
31 body : Slice Std.U8
32 negative : Bool
33 parse_number_result : Option num.imp.dec2flt.decimal.Decimal
34 fast_path_input : num.imp.dec2flt.decimal.Decimal
35 fast_path_result : Option F
36 first_compute_exponent : Std.I64
37 first_compute_mantissa : Std.U64
38 first_compute_result : num.imp.dec2flt.common.BiasedFp
39 second_compute_guard : Bool
40 second_compute_exponent : Option Std.I64
41 second_compute_mantissa : Option Std.U64
42 second_compute_result : Option num.imp.dec2flt.common.BiasedFp
43 second_equals_first : Option Bool
44 forced_deferral : Bool
45 post_comparison_pair : num.imp.dec2flt.common.BiasedFp
46 slow_path_guard : Bool
47 slow_path_result : Option num.imp.dec2flt.common.BiasedFp
48 selected_pair : num.imp.dec2flt.common.BiasedFp
49 assembled_word : Std.U64
50 assembly_result : F
51 lexical_sign_applied : Bool
52 result : F
HISTORICAL PREDECESSOR TABLET EVIDENCE (not current-source support)
Request-9 recovery archives the following obsolete or redundant nodes.
Their predecessor extraction identity is
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9.
The current extraction is
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The old 65545-byte parser counterexample claimed 1.0 under the old cutoff;
the current source uses 2^59 and that input's target is positive infinity.
The old 2^31-all-ones slow witness used an I32 wrap that the current source
has removed. Current saved-count arithmetic clips its positive point to 2047.
Giant-count mathematical certificates are not executions of allocated inputs.
The old empty-contract proof concerns the archived, unbounded contracts only.
No archived statement supplies a current GOAL claim or primitive binding.
HISTORICAL Tablet/DecimalSeqExponentEval.lean
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqExponentEval]
def DecimalSeqExponentEval (s : Slice Std.U8) (base : Std.I32) :
Result Std.I32 :=
-- BODY
do
let empty <- core.slice.Slice.is_empty s
if empty then ok base else
let ch <- Slice.index_usize s 0#usize
if ch = 101#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else if ch = 69#u8 then
let s3 <- core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := 1#usize }
let b2 <- core.slice.Slice.is_empty s3
let (s4, exp_sign) <- if b2 then ok (s3, 1#i32) else do
let ch1 <- Slice.index_usize s3 0#usize
let exp_sign1 <- if ch1 = 45#u8 then ok (-1)#i32 else ok 1#i32
let s5 <- if ch1 = 45#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else if ch1 = 43#u8 then
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s3
{ start := 1#usize }
else ok s3
ok (s5, exp_sign1)
let exp_num <- num.imp.dec2flt.decimal_seq.parse_decimal_exponent s4
let signed <- exp_sign * exp_num
base + signed
else ok base
end dec2flt_model
HISTORICAL Tablet/DecimalSeqExponentEval.tex
Definition · Optional decimal exponent evaluation
DecimalSeqExponentEval to be the extracted parser's optional
exponent computation: return the base on an empty residual; otherwise inspect
an uppercase or lowercase exponent marker, consume an optional sign, fold the
remaining decimal exponent digits, apply the sign, and add the signed exponent
to the base. A non-exponent marker leaves the base unchanged.Preservation argument
Claim
DecimalSeqExponentEval(r,p) is exactly, as a monadic
Result computation, the optional-exponent fragment repeated in the
pinned parse_decimal_seq declaration. Thus it returns p when
r is empty or its first byte is neither e nor E; after
either marker it removes an optional - or +, invokes the
pinned decimal-exponent parser on the resulting suffix, multiplies by the
corresponding I32 sign, and adds the result to p. Equality includes both
the normal I32 result and failure at the same checked operation. This is also
the behavior of the optional-exponent source fragment at
crate/dec2flt/decimal_seq.rs:336--358 and of the corresponding
original fragment after the recorded source adaptation.Proof
DecimalSeqExponentEval and compare it with the repeated
optional-exponent fragments in the pinned
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq. Both computations
first call Slice.is_empty. If r is empty, both immediately return
ok p, so neither performs an index, a slice, exponent parsing, or
arithmetic. If r is nonempty, both index position zero. The preceding
nonemptiness branch is exactly the bounds justification for that index; any
modeled failure of the bind is propagated before the byte tests in both
computations.ok p. For decimal 101 (ASCII e), each computation takes
the suffix from index one; for decimal 69 (ASCII E), it takes a
second, textually duplicated branch with the same operations. In either
case the marker branch itself just established that r is nonempty, so the
range-from-one slice has a valid boundary. A failure of that slice operation
is nevertheless the same next monadic failure on each side.parse_decimal_exponent declaration on exactly that suffix
num_imp_dec2flt_decimal_seq_parse_decimal_exponent. Its result is
bound before further arithmetic, so its failure is returned unchanged. On a
normal result e, both sides perform the same checked I32 multiplication of
the selected sign by e and then the same checked I32 addition to p; a
failure of either operation is therefore returned at the same point, while
two successful operations yield the same p+(\mathord{\pm}e).parse_decimal_exponent has the same digit order, wrapping ASCII
classification, and \mathtt{0x10000} update guard as the original closure.
That guard bounds the accumulated nonnegative exponent, so multiplication by
-1 is defined and equals the source's negative branch; multiplication by
1 equals its positive branch. The evidence also records that the final
checked decimal-point addition remains in the same position. Hence the
pinned fragment, this factoring, the adapted source, and the original source
have identical normal and modeled-failure behavior for every r and p.Requirement: parser totality
Result fragment, on every residual and base and with identical failures. Replacing the inline fragment by this name adds no domain premise and changes no normal-or-panic observation relevant to totality.Requirement: parser numeric acceptance
e/E, sign, exponent-fold, and checked-add branches are executed. The factoring neither strengthens numeric grammar nor assumes acceptance, so it preserves whatever dec2flt returns for each numeric literal.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
parse_decimal_seq; the sign factored here is only the explicit decimal exponent sign and produces the identical point update. Thus the returned-word sign path is untouched.Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number helper has its own exponent scan and returns a Decimal record; it does not call this decimal-sequence finalizer. Its byte-slice domain and Option result are therefore unaffected.Requirement: number helper rejection
parse_number is decided before any slow decimal-sequence conversion. This separate Result I32 definition cannot change the helper's None cases.Requirement: number helper record bounds
Decimal record and modifies neither mantissa, negative, nor many_digits. The record-bound obligation is noninterfering.Requirement: number helper accumulated value
parse_number, whereas this factoring is used later by parse_decimal_seq. It changes neither record exponent nor mantissa and hence is noninterfering.Requirement: special helper infinity
parse_inf_nan helper and its separate sign argument do not use decimal-sequence exponent evaluation. Keyword recognition and the infinity word are unchanged.Requirement: special helper nan
parse_inf_nan, disjoint from this definition. No byte, sign argument, or result of that helper is altered.Requirement: special helper rejection
None behavior on every other byte slice is therefore unchanged.Requirement: native correct or defer
Decimal record and does not construct a DecimalSeq. Optional decimal-sequence exponent evaluation is not on that path, so its Option result and rounding expression are unchanged.Requirement: integer correct or defer
compute_float operates on an already supplied I64 exponent and U64 mantissa. It neither calls nor observes this residual-slice computation, so its raw-pair behavior is unchanged.Requirement: slow accumulated rounding
parse_long_mantissa obtains its record from parse_decimal_seq; this definition exactly factors that parser's optional-exponent point update and adds no premise on the unsigned numeric input. Thus the full-significand record and all later slow-path observations are preserved without assuming the rounding conclusion.Requirement: assembly correspondence
BiasedFp and performs word operations. It has no residual slice or decimal-point input, so this definition cannot alter its all-field-values statement.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
parse_decimal_seq. The factoring neither changes those definitions nor assumes their exponent-equality premise, so it is noninterfering.HISTORICAL Tablet/DecimalSeqFractionalFinish.lean
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqFractionalFinish]
def DecimalSeqFractionalFinish (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq :=
-- BODY
do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalFinish.tex
Definition · Decimal-sequence fractional finalization
rest and an arbitrary modeled
decimal-sequence record d, DecimalSeqFractionalFinish is the
following checked monadic computation. It subtracts
|\texttt{rest}| from |s| and passes the resulting consumed count
to the extracted trailing-zero counter on s. It casts the returned
trailing count to I32 and adds it to
d.\texttt{decimal\_point}; subtracts trailing from
d.\texttt{num\_digits} to obtain kept; casts kept to I32
and adds it to the intermediate point; and then selects
rest and the resulting
point. Finally it runs the extracted parser loop~1 on d.\texttt{digits}
over the half-open array-index interval [\texttt{nDigits},19), setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from nDigits, the exponent-adjusted point,
flag, and that array. Each failed or divergent checked operation is
propagated by its monadic bind.Preservation argument
Claim
crate/dec2flt/decimal_seq.rs:320--363 after the integral and optional
fractional scans. Let s_0 be the exact original source slice stored as
start, let r be the exact current residual suffix stored as
s, and let d be the exact post-scan DecimalSeq. On the
branch d.\texttt{num_digits}\ne0, the remainder of that source execution is
exactly DecimalSeqFractionalFinish(s_0,r,d): it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return. No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.Proof
parse_decimal_seq declaration
num imp dec2flt decimal seq parse decimal seq.consumed_len to
|s_0|-|r|. The definition binds the same Usize subtraction
Slice.len s_0- Slice.len r. Since r is the exact
residual suffix of this execution, |r|\le |s_0| on every source-reachable
state. At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.consumed_len-1, …, 0 in the same order as the original
iter().rev() loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
n_trailing_zeros; a helper failure is bound and returned before any
record update on both model fragments.u as i32 and Aeneas's pure
UScalar.hcast .I32 u both compute exactly
\operatorname{cast32}(u); this operation truncates and cannot fail (the
lift surrounding it in the pinned parser merely places that pure
value in the Result computation). Thus both fragments first perform
the same checked I32 addition
d.\texttt{decimal_point}+\operatorname{cast32}(z), which either fails on
both sides or produces the same intermediate point. They next perform the
same checked Usize subtraction d.\texttt{num_digits}-z; if it succeeds, call
its Usize result k. Both then compute the identical pure value
\operatorname{cast32}(k) and perform the same checked I32 addition to the
intermediate point. Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
d.\texttt{decimal_point}+\operatorname{cast32}(z)
+\operatorname{cast32}(k); subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.truncated to true. In the false
branch both retain k and preserve d.\texttt{truncated}. This establishes
the same pair (n,f) of stored digit count and flag, including the equality
case k=768.Slice.is_empty result is saved across finalization. After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual s_6 or s_5 and test it after
finalization. In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte s_2[0] across
finalization. In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice. Thus the argument r passed to the
factoring is respectively that same s_2, s_6, s_5, or s_2.Slice.is_empty is total and returns
the deterministic test of whether the slice length is zero. Recomputing it
on the unchanged r therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies. In the empty case both computations take the
empty branch and neither indexes r. In every nonempty case, index zero is
in bounds; Slice.index_usize therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy. Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-e, or uppercase-E branch.MAX_DIGITS_WITHOUT_OVERFLOW and writes zero to each selected digit
cell. Aeneas duplicated this one source loop across control-flow branches as
parse_decimal_seq_loop1, loop4, loop6, and
loop7 in the pinned node; their range iterator, array update, state,
and exit bodies are identical. The factoring calls loop1 with the
same range and original d.\texttt{digits}, and hence produces exactly the
same filled array a, or propagates the same range/array failure at the same
iteration. When all binds succeed, both computations construct
DecimalSeq.mk with fields
num_digits=n, decimal_point=p,
truncated=f, and digits=a. Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.Requirement: parser totality
Requirement: parser numeric acceptance
parse_decimal_seq. The definition adds no grammar condition and assumes no acceptance result.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
parse_decimal_seq. This factoring changes neither their keyword path nor their lexical sign.Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
DecimalSeq or the identical prior failure. No biased-exponent range fact is inserted as a premise.Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
parse_number returns a Decimal before the optional slow decimal-sequence conversion and never calls this finalizer. Its nonempty-slice domain and Some cases are unaffected.Requirement: number helper rejection
None decision precedes and is independent of parse_decimal_seq. A definition over DecimalSeq states no new condition on that decision.Requirement: number helper record bounds
Decimal, whereas this definition consumes and constructs DecimalSeq. It cannot change the returned mantissa, negative flag, or 10^{19} bound.Requirement: number helper accumulated value
parse_number record. Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.Requirement: special helper infinity
parse_inf_nan neither produces nor consumes a DecimalSeq. Its keyword bytes, separate sign argument, and infinity result are noninterfering.Requirement: special helper nan
Requirement: special helper rejection
None cases remain identical.Requirement: native correct or defer
try_fast_path operates directly on the Decimal record and runs before slow decimal-sequence parsing. This finalizer changes neither a native-path Some value nor a deferral.Requirement: integer correct or defer
compute_float accepts scalar exponent and mantissa arguments and does not observe any DecimalSeq array. Its returned or deferred BiasedFp is unaffected.Requirement: slow accumulated rounding
parse_long_mantissa calls parse_decimal_seq and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately. No premise is added to unsigned numeric inputs, and no rounding result is assumed.Requirement: assembly correspondence
biased_fp_to_float consumes only a completed raw pair, not a source slice, residual, or decimal digit array. This finalizer cannot alter the assembly formula quantified over all field values.Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
DecimalSeq. Its real input and binary64 comparison relation remain unchanged.Requirement: exponent value agreement
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def leadingParserFinish4 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def leadingAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop4
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def leadingAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- leadingBase afterPoint rest
leadingAfterBase s rest d2 base
private def leadingAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
leadingAfterScan2 s afterPoint rest d2
private def leadingAfterZeros (s afterPoint sigStart : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits
leadingAfterBulk s afterPoint bulkRest d1 count arr
private def leadingAfterPoint (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let sigStart <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint
leadingAfterZeros s afterPoint sigStart d1
-- [TABLET NODE: DecimalSeqFractionalLeadingParserCore]
theorem DecimalSeqFractionalLeadingParserCore
(s s1 pointRest afterPoint sigStart bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1zero : d1.num_digits = 0#usize)
(hloop2 : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop2 afterPoint =
ok sigStart)
(hloop3 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 sigStart
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } =
ok d := by
-- BODY
have hbranch : leadingAfterPoint s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1zero] at hparse
simpa [leadingAfterPoint, leadingAfterZeros, leadingAfterBulk,
leadingAfterScan2, leadingBase, leadingAfterBase,
DecimalSeqExponentEval, Aeneas.Std.lift, hd1zero] using hparse
have hzeros : leadingAfterZeros s afterPoint sigStart d1 = ok d := by
as_aux_lemma =>
unfold leadingAfterPoint at hbranch
rw [hloop2] at hbranch
simpa only [bind_tc_ok] using hbranch
have hbulk : leadingAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold leadingAfterZeros at hzeros
rw [hloop3] at hzeros
simpa only [bind_tc_ok] using hzeros
have hafter : leadingAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold leadingAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
leadingBase afterPoint rest = ok base := by
apply bindOk (leadingBase afterPoint rest)
(leadingAfterBase s rest d2) d
simpa only [leadingAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : leadingAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold leadingAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish4 :
leadingParserFinish4 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold leadingAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change leadingParserFinish4 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [leadingBase] using hb
unfold leadingParserFinish4 at hfinish4
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.1, bind_assoc, bind_tc_ok]
using hfinish4
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalLeadingParserCore.tex
Lemma · Exact leading-fractional parser branch
Proof
HISTORICAL Tablet/DecimalSeqFractionalParserCore.lean
import Tablet.DecimalSeqDuplicateLoops
import Tablet.DecimalSeqFractionalFinish
import Tablet.DecimalSeqExponentEval
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 100000
set_option maxHeartbeats 3000000
namespace dec2flt_model
private def fracParserFinish6 (s rest : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <- do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- d.decimal_point + UScalar.hcast .I32 trailing
let kept <- d.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d.truncated)
ok (nDigits, point, flag)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracBase (afterPoint rest : Slice Std.U8) : Result Std.I32 :=
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint)
private def fracAfterBase (s rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (base : Std.I32) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (nDigits, point, flag) <-
if d2.num_digits != 0#usize then do
let consumed <- Slice.len s - Slice.len rest
let trailing <-
num.imp.dec2flt.decimal_seq.count_trailing_zeros s consumed
let p1 <- base + UScalar.hcast .I32 trailing
let kept <- d2.num_digits - trailing
let point <- p1 + UScalar.hcast .I32 kept
let (nDigits, flag) <-
if kept > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
then ok (num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS, true)
else ok (kept, d2.truncated)
ok (nDigits, point, flag)
else ok (d2.num_digits, base, d2.truncated)
let finalPoint <- DecimalSeqExponentEval rest point
let a <- num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop6
{ start := nDigits,
«end» :=
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
d2.digits
ok (num.imp.dec2flt.decimal_seq.DecimalSeq.mk nDigits finalPoint flag a)
private def fracAfterScan2 (s afterPoint rest : Slice Std.U8)
(d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let base <- fracBase afterPoint rest
fracAfterBase s rest d2 base
private def fracAfterBulk (s afterPoint bulkRest : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) (arr : Array Std.U8 768#usize) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (rest, d2) <-
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := count, digits := arr }
fracAfterScan2 s afterPoint rest d2
private def fracAfterPointNonzero (s afterPoint : Slice Std.U8)
(d1 : num.imp.dec2flt.decimal_seq.DecimalSeq) :
Result num.imp.dec2flt.decimal_seq.DecimalSeq := do
let (bulkRest, count, arr) <-
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits
fracAfterBulk s afterPoint bulkRest d1 count arr
-- [TABLET NODE: DecimalSeqFractionalParserCore]
theorem DecimalSeqFractionalParserCore
(s s1 pointRest afterPoint bulkRest rest : Slice Std.U8)
(d0 d1 d2 d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(bulkCount : Std.Usize) (bulkArray : Array Std.U8 768#usize)
(hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0)
(hlead : num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s1)
(hscan1 : num.imp.dec2flt.decimal_seq.parse_digits_into_seq s1 d0 =
ok (pointRest, d1))
(hpointRestNe : pointRest.val ≠ [])
(hpointIndex : Slice.index_usize pointRest 0#usize = ok 46#u8)
(hdropPoint :
core.slice.index.SliceIndexRangeFromUsizeSlice.index
{ start := 1#usize } pointRest = ok afterPoint)
(hd1ne : d1.num_digits ≠ 0#usize)
(hloop5 :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop5 afterPoint
d1.num_digits d1.digits = ok (bulkRest, bulkCount, bulkArray))
(hscan2 :
num.imp.dec2flt.decimal_seq.parse_digits_into_seq bulkRest
{ d1 with num_digits := bulkCount, digits := bulkArray } =
ok (rest, d2))
(hd2valNe : d2.num_digits.val ≠ 0)
(hparse : num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok d) :
exists base : Std.I32,
(UScalar.hcast .I32 (Slice.len rest) : Std.I32) -
UScalar.hcast .I32 (Slice.len afterPoint) = ok base /\
DecimalSeqFractionalFinish s rest { d2 with decimal_point := base } = ok d := by
-- BODY
have hbranch : fracAfterPointNonzero s afterPoint d1 = ok d := by
as_aux_lemma =>
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq at hparse
rw [hdefault] at hparse
simp only [bind_tc_ok] at hparse
rw [hlead] at hparse
simp only [bind_tc_ok] at hparse
rw [hscan1] at hparse
simp only [bind_tc_ok] at hparse
simp [core.slice.Slice.is_empty, hpointRestNe, hpointIndex,
hdropPoint, hd1ne] at hparse
simpa [fracAfterPointNonzero, fracAfterBulk, fracAfterScan2, fracBase,
fracAfterBase, DecimalSeqExponentEval] using hparse
have hbulk : fracAfterBulk s afterPoint bulkRest d1 bulkCount bulkArray =
ok d := by
as_aux_lemma =>
unfold fracAfterPointNonzero at hbranch
rw [hloop5] at hbranch
simpa only [bind_tc_ok] using hbranch
have hafter : fracAfterScan2 s afterPoint rest d2 = ok d := by
as_aux_lemma =>
unfold fracAfterBulk at hbulk
rw [hscan2] at hbulk
simpa only [bind_tc_ok] using hbulk
have hd2ne : d2.num_digits ≠ 0#usize := by
intro heq
apply hd2valNe
exact congrArg UScalar.val heq
have bindOk {α β : Type} (r : Result α) (k : α -> Result β) (y : β)
(h : r >>= k = ok y) : exists x, r = ok x := by
cases r <;> simp_all
have hbaseOk : exists base : Std.I32,
fracBase afterPoint rest = ok base := by
apply bindOk (fracBase afterPoint rest)
(fracAfterBase s rest d2) d
simpa only [fracAfterScan2] using hafter
rcases hbaseOk with ⟨base, hb⟩
have hafterBase : fracAfterBase s rest d2 base = ok d := by
as_aux_lemma =>
unfold fracAfterScan2 at hafter
rw [hb] at hafter
simpa only [bind_tc_ok] using hafter
have hfinish6 :
fracParserFinish6 s rest { d2 with decimal_point := base } = ok d := by
as_aux_lemma =>
unfold fracAfterBase at hafterBase
have hcond : (d2.num_digits != 0#usize) = true := by
simpa only [bne_iff_ne] using hd2ne
simp only [hcond, if_true] at hafterBase
change fracParserFinish6 s rest
{ d2 with decimal_point := base } = ok d at hafterBase
exact hafterBase
refine ⟨base, ?_, ?_⟩
· simpa only [fracBase] using hb
unfold fracParserFinish6 at hfinish6
unfold DecimalSeqFractionalFinish
simpa only [DecimalSeqDuplicateLoops.2.2.2.1, bind_assoc, bind_tc_ok]
using hfinish6
end dec2flt_model
HISTORICAL Tablet/DecimalSeqFractionalParserCore.tex
Lemma · Exact nonzero-integer fractional parser branch
Proof
HISTORICAL Tablet/DispatchContractsUninhabited.lean
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
HISTORICAL Tablet/DispatchContractsUninhabited.tex
Theorem
DispatchContracts is empty.Proof
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.HISTORICAL Tablet/ParserExactRoundingScientific.lean
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingScientific]
theorem ParserExactRoundingScientific (s : Slice Std.U8)
(hs : s.val = [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
exists rest,
num.imp.dec2flt.parse.parse_scientific s =
ok (some 65536#i64, rest) /\
rest.val = [] := by
-- BODY
have ht : s = (⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩ : Slice Std.U8) := by
exact (Slice.eq_iff _ _).2 hs
rw [ht]
refine ⟨⟨[], by simp⟩, ?_, by rfl⟩
have addOne (x y : Usize) (hxy : x.val + 1 = y.val) :
x + 1#usize = ok y := by
have hmax : x.val + (1#usize).val <= UScalar.max .Usize := by
rw [show (1#usize).val = 1 by rfl, hxy]
have hy := UScalar.hrBounds y
simpa [UScalar.rMax_eq_max] using hy
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec hmax)
rw [hz]
congr 1
apply UScalar.eq_of_val_eq
simpa [hxy] using hzval
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = 6#i64 := by
rfl
have first_sum2 :
0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_sum3 :
0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 6#i64 := by
rfl
have first_count : (0#usize + 1#usize) = ok 1#usize :=
addOne _ _ (by rfl)
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 65#i64 := by
rfl
have second_count : (1#usize + 1#usize) = ok 2#usize :=
addOne _ _ (by rfl)
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8) = ok 655#i64 := by
rfl
have third_count : (2#usize + 1#usize) = ok 3#usize :=
addOne _ _ (by rfl)
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8) = ok 6553#i64 := by
rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize :=
addOne _ _ (by rfl)
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8) = ok 65536#i64 := by
rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize :=
addOne _ _ (by rfl)
have sixth_count : (5#usize + 1#usize) = ok 6#usize :=
addOne _ _ (by rfl)
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq,
first_product, first_sum, first_count, first_digit, first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq]
simp [fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body, Slice.index_usize,
Aeneas.Std.lift, core.num.U8.wrapping_sub, U8.size_eq, sixth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingScientific.tex
Helper · Exact scientific suffix
[54,53,53,51,54,48], the extracted
parse_scientific succeeds with exponent 65536 and an empty
remaining slice.Proof
HISTORICAL Tablet/ParserExactRoundingExecution.lean
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
(hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok
(⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
have parse_number_exact (body : Slice Std.U8)
(hbody : body.val = [48#u8, 46#u8] ++
List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
num.imp.dec2flt.parse.parse_number body = ok (some {
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }) := by
have hbodyLen : body.val.length = 65545 := by
simp only [hbody, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
obtain ⟨point, hscan0, hpoint⟩ :=
ParserExactRoundingDigitScans.2 body hbody
have hpointLen : point.val.length = 65544 := by
simp only [hpoint, List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
ParserExactRoundingOffsets body point (by omega) (by omega)
have hnDigitsEq : nDigits = 1#isize := by
apply IScalar.eq_of_val_eq
rw [hnDigitsVal, hbodyLen, hpointLen]
norm_num
subst nDigits
let fraction : Slice Std.U8 :=
⟨List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
simp only [List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hfraction : fraction.val = List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
rfl
have hsplitPoint : core.slice.Slice.split_first point =
ok (some (46#u8, fraction)) := by
let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
rw [hfraction]
simp only [List.length_cons, List.length_append,
List.length_replicate, List.length_nil]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
hfraction]
rfl)
rw [hpointEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, point']
obtain ⟨expRest, hscan1, hexpRest⟩ :=
ParserExactRoundingDigitScans.1 fraction hfraction
have hfractionLen : fraction.val.length = 65543 := by
simp only [hfraction, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hexpRestLen : expRest.val.length = 7 := by
simp [hexpRest]
obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
have hnAfterEq : nAfter = 65536#isize := by
apply IScalar.eq_of_val_eq
rw [hnAfterVal, hfractionLen, hexpRestLen]
norm_num
subst nAfter
have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
rw [IScalar.min]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalarTy.numBits, hbits]
obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(HNeg.hNeg.step (65536#isize) hnAfterNotMin)
have hnegAfterEq : negAfter = (-65536)#isize := by
apply IScalar.eq_of_val_eq
simpa using hnegAfterVal
subst negAfter
have hcastFractionExponent :
lift (IScalar.cast .I64 ((-65536)#isize)) =
ok (-65536)#i64 := by
have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
constructor
· rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
norm_num
· rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num)
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
rw [hz]
congr 2
apply IScalar.eq_of_val_eq
simpa using hzval
have haddBounds : IScalar.min .Isize <=
(1#isize).val + (65536#isize).val /\
(1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec haddBounds.1 haddBounds.2)
have htotalDigitsEq : totalDigits = 65537#isize := by
apply IScalar.eq_of_val_eq
norm_num at htotalDigitsVal
simpa using htotalDigitsVal
subst totalDigits
let exponentDigits : Slice Std.U8 :=
⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
have hsplitExponent : core.slice.Slice.split_first expRest =
ok (some (101#u8, exponentDigits)) := by
let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
rw [← hexpRest]
exact expRest.property⟩
have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
rw [hexpRest])
rw [hexpRestEq]
simp [core.slice.Slice.split_first,
dec2flt_model.ModelSliceSplitFirst, expRest']
have hexponentDigits : exponentDigits.val =
[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
obtain ⟨empty, hscientific, hempty⟩ :=
ParserExactRoundingScientific exponentDigits hexponentDigits
have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
have hb : IScalar.min .I64 <=
((-65536)#i64).val + (65536#i64).val /\
((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
IScalar.max_IScalarTy_I64_eq, I64.max_eq]
norm_num
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.add_spec hb.1 hb.2)
rw [hz]
congr 1
apply IScalar.eq_of_val_eq
simpa using hzval
obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
ParserExactRoundingOffsets body empty (by omega) (by
rw [hempty]
simp)
have hfullOffsetValExact : fullOffset.val = 65545 := by
rw [hfullOffsetVal, hbodyLen, hempty]
rfl
have hfullCastBounds : 0 <= fullOffset.val /\
fullOffset.val <= UScalar.max .Usize := by
rw [hfullOffsetValExact]
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [UScalar.max, hbits]
obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
have hfullLenEq : fullLen = Slice.len body := by
apply UScalar.eq_of_val_eq
rw [hfullOffsetVal] at hfullLenVal
simpa [hempty, Slice.len_val] using hfullLenVal
subst fullLen
have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
ok (Slice.len body) := by
simpa [Aeneas.Std.lift] using hcastLen0
have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
have hsubBounds : IScalar.min .Isize <=
(65537#isize).val - (19#isize).val /\
(65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
rcases System.Platform.numBits_eq with hbits | hbits <;>
simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec hsubBounds.1 hsubBounds.2)
have hmoreDigitsEq : moreDigits = 65518#isize := by
apply IScalar.eq_of_val_eq
norm_num at hmoreDigitsVal
simpa using hmoreDigitsVal
subst moreDigits
have hadjust := ParserExactRoundingAdjustment body hbody
let pointPhase :=
(match (46#u8 : Std.U8) with
| 46#uscalar =>
ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
| _ => ok (point, 0#u64, 0#isize, 0#i64))
have hpointMatch : pointPhase =
ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
unfold core.slice.Slice.is_empty
rw [show body.length = 65545 by
simpa [Slice.length] using hbodyLen]
rfl
have hnonemptyVal : body.val ≠ [] := by
intro h
rw [h] at hbodyLen
norm_num at hbodyLen
have hmassert : massert (¬ body.val = []) = ok () := by
simp [hnonemptyVal]
have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
ok (some ({
exponent := 0#i64,
mantissa := 1#u64,
negative := false,
many_digits := false }, Slice.len body)) := by
unfold num.imp.dec2flt.parse.parse_partial_number
simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
hnAfter, hnegAfter, hcastFractionExponent]
change (do let x ← pointPhase; _) = _
rw [hpointMatch]
simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
hadjust]
rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
(some 65536#i64) = ok
(core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
change (do
let exponent ← (-65536)#i64 + 65536#i64
ok (some (({
exponent,
mantissa := 1#u64,
negative := false,
many_digits := false } : num.imp.dec2flt.decimal.Decimal),
Slice.len body))) = _
rw [hexponentAdd]
rfl
unfold num.imp.dec2flt.parse.parse_number
simp [hpartial]
have hcompact : s.val = 48#u8 :: 46#u8 ::
(List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
rw [hs]
rfl
have hslen : s.val.length = 65545 := by
simp only [hs, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
unfold core.slice.Slice.first ModelSliceFirst
rw [hcompact]
rfl
have hnonempty : s.val ≠ [] := by
intro h
rw [h] at hslen
norm_num at hslen
have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
unfold core.slice.Slice.is_empty
rw [show s.length = 65545 by simpa [Slice.length] using hslen]
rfl
have hparse := parse_number_exact s hs
simp [num.imp.dec2flt.dec2flt,
num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
ParserExactRoundingFastPath]
end dec2flt_model
HISTORICAL Tablet/ParserExactRoundingExecution.tex
Helper · Exact execution of the long decimal witness
s contain the ASCII bytes 0., followed by exactly
65{,}535 zero bytes, and then 1e655360. The extracted public
binary64 parser returns success with the binary64 word
0x3ff0000000000000, namely 1.0.Proof
e655360, and produces mantissa one.655360.
ParserExactRoundingScientific gives their exact parsed value
65{,}536 and an empty remainder, so checked exponent addition gives zero.
Since 65{,}537>19, the extracted parser subtracts nineteen and obtains
65{,}518. By ParserExactRoundingAdjustment, the many-digit
adjustment is -18, which is not positive. Consequently the parser keeps
the already accumulated mantissa one and sets many_digits to false.
The exact record is therefore exponent zero, mantissa one, negative false,
and many-digits false, and the consumed length equals the input length.0, so the dispatcher takes neither sign
branch. It receives the exact decimal record above and, by
ParserExactRoundingFastPath, the ordinary fast path returns binary64
1.0. The dispatcher propagates that successful value, and the public
dec2flt wrapper discards only the trace and returns the same result.HISTORICAL Tablet/ParserExactRoundingWitness.lean
import Tablet.Binary64ModelDefault
import Tablet.DecimalGoalVocabularyDefault
import Tablet.ParserExactRoundingExecution
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 0
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: ParserExactRoundingWitness]
theorem ParserExactRoundingWitness :
exists (s : Str) (x : DecimalLexeme) (f : F64),
s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] /\
x = {
leadingSign := none
integerDigits := [0]
fractionDigits := some (List.replicate 65535 0 ++ [1])
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
} /\
f = (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) /\
DecimalGoalVocabularyDefault.sourceString s /\
DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x /\
num.imp.dec2flt.dec2flt
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64
F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f) /\
Not (exists magnitude : F64,
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.exactMagnitude x) magnitude /\
DecimalGoalVocabularyDefault.signedMagnitude
(DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
let lexeme : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witness : Str :=
⟨witnessBytes, by
rw [witnessBytes_length]
rcases Usize.bounds_eq with q | q <;>
norm_num [q, U32.max_eq, U64.max_eq]⟩
let one : F64 := ⟨BitVec.ofNat 64 4607182418800017408⟩
have byteArray_toList_eq_data (b : ByteArray) :
b.toList = b.data.toList := by
have aux (i : Nat) (r : List UInt8) (hi : i ≤ b.size) :
ByteArray.toList.loop b i r = r.reverse ++ b.data.toList.drop i := by
fun_induction ByteArray.toList.loop b i r with
| case1 i r h ih =>
rw [ih (by omega)]
simp only [List.reverse_cons, List.append_assoc, List.singleton_append]
have hlen : i < b.data.toList.length := by simpa using h
rw [List.drop_eq_getElem_cons hlen]
congr
cases b
rename_i data
exact getElem!_pos data i (by simpa using h)
| case2 i r h =>
have hieq : i = b.size := by omega
simp [hieq]
unfold ByteArray.toList
simpa using aux 0 [] (Nat.zero_le _)
let witnessString : String :=
String.ofList (['0', '.'] ++ List.replicate 65535 '0' ++
['1', 'e', '6', '5', '5', '3', '6', '0'])
have utf8_ofList (l : List Char) :
(String.ofList l).toUTF8.toList = l.flatMap String.utf8EncodeChar := by
rw [String.toUTF8, String.toByteArray_ofList]
rw [byteArray_toList_eq_data]
simp only [List.utf8Encode, List.toList_data_toByteArray]
have utf8_zeros (n : Nat) :
(List.replicate n '0').flatMap String.utf8EncodeChar =
List.replicate n (48 : UInt8) := by
rw [List.flatMap_replicate]
have h : String.utf8EncodeChar '0' = [(48 : UInt8)] := by decide
rw [h, List.flatten_replicate_singleton]
have witness_source : DecimalGoalVocabularyDefault.sourceString witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
· refine ⟨witnessString, ?_⟩
simp only [witnessString]
rw [utf8_ofList]
simp only [witness, witnessBytes, List.flatMap_append, utf8_zeros,
List.flatMap_cons, List.flatMap_nil, List.map_append, List.map_replicate,
List.map_cons, List.map_nil]
have h0 : (String.utf8EncodeChar '0').map UInt8.toNat = [48] := by decide
have hd : (String.utf8EncodeChar '.').map UInt8.toNat = [46] := by decide
have h1 : (String.utf8EncodeChar '1').map UInt8.toNat = [49] := by decide
have he : (String.utf8EncodeChar 'e').map UInt8.toNat = [101] := by decide
have h6 : (String.utf8EncodeChar '6').map UInt8.toNat = [54] := by decide
have h5 : (String.utf8EncodeChar '5').map UInt8.toNat = [53] := by decide
have h3 : (String.utf8EncodeChar '3').map UInt8.toNat = [51] := by decide
rw [h0, hd, h1, he, h6, h5, h3]
have u48 : (48#u8 : Std.U8).val = 48 := by decide
have u46 : (46#u8 : Std.U8).val = 46 := by decide
have u49 : (49#u8 : Std.U8).val = 49 := by decide
have u101 : (101#u8 : Std.U8).val = 101 := by decide
have u54 : (54#u8 : Std.U8).val = 54 := by decide
have u53 : (53#u8 : Std.U8).val = 53 := by decide
have u51 : (51#u8 : Std.U8).val = 51 := by decide
have ui48 : UInt8.toNat (48 : UInt8) = 48 := by decide
rw [u48, u46, u49, u101, u54, u53, u51, ui48]
rfl
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
exact fold_zeros 65535
have fraction_length : fraction.length = 65536 := by
simp only [fraction, zeros, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
simp only [fraction]
rw [List.foldl_append, zeros_fold]
rfl
have lexeme_valid : DecimalGoalVocabularyDefault.validNumeric lexeme := by
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
simp only [zeros, List.mem_replicate] at h
exact h.2
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [lexeme]
constructor
· simp only [lexeme]
intro d hd
simp only [fraction] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [lexeme]
· simp [lexeme]
have lexeme_render :
DecimalGoalVocabularyDefault.bytes witness =
DecimalGoalVocabularyDefault.renderNumeric lexeme := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [lexeme, witness, witnessBytes, fraction, zeros, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
norm_num
have lexeme_exact :
DecimalGoalVocabularyDefault.exactMagnitude lexeme =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, lexeme]
rw [significand_fold, fraction_length]
norm_num
rfl
let infinityBits : Nat := 2047 * 2 ^ 52
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
have hRun :
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 witness =
ok (core.result.Result.Ok one) := by
exact ParserExactRoundingExecution witness (by rfl)
refine ⟨witness, lexeme, one, ?_, ?_, rfl, witness_source, lexeme_valid,
lexeme_render, hRun, ?_⟩
· rfl
· rfl
· rintro ⟨magnitude, hround, hsigned⟩
rw [lexeme_exact] at hround
have hinf := huge_target_is_infinity magnitude hround
dsimp only [DecimalGoalVocabularyDefault, lexeme, one] at hsigned
rw [hinf] at hsigned
have bad := hsigned.2
change (4607182418800017408 : Nat) = infinityBits + 0 at bad
norm_num [infinityBits] at bad
HISTORICAL Tablet/ParserExactRoundingWitness.tex
Theorem · Concrete failure of exact rounding
roundsMagnitude and acquires the lexical sign of x to yield f.Proof
0', .', 1', e', 6', 5', and `3'
encode respectively to bytes 48,46,49,101,54,53,51; mapping the repeated
zero characters therefore gives precisely the symbolic repeated-byte segment.
This supplies the string required by sourceString in
DecimalGoalVocabularyDefault.validNumeric. Expanding renderNumeric and the ASCII digit
encoding yields the stated bytes. The parser execution is exactly
ParserExactRoundingExecution: its hypothesis is the concrete byte
equality already established, and its conclusion is the required successful
return of the word for 1.0.exactMagnitude from DecimalGoalVocabularyDefault is
10^{655360-65536}=10^{589824}.roundsMagnitude rules out
every non-infinity word, so the magnitude word must be the positive-infinity
word 2047\cdot2^{52}. Since x is nonnegative,
signedMagnitude would then require that word to equal the word of
f, namely 4607182418800017408. Direct arithmetic shows these words are
unequal. This contradiction proves the final negation and hence all clauses
of the witness theorem.HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.lean
import Tablet.SlowAccumulatedRoundingCount
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingDecimal]
theorem SlowAccumulatedRoundingDecimal (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
exists a : Array Std.U8 768#usize,
num.imp.dec2flt.decimal_seq.parse_decimal_seq s = ok {
num_digits := 768#usize
decimal_point := (-2147483648)#i32
truncated := true
digits := a } := by
-- BODY
let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq := {
num_digits := 0#usize
decimal_point := 0#i32
truncated := false
digits := Array.repeat 768#usize 0#u8 }
have hdefault :
num.imp.dec2flt.decimal_seq.DecimalSeq.Insts.CoreDefaultDefault.default =
ok d0 := by rfl
have hsLen : s.val.length = 2147483648 := by
rw [hs]
exact List.length_replicate
have hnonempty : 0 < s.val.length := by omega
have hidx0 : Slice.index_usize s 0#usize = ok 49#u8 := by
have hget : s.val[0]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 0#usize (by
simpa [Slice.length] using hnonempty))
rw [hz]
congr
exact hzval.trans hget
have hleading :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 s = ok s := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
core.slice.Slice.is_empty, hnonempty, hidx0]
obtain ⟨empty, d1, hscan, hempty, hdcount, hdpoint, hdtrunc⟩ :=
SlowAccumulatedRoundingCount s d0 hs rfl rfl rfl
have hemptyLen : empty.val.length = 0 := by rw [hempty]; rfl
have hemptyTest : core.slice.Slice.is_empty empty = ok true := by
simp [core.slice.Slice.is_empty, hempty]
have hsUsize : Slice.len s = 2147483648#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hsLen
have hemptyUsize : Slice.len empty = 0#usize := by
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using hemptyLen
have hconsumed : (2147483648#usize : Std.Usize) - 0#usize =
ok 2147483648#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 0#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hpred : (2147483648#usize : Std.Usize) - 1#usize =
ok 2147483647#usize := by
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := 2147483648#usize) (y := 1#usize) (by norm_num))
rw [hz]
congr 2
apply UScalar.eq_of_val_eq
simpa using hzval
have hlast : Slice.index_usize s 2147483647#usize = ok 49#u8 := by
have hget : s.val[2147483647]'(by omega) = 49#u8 := by
simpa only [hs, List.getElem_replicate]
obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
(Slice.index_usize_spec s 2147483647#usize (by
simp [Slice.length, hsLen]))
rw [hz]
congr
exact hzval.trans hget
have hzeros :
num.imp.dec2flt.decimal_seq.count_trailing_zeros s
2147483648#usize = ok 0#usize := by
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros
unfold num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body,
hpred, hlast]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop.body]
have hcastZero : UScalar.hcast .I32 (0#usize : Std.Usize) = 0#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
have hcastN : UScalar.hcast .I32 (2147483648#usize : Std.Usize) =
(-2147483648)#i32 := by
rw [IScalar.eq_equiv_bv_eq]
apply BitVec.eq_of_toNat_eq
simp only [UScalar.hcast, BitVec.zeroExtend_eq_setWidth,
BitVec.toNat_setWidth, UScalar.bv_toNat, I32.ofInt_bv,
BitVec.toNat_ofInt]
norm_num
rfl
have haddZero : ((0#i32 : Std.I32) + 0#i32) = ok 0#i32 := by rfl
have hsubZero : ((2147483648#usize : Std.Usize) - 0#usize) =
ok 2147483648#usize := hconsumed
have haddMin : ((0#i32 : Std.I32) + (-2147483648)#i32) =
ok (-2147483648)#i32 := by rfl
have hlarge : (2147483648#usize : Std.Usize) >
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
rw [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
norm_num
have hcleanup (a : Array Std.U8 768#usize) :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
{ start := 768#usize,
«end» := num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW }
a = ok a := by
have hlt : core.iter.range.StepUsize.partialOrdInst.lt
768#usize 19#usize = ok false := by rfl
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop1.body,
core.iter.range.IteratorRange.next,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS_WITHOUT_OVERFLOW.eq_def,
hlt]
refine ⟨d1.digits, ?_⟩
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq
simp [hdefault, hleading, hscan, hempty, hemptyTest, hdcount, hsUsize,
hemptyUsize, hconsumed, hzeros, hcastZero, hdpoint, haddZero,
hsubZero, hcastN, haddMin, hlarge, hcleanup, hdtrunc,
Aeneas.Std.lift,
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def]
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingDecimal.tex
Lemma · Exact long decimal-sequence result
parse_decimal_seq(s) returns the record
Proof
i32
gives zero. The parser's cast of the consumed count is the 32-bit
two's-complement narrowing
i32::MIN.MAX_DIGITS_WITHOUT_OVERFLOW value 19, so its comparison is false
and it performs no update. Substitution into the cited parser definition
gives exactly the displayed record.HISTORICAL Tablet/SlowAccumulatedRoundingSlow.lean
import Tablet.SlowAccumulatedRoundingDecimal
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingSlow]
theorem SlowAccumulatedRoundingSlow (s : Slice Std.U8)
(hs : s.val = List.replicate 2147483648 49#u8) :
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
obtain ⟨a, hdecimal⟩ := SlowAccumulatedRoundingDecimal s hs
have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
ok 53#u32 := by
simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault]
have hinf :
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER =
ok 2047#i32 := by
simp [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64,
num.imp.traits.Float.INFINITE_POWER.default.eq_def,
num.imp.traits.Float.EXP_SAT.default.eq_def,
num.imp.traits.Float.EXP_BITS.default.eq_def,
num.imp.traits.Float.SIG_BITS.default.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
have h : (do
let x ← 53#u32 - 1#u32
let x ← 64#u32 - x
let x ← x - 1#u32
let x ← 1#u32 <<< x
let i ← x - 1#u32
ok (UScalar.hcast .I32 i))
⦃ x => x = 2047#i32 ⦄ := by
step
step
step
step
step
apply IScalar.eq_of_val_eq
have hi : i.val = 2047 := by scalar_tac
have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
rw [hi] at hs
simpa [Aeneas.Std.lift, WP.spec_ok] using hs
obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
simpa [hxt] using hx
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
let infPower :=
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.INFINITE_POWER
have hinf' : infPower = ok 2047#i32 := hinf
unfold num.imp.dec2flt.slow.parse_long_mantissa
rw [hzero]
simp only [bind_tc_ok]
change (do let i ← infPower; _) = _
rw [hinf']
simp only [bind_tc_ok]
rw [hinfFp]
simp only [bind_tc_ok]
rw [hdecimal]
simp
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingSlow.tex
Lemma · Early slow-path zero pair
parse_long_mantissa(s) returns
Proof
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.lean
import Tablet.SlowAccumulatedRoundingLexical
import Tablet.SlowAccumulatedRoundingSlow
import Tablet.SlowAccumulatedRoundingMagnitude
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: SlowAccumulatedRoundingWitness]
theorem SlowAccumulatedRoundingWitness :
exists (s : Slice Std.U8) (x : DecimalLexeme),
s.val = List.replicate 2147483648 49#u8 /\
x = {
leadingSign := none
integerDigits := List.replicate 2147483648 1
fractionDigits := none
exponent := none } /\
Not (SourceValidByteSlice s -> x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.slow.parse_long_mantissa
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 s =
ok { m := 0#u64, p_biased := 0#i32 } ->
exists target : F64,
DecimalGoalVocabularyDefault.assembledWord
{ m := 0#u64, p_biased := 0#i32 } target /\
DecimalGoalVocabularyDefault.roundsMagnitude
(DecimalGoalVocabularyDefault.accumulatedMagnitude x)
target) := by
-- BODY
obtain ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩ :=
SlowAccumulatedRoundingLexical
have hslow := SlowAccumulatedRoundingSlow s hs
obtain ⟨_, hnoTarget⟩ := SlowAccumulatedRoundingMagnitude x hx
refine ⟨s, x, hs, hx, ?_⟩
intro hmatrix
exact hnoTarget (hmatrix hsource hsign hvalid hrender hslow)
end dec2flt_model
HISTORICAL Tablet/SlowAccumulatedRoundingWitness.tex
Lemma · Concrete slow accumulated-rounding witness
Proof
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.lean
import Tablet.Assumptions
import Tablet.NumberHelperEightDigitWord
import Tablet.NumberHelperEightDigitWordAccepted
import Tablet.NumberHelperParseEightDigitsSafe
import Tablet.NumberHelperReadEightBytes
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.num_imp_dec2flt_parse_parse_8digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperDigitScanSafeLength]
theorem NumberHelperDigitScanSafeLength :
forall (s : Slice Std.U8) (initial : Std.U64)
(digits tail : List Std.U8),
s.val = digits ++ tail ->
(forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) ->
(forall b rest, tail = b :: rest ->
Not (48 <= b.val /\ b.val <= 57)) ->
s.val.length <= 9223372036854120458 ->
exists (value : Std.U64) (rest : Slice Std.U8),
num.imp.dec2flt.parse.try_parse_digits s initial = ok (rest, value) /\
rest.val = tail := by
-- BODY
intro s initial digits tail hs hdigits htail hlen
have fast : forall (t : Slice Std.U8) (a : Std.U64) (ds : List Std.U8),
t.val = ds ++ tail ->
(forall b, List.Mem b ds -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop0 t a
⦃ p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458 ⦄ := by
intro t a ds htds hds htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop0
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.U64 => p.1.length)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => exists rem : List Std.U8,
p.1.val = rem ++ tail /\
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) /\
p.1.val.length <= 9223372036854120458)
(fun p => num.imp.dec2flt.parse.try_parse_digits_loop0.body p.1 p.2)
(t, a)
· intro p hp
rcases p with ⟨u, x⟩
rcases hp with ⟨rem, hurem, hrem, hulen⟩
change u.val = rem ++ tail at hurem
change u.val.length <= 9223372036854120458 at hulen
simp [num.imp.dec2flt.parse.try_parse_digits_loop0.body, WP.spec_ok,
Slice.length]
split
· rename_i h8
obtain ⟨chunk, hread, hbyte⟩ := NumberHelperReadEightBytes u h8
rw [hread]
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift]
split
· rename_i haccepted
have haccepted :
num.imp.dec2flt.common.is_8digits chunk = ok true := by
simp [num.imp.dec2flt.common.is_8digits, Aeneas.Std.lift,
haccepted]
have hrem8 : 8 <= rem.length := by
by_contra hn
have hrem_lt : rem.length < 8 := by omega
have htail_pos : 0 < tail.length := by
by_contra hzero
have ht0 : tail = [] := List.eq_nil_of_length_eq_zero (by omega)
have heq := congrArg List.length hurem
simp [ht0] at heq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hindex : rem.length < u.val.length := by omega
have hbyte_eq := hbyte rem.length hrem_lt
have hword_digit :=
NumberHelperEightDigitWord chunk haccepted rem.length hrem_lt
have hu_digit :
48 <= (u.val[rem.length]'hindex).val /\
(u.val[rem.length]'hindex).val <= 57 := by
omega
have hu_eq : (u.val[rem.length]'hindex) = b := by
simp [hurem, htail_eq]
rw [hu_eq] at hu_digit
exact (htail b rest htail_eq) hu_digit
obtain ⟨z, hparse⟩ :=
NumberHelperParseEightDigitsSafe chunk haccepted
rw [hparse]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, WP.spec_ok, h8]
constructor
· refine ⟨rem.drop 8, ?_, ?_, ?_⟩
· rw [hurem, List.drop_append_of_le_length hrem8]
· intro b hb
exact hrem b (List.mem_of_mem_drop hb)
· omega
· omega
· simp [WP.spec_ok]
exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨rem, hurem, hrem, hulen⟩
· exact ⟨ds, htds, hds, htlen⟩
have scalar : forall (t : Slice Std.U8) (a : Std.U64) (rem : List Std.U8),
t.val = rem ++ tail ->
(forall b, List.Mem b rem -> 48 <= b.val /\ b.val <= 57) ->
t.val.length <= 9223372036854120458 ->
num.imp.dec2flt.parse.try_parse_digits_loop1 t a 0#usize
⦃ p => p.2.val = rem.length ⦄ := by
intro t a rem htrem hrem htlen
unfold num.imp.dec2flt.parse.try_parse_digits_loop1
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Std.U64 × Std.Usize => rem.length - p.2.val)
(fun p => p.2.val <= rem.length)
(fun p => p.2.val = rem.length)
(fun p =>
num.imp.dec2flt.parse.try_parse_digits_loop1.body t p.1 p.2)
(a, 0#usize)
· intro p hp
rcases p with ⟨x, count⟩
change count.val <= rem.length at hp
simp [num.imp.dec2flt.parse.try_parse_digits_loop1.body, WP.spec_ok,
Slice.length]
split
· rename_i hcount_t
step
by_cases hinside : count.val < rem.length
· have hi_mem : List.Mem i1 rem := by
have hi_eq : i1 = rem[count.val]'hinside := by
rw [i1_post]
simp [htrem, hinside]
rw [hi_eq]
exact List.getElem_mem _
have hi_digit := hrem i1 hi_mem
step
have hi2_val : i2.val = i1.val - 48 := by
rw [i2_post]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2_lt : i2.val < 10 := by omega
simp [hi2_lt]
step
step
step
step
step
omega
· have hcount_eq : count.val = rem.length := by omega
have htail_pos : 0 < tail.length := by
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
obtain ⟨b, rest, htail_eq⟩ :=
List.exists_cons_of_length_pos htail_pos
have hi_eq : i1 = b := by
rw [i1_post]
simp [htrem, htail_eq, hcount_eq]
have hb_not := htail b rest htail_eq
step
have hi2_not : Not (i2.val < 10) := by
rw [i2_post, hi_eq]
rw [core.num.U8.wrapping_sub_val_eq]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
scalar_tac
simp [hi2_not, WP.spec_ok, hcount_eq]
· rename_i hcount_not
simp [WP.spec_ok]
have hlen_eq := congrArg List.length htrem
simp at hlen_eq
omega
· simp
unfold num.imp.dec2flt.parse.try_parse_digits
have hf := fast s initial digits hs hdigits hlen
obtain ⟨p, hfast, hfp⟩ := Aeneas.Std.WP.spec_imp_exists hf
rcases p with ⟨s1, x1⟩
rcases hfp with ⟨rem, hs1, hrem, hs1len⟩
change s1.val = rem ++ tail at hs1
change s1.val.length <= 9223372036854120458 at hs1len
have hsc := scalar s1 x1 rem hs1 hrem hs1len
obtain ⟨q, hscalar, hcount⟩ := Aeneas.Std.WP.spec_imp_exists hsc
rcases q with ⟨x2, count⟩
change count.val = rem.length at hcount
have hcount_le : count.val <= s1.val.length := by
rw [hcount, hs1]
simp
simp [hfast, hscalar]
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcount_le]
rw [hcount, hs1, List.drop_append_of_le_length (Nat.le_refl _)]
simp
end dec2flt_model
HISTORICAL Tablet/NumberHelperDigitScanSafeLength.tex
Lemma · Safe and exact digit scanning
try_parse_digits returns normally, and
its returned slice is exactly that tail.Proof
usize and
isize; in particular L\leq C<2^{63}<2^{64}. We audit the two
loops in num imp dec2flt parse try parse digits.0x30, induct from the least significant byte. The
incoming borrow is initially zero. If b_i<48, the result byte is in
[208,255], contradicting the accepted word's zero 0x80 bit.
Consequently b_i\geq48, no borrow leaves that byte, and the result-byte
high bit further gives b_i\leq175. In the wrapping addition by eight
copies of 0x46, the incoming carry is likewise initially zero.
Under the preceding bound, b_i\geq58 would produce a byte in [128,245],
again contradicting the zero high bit. Hence b_i\leq57 and no carry
leaves the byte. Both inductions cross all seven byte boundaries, so there
is no false positive. Conversely, bytes in [48,57] plainly create neither
a borrow nor a high bit in either operation, so the test accepts them.u32 succeeds. The outer accumulator update is
wrapping. The continuing branch then drops exactly the eight bytes just
read. Each continuation strictly reduces the remaining length, so the
first loop terminates after consuming whole eight-byte blocks contained in
the stated digit prefix. It cannot cross into the tail, because a block
containing its nondigit first byte fails the exact test.u64 cast is
exact, the accumulator multiplication and addition are wrapping, and the
checked increment gives j+1 no larger than the suffix length and hence no
larger than L<2^{64}. It therefore consumes all remaining bytes of the
given digit prefix. At the first tail byte the digit test fails, or at an
empty tail the length guard fails. The final slice begins at this bounded
count, so it succeeds and equals the unconsumed tail. This proves both the
normal return and the asserted exact remainder for every initial
accumulator.HISTORICAL Tablet/NumberHelperSharpFractionBytes.lean
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperSharpFractionBytes]
theorem NumberHelperSharpFractionBytes : exists l : List Std.U8,
l = List.replicate 9223372036854120450 49#u8 ++
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] /\
l.length = 9223372036854120458 := by
-- BODY
let tail : List Std.U8 :=
[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]
let bs : List Std.U8 :=
(tail.reverse ++ List.replicate 9223372036854120450 49#u8).reverse
have hlen : bs.length = 9223372036854120458 := by
simp only [bs, List.length_reverse, List.length_append,
List.length_replicate, tail, List.length_cons, List.length_nil]
refine ⟨bs, ?_, hlen⟩
simp only [bs, List.reverse_append, List.reverse_replicate,
List.reverse_reverse, tail]
end dec2flt_model
HISTORICAL Tablet/NumberHelperSharpFractionBytes.tex
Lemma · Certified sharp fractional byte list
1 followed by the eight ASCII bytes of e-655359, and its
length is 9223372036854120458.Proof
e-655359, and take
HISTORICAL Tablet/ParserNumericWriteEightCertificate.lean
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericWriteEightCertificate]
theorem ParserNumericWriteEightCertificate (s : Slice Std.U8) (v : Std.U64)
(hlen : 8 <= s.val.length) :
exists s',
SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64 s v =
ok s' := by
-- BODY
have htake : (s.val.take 8).length = 8 := by simp [hlen]
have hbytes : (List.map (fun b : BitVec 8 => (@UScalar.mk .U8 b))
v.bv.toLEBytes).length = 8 := by
simp
unfold SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
simp [core.ops.index.IndexMutSlice, core.slice.index.Slice.index_mut,
core.slice.index.SliceIndexRangeToUsizeSlice.index_mut, hlen,
Array.to_slice, core.slice.Slice.copy_from_slice, Slice.length,
Aeneas.Std.lift, core.num.U64.to_le_bytes]
split
· simp
· rename_i hne
exfalso
apply hne
apply UScalar.eq_of_val_eq
simpa [Slice.len_val] using htake.trans hbytes.symm
end dec2flt_model
HISTORICAL Tablet/ParserNumericWriteEightCertificate.tex
Helper · Eight-byte write succeeds
write_u64 operation succeeds.Proof
u64 has exactly eight bytes,
and conversion of that array to a slice is total. Thus the two slice lengths
tested by copy_from_slice agree. The copy succeeds, and applying
the range update continuation yields the required output slice.reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
Assumptions / kernel axioms
- Classical.choice
- Quot.sound
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (6)
- Conditional component compliance
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional numeric acceptance
- Conditional totality
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:1cc464db5545756405a8c541f4c115a36622bf30485fa5c7db4b1b3b18ffb687 |
| Preservation current fingerprint | preservation-v1:1cc464db5545756405a8c541f4c115a36622bf30485fa5c7db4b1b3b18ffb687 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"30e719fbf8a22d67928d66037e0375bb6c0d3f03990c7ee9146425d91918f4c2","lean_semantic_closure":"09908c897f1be1fd1e932c65f7b6e26bc2d2b4242602dedb70486d8eb84fbb95","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelOptionBranch":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","ModelOptionFromResidual":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","ModelSliceSplitFirst":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","ModelU8IsAsciiDigit":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","P9_T1_ActualDispatchOperations":"b578349cf5d69fb995f5a78081f2c0ea8f0e59bb869b24c632422c2ff625a698","P9_T1_DispatchCall":"aafbab5720f9f1f1be1a4f1ad90751b052013f2f548a12cb89c762ad2f57d702","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelOptionBranch","ModelOptionFromResidual","ModelSliceSplitFirst","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","ModelU8IsAsciiDigit","P9_T1_ActualDispatchOperations","P9_T1_DispatchCall","P9_T1_DispatchOperations","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_biased_fp_to_float","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq","num_imp_dec2flt_common_BiasedFp_zero_pow2","num_imp_dec2flt_common_is_8digits","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_decimal_Decimal_can_use_fast_path","num_imp_dec2flt_decimal_Decimal_try_fast_path","num_imp_dec2flt_decimal_INT_POW10","num_imp_dec2flt_decimal_seq_DecimalSeq","num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE","num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW","num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_round","num_imp_dec2flt_decimal_seq_DecimalSeq_trim","num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit","num_imp_dec2flt_decimal_seq_count_trailing_zeros","num_imp_dec2flt_decimal_seq_final_decimal_point","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5","num_imp_dec2flt_decimal_seq_parse_decimal_seq","num_imp_dec2flt_decimal_seq_parse_digits_into_seq","num_imp_dec2flt_fpu_fpu_precision_set_precision","num_imp_dec2flt_lemire_compute_float","num_imp_dec2flt_lemire_compute_product_approx","num_imp_dec2flt_lemire_full_multiplication","num_imp_dec2flt_lemire_power","num_imp_dec2flt_parse_MIN_19DIGIT_INT","num_imp_dec2flt_parse_adjust_many_digit_count","num_imp_dec2flt_parse_parse_8digits","num_imp_dec2flt_parse_parse_8digits_MASK","num_imp_dec2flt_parse_parse_8digits_MUL1","num_imp_dec2flt_parse_parse_8digits_MUL2","num_imp_dec2flt_parse_parse_inf_nan","num_imp_dec2flt_parse_parse_many_digits","num_imp_dec2flt_parse_parse_number","num_imp_dec2flt_parse_parse_partial_number","num_imp_dec2flt_parse_parse_scientific","num_imp_dec2flt_parse_try_parse_19digits","num_imp_dec2flt_parse_try_parse_digits","num_imp_dec2flt_slow_parse_long_mantissa","num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT","num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_closure","num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call","num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE","num_imp_dec2flt_table_POWER_OF_FIVE_128","num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"30e719fbf8a22d67928d66037e0375bb6c0d3f03990c7ee9146425d91918f4c2","lean_semantic_closure":"09908c897f1be1fd1e932c65f7b6e26bc2d2b4242602dedb70486d8eb84fbb95","lean_relevant_definition_descendants":{"Binary64Model":"d80435c56f8fcbe084ebc2fbf05989a7ddf07434d0acd161302414cac32f964d","Binary64ModelDefault":"e2475cd1caad0eef450c903f24d2dfb8ffdfadf787ccad3621a86556f41e533a","F64":"cc96d5e66f40c1a2965cffa0288f89c7ca9ce356f1258ceee4a0bdf883a2f6c2","ModelF64Classify":"4a3d0c05976e97107a13b942cb21c0cf7b9f33a8538413a9ab4e1c8bacaa81bd","ModelF64Clone":"ded9f491be3645b6ae10ebf1288579776c2387c3e73da2da65a7c225d08863c9","ModelF64Div":"7fa348acfaef51e50ae39f618bbf92c23f7094c6e1bfb8416bae87d57b1aa712","ModelF64ExponentMask":"255b2144e2885d8d4584092e44db1391e26adb165b2be45c62fcc1a6cb66ce69","ModelF64FromBits":"ddd4e3ac18fa87485d58985fb4379a911c939601d663228453ef7e47dbb1aa31","ModelF64FromU64":"8d2638f64a331a029d6ae0d22b87b2d11cc4bd8ebb1c2c5ccd6dbe16f103283d","ModelF64Infinity":"3512da70d592e5cb1c4e373241f16ed70fc052e55e938a0994cafffd5cfc8a6a","ModelF64MantissaDigits":"b8b7cf0690e2428d01acbbf9bf6bef6fdb3f9341df552b26b74ed6e102c32ecc","ModelF64MantissaMask":"14ed75ce28431a353750ad105bf350beec679ec936692739193ca20d4289838f","ModelF64Mul":"967c7873d540d6122f7c1330d7214f4df95f5ca8b07901660a8b98da190737cf","ModelF64Nan":"3f83a9cfc9a7c9ad2cff00d1d84b47ab28751d2b89c22102bfe1c1793dbb6c8f","ModelF64Neg":"3117e25e4ec7d4c7e88240299df10cc344be6fc6028b0b9a1e573a777eb613f9","ModelF64NegInfinity":"83b0894f6775fa78c9841be37195e3096ccfab2759adf691cec8a3e153f4c667","ModelF64ToBits":"293df8c87f6de0dd27a40fa265758f72260aea51ecd3e69edf9d51df43cb564b","ModelOptionBranch":"52346a9eff57b2df264690fd9889257a49117a5df41389641f6e99d744ca19f4","ModelOptionFromResidual":"f3d98cec684f8005e8fc2d92d579677f40c057555c8038016be87f598d853d28","ModelSliceSplitFirst":"b941136529ebbb99d2692bd8b5047d080684eea508b678b8cf7b06ef567ee21f","ModelU64BitAnd":"f3791b8cb54cd55f702cb65b53b998d0d642a4f516b1f1d4dc7ef02f1a8bc180","ModelU64BitOr":"c1795ffd326d6d7b10277e6e5189adbd559da37f0b95510ab95505fdac8430e3","ModelU64Shl":"b63ed97847770538f9391ba01e7547e6610c166290a0dada3d38eec1119a9ee6","ModelU64Shr":"5ad44572d12a36ad385208a68bb9ccd600e8e297c44925442323eabdc625445e","ModelU8IsAsciiDigit":"aa1fc6e8f0864cd1c431bceb74254faac1595cfb2182d5e273fbaa8a3f600efc","P9_T1_ActualDispatchOperations":"b578349cf5d69fb995f5a78081f2c0ea8f0e59bb869b24c632422c2ff625a698","P9_T1_DispatchCall":"aafbab5720f9f1f1be1a4f1ad90751b052013f2f548a12cb89c762ad2f57d702","P9_T1_DispatchOperations":"fef41f92c98c04a0676c6a99be32531f1fb855676716915bbcb4e7273967f366"},"lean_relevant_dependencies":["Binary64Model","Binary64ModelDefault","F64","F64_Insts_CoreCloneClone","F64_Insts_CoreMarkerCopy","F64_Insts_CoreOpsArithDivF64F64","F64_Insts_CoreOpsArithMulF64F64","F64_Insts_CoreOpsArithNegF64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH","F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_from_u64_bits","F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64_integer_decode","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_EXP_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_INFINITY","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_NEG_NAN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_MASK","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_classify","F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_to_bits","ModelF64Classify","ModelF64Clone","ModelF64Div","ModelF64ExponentMask","ModelF64FromBits","ModelF64FromU64","ModelF64Infinity","ModelF64MantissaDigits","ModelF64MantissaMask","ModelF64Mul","ModelF64Nan","ModelF64Neg","ModelF64NegInfinity","ModelF64ToBits","ModelOptionBranch","ModelOptionFromResidual","ModelSliceSplitFirst","ModelU64BitAnd","ModelU64BitOr","ModelU64Shl","ModelU64Shr","ModelU8IsAsciiDigit","P9_T1_ActualDispatchOperations","P9_T1_DispatchCall","P9_T1_DispatchOperations","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64","SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64","U64_Insts_CoreOpsBitBitAndU64U64","U64_Insts_CoreOpsBitBitOrU64U64","U64_Insts_CoreOpsBitShlU32U64","U64_Insts_CoreOpsBitShrU32U64","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16","U64_Insts_Dec2flt_modelNumImpTraitsCastIntoI16_cast","U64_Insts_Dec2flt_modelNumImpTraitsInt","U64_Insts_Dec2flt_modelNumImpTraitsInt_ONE","U64_Insts_Dec2flt_modelNumImpTraitsInt_ZERO","core_num_FpCategory","core_ops_arith_Div","core_ops_arith_Mul","core_ops_arith_Neg","core_ops_bit_BitOr","core_ops_bit_Shl","core_ops_bit_Shr","num_imp_dec2flt_Lemire","num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default","num_imp_dec2flt_biased_fp_to_float","num_imp_dec2flt_common_BiasedFp","num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq","num_imp_dec2flt_common_BiasedFp_zero_pow2","num_imp_dec2flt_common_is_8digits","num_imp_dec2flt_decimal_Decimal","num_imp_dec2flt_decimal_Decimal_can_use_fast_path","num_imp_dec2flt_decimal_Decimal_try_fast_path","num_imp_dec2flt_decimal_INT_POW10","num_imp_dec2flt_decimal_seq_DecimalSeq","num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE","num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS","num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW","num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift","num_imp_dec2flt_decimal_seq_DecimalSeq_round","num_imp_dec2flt_decimal_seq_DecimalSeq_trim","num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit","num_imp_dec2flt_decimal_seq_count_trailing_zeros","num_imp_dec2flt_decimal_seq_final_decimal_point","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE","num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5","num_imp_dec2flt_decimal_seq_parse_decimal_seq","num_imp_dec2flt_decimal_seq_parse_digits_into_seq","num_imp_dec2flt_fpu_fpu_precision_set_precision","num_imp_dec2flt_lemire_compute_float","num_imp_dec2flt_lemire_compute_product_approx","num_imp_dec2flt_lemire_full_multiplication","num_imp_dec2flt_lemire_power","num_imp_dec2flt_parse_MIN_19DIGIT_INT","num_imp_dec2flt_parse_adjust_many_digit_count","num_imp_dec2flt_parse_parse_8digits","num_imp_dec2flt_parse_parse_8digits_MASK","num_imp_dec2flt_parse_parse_8digits_MUL1","num_imp_dec2flt_parse_parse_8digits_MUL2","num_imp_dec2flt_parse_parse_inf_nan","num_imp_dec2flt_parse_parse_many_digits","num_imp_dec2flt_parse_parse_number","num_imp_dec2flt_parse_parse_partial_number","num_imp_dec2flt_parse_parse_scientific","num_imp_dec2flt_parse_try_parse_19digits","num_imp_dec2flt_parse_try_parse_digits","num_imp_dec2flt_slow_parse_long_mantissa","num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT","num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_POWERS","num_imp_dec2flt_slow_parse_long_mantissa_closure","num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call","num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE","num_imp_dec2flt_table_POWER_OF_FIVE_128","num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE","num_imp_traits_CastInto","num_imp_traits_Float","num_imp_traits_FloatExt","num_imp_traits_Float_EXP_BIAS_default","num_imp_traits_Float_EXP_BITS_default","num_imp_traits_Float_EXP_MIN_default","num_imp_traits_Float_EXP_SAT_default","num_imp_traits_Float_SIG_BITS_default","num_imp_traits_Int"],"preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "5ced9721ba23bf2c86225d7363be5b5dc70896dc76c5743a31158a34f6c5683c",
"dep_statement_hashes": {
"P9_T1_ActualDispatchFrameEquality": "aec6105b77a9274b33f7520f744a077e0d666c68cf4a1ab9154f953bf6cac7af"
},
"combined_sound_fp": "preservation-v1:1cc464db5545756405a8c541f4c115a36622bf30485fa5c7db4b1b3b18ffb687"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/dispatch-contracts.txt",
"sha256": "7393521c7013455145f8f916942b47011cf2aa0cda85ca7ec74d13df4bd8f859",
"cited_by": [
"Tablet/P9_T1_ReachedDispatchCall.tex",
"committed_node_kinds / pv_tablet.json"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"reference/model-evidence/dispatch-contracts.txt"
]
}
]SourceValidByteSlice
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
import Tablet.Preamble
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: SourceValidByteSlice]
def SourceValidByteSlice (s : Slice Std.U8) : Prop :=
-- BODY
s.val.length <= 9223372036854775807
end dec2flt_model
Why this model is faithful
Definition
Preservation argument
Claim
x86_64-unknown-linux-gnu source domain,
SourceValidByteSlice is exactly the length condition on a Rust
&[u8] represented by an Aeneas byte slice: the represented byte count
is at most isize::MAX; byte contents are unrestricted.Proof
Slice Std.U8 exposes its represented elements as
s.val, so s.val.length is its byte count. The pinned
toolchain reports a 64-bit pointer width, isize::MAX equal to
9223372036854775807, and one-byte u8 elements. Its core slice
source records that a slice occupies at most isize::MAX bytes.
These commands, raw results, and source locations are recorded in
reference/model-evidence/source-valid-byte-slice.txt. Thus the
Lean inequality is precisely the configured source length bound. Since the
definition inspects only length, it adds neither a byte-value condition nor
the UTF-8 invariant that belongs specifically to Rust strings.Authored arguments for individual requirements
Requirement: parser totality
Requirement: parser numeric acceptance
as_bytes is called; numeric grammar remains a separate premise.Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
Requirement: number helper rejection
Requirement: number helper record bounds
Requirement: number helper accumulated value
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Requirement: native correct or defer
Decimal records rather than slices, so the predicate is noninterfering.Requirement: integer correct or defer
Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Recorded review
| Correspondence | Pass |
|---|---|
| Preservation | VerifierPass |
SourceValidByteSlice · Lean checked
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Assumptions / kernel axioms
- propext
conservative transitive union of saved axiom observations across node dependencies
Requirements depending on this item (18)
- Conditional abstract composition
- Conditional component compliance
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
All 18 entries
- Conditional abstract composition
- Conditional component compliance
- Conditional numeric acceptance
- Conditional accumulated-value diagnostic
- Record bounds
- Conditional invalid rejection
- Conditional accumulated-value diagnostic
- Conditional equal-target bridge
- Conditional exact rounding
- Conditional invalid rejection
- No spurious NaNs
- Conditional numeric acceptance
- Numeric sign
- Selected magnitude sign
- Signed zero
- Conditional totality
- Full-significand diagnostic
- Rejection
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | committed_node_kinds / pv_tablet.json |
|---|---|
| Kind | authored definition |
| Preservation assessment origin | VerifierPanel |
| Preservation fingerprint | preservation-v1:588bb23bbf5abc3cbacc628bb377f7c226b8672ef83db1a0522da3b5130239e3 |
| Preservation current fingerprint | preservation-v1:588bb23bbf5abc3cbacc628bb377f7c226b8672ef83db1a0522da3b5130239e3 |
| Preservation freshness | matches current fingerprint |
| Correspondence approved fingerprint | {"own_tex":"d736148659be38528d8040160c92286f94c9e3a163bf026d5bef1af084b422bd","lean_semantic_closure":"97e2005f894731188b78bd906f4df6b86ad4a847c9c485370529868a68c963f7","preamble_tex":""} |
| Correspondence current fingerprint | {"own_tex":"d736148659be38528d8040160c92286f94c9e3a163bf026d5bef1af084b422bd","lean_semantic_closure":"97e2005f894731188b78bd906f4df6b86ad4a847c9c485370529868a68c963f7","preamble_tex":""} |
| Correspondence freshness | matches current fingerprint |
Exact preservation assessment
{
"status": "VerifierPass",
"origin": "VerifierPanel",
"fingerprints": {
"own_tex_hash": "6c00e685a511691ecc5fb0f7f3abe93fb3314211d74627dba692558cc82f01e5",
"dep_statement_hashes": {},
"combined_sound_fp": "preservation-v1:588bb23bbf5abc3cbacc628bb377f7c226b8672ef83db1a0522da3b5130239e3"
},
"lane_votes": {
"v1": "Pass"
},
"reviewer_action_id": null
}Captured evidence identities
[
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"Tablet/SourceValidByteSlice.tex",
"committed_node_kinds / pv_tablet.json"
]
}
]Source adaptations (8)
source adaptation audit
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Recorded review
| Preservation | accept |
|---|
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Record details
| Record source | modeling-input/manifest.json |
|---|---|
| Kind | source adaptation audit |
Exact source record
{
"axiom_compatibility_sha256": "45acea9f64cb52cefe3f6bd93368ff0ca23b80b0c641b3191195a7b2934f0eb0",
"basis": "6ca7ceca84b53a92866e94a51d1eccb6f828f19960d3f6c5590436b94be076d9c06583f9e94b467095cf9aff1a26a4857650ace006061c1ca5e4c441747ef622",
"decision": "accept",
"reason": "Adaptation meets its completion criteria at fingerprint 73bc943df16c9323da7c82d20596fe758d3fafc5c2c8ccdcc6881073c89ac769. I reviewed GOAL.md, current upstream, the complete 1345-line candidate diff, preservation comments, setup decisions, boundary inventory and export reports. My independent fresh full check at .trellis/scratch/check-1791488052884182817/observation.json reproduces successful uncached Cargo, Charon and Aeneas, one root Generated/M.lean, identical generated-source hash and source diff, and zero extracted-body placeholders. Lean fails exclusively on absent F64 and four cascading elaboration warnings. F64 is genuinely absent, not a forward reference; the carrier-only probe differs solely by a diagnostic comment and F64 := Std.U64 and compiles successfully. Export packaging/import checks pass. The local exponent_suffix repair calls the unchanged shared parser on the identical suffix under identical guards, including zero significands and malformed exponents; only an unobserved local mutation changes. The retained indexed scans, transparent helpers and delayed returns preserve byte visitation, update order, checked failures and suffix observations. Saved untrimmed significant/full fractional counts, the pre-update 2^59 exponent rule with one-digit overshoot and continued consumption, and repaired zero/subtraction/saturating-add/clamp point computation remain current source operations. Dispatcher instrumentation preserves helper call order, endpoint checks, fallback, actual final assembly inputs and sign application; special/native direct returns select no pair. Bit tables and specialized constants/decoding retain the f64 values. The two successful matching comparisons support, but do not replace, these source-grounded arguments. The fresh local is smaller than an additional helper or opaque slow-parser boundary; retaining primitive bindings is preferable to replacing a conversion tier or reducing goal coverage. Independently, no consequential unresolved route choice is required: all 32 goals and concrete f64/u64 domains remain retained, full-word representation preserves unrestricted assembly, and required primitive results on reached arithmetic calls are source-specified. Native guards independently bound ordinary/disguised cast operands by 2^53 and table indices by 22, excluding arithmetic-NaN cases without assuming native correctness. No particular reusable encoder or arbitrary-NaN bit policy is approved here. Confirmed export dependencies cover 2220 declarations with no unapproved axioms; the 64 pending declarations are missing-F64 declarations and dependents. The complete carrier-only diagnostic introduces no additional axiom dependency, but does not approve operation meanings or replace required final closure checks. Acceptance is for adaptation only: fresh paired definitions, independent preservation proofs and separate applications to every affected GOAL, current goal-faithfulness reviews, and complete elaborated axiom-policy validation remain required. No predecessor approval or correctness result is used as evidence.",
"route_compliance": "not_needed",
"support_obligations": [
"Supply the genuinely absent F64 carrier and its source/model raw-bit correspondence. Generated/M.lean uses F64 in primitive signatures and the concrete traits.rs and dec2flt/mod.rs instances but declares no carrier; all current Lean errors originate there. Preserve every binary64 word, including signed zeros, infinities and NaN payloads. Source biased_fp_to_float computes m | ((p_biased as u64) << 52) for every BiasedFp without field-validity assumptions, so the word interpretation and inverse bit conversions must be unrestricted.",
"Give reviewed meanings to F64 clone; MANTISSA_DIGITS, NAN, INFINITY, NEG_INFINITY, EXPONENT_MASK and MANTISSA_MASK; classify; to_bits; and from_bits. Their generated provenance points to pinned core clone.rs, num/f64.rs and num/mod.rs, and traits.rs uses them in the retained f64 instance and derived constants. Clone and conversions preserve all bits; classification implements the five IEEE field cases. Constants must match the pinned source words, including the NaN constant, rather than merely equivalent numerical classes.",
"Bind binary64 Mul, Div and Neg from the generated core ops/arith.rs externals. decimal.rs try_fast_path executes the actual ordinary/disguised arithmetic after its guards, and parse_inf_nan and the dispatcher execute lexical negation. Establish selected binary64 nearest-even primitive arithmetic independently of native_correct_or_defer, preserving normal return and signs. Fresh source-guard proofs must justify any restriction of arithmetic preservation to reached non-NaN operands; a canonical arithmetic-NaN choice is not arbitrary exact-bit source equivalence. Negation must toggle only bit 63 on all words, including every NaN payload.",
"Bind F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64 to the complete opaque source body in work/crate/dec2flt/mod.rs: development debug_assert!(v <= MAX_MANTISSA_FAST_PATH), then u64 as f64. Preserve assertion failure above 2^53 and exact source conversion at or below 2^53. Do not replace it by a total rounding cast or use the pursued native correctness claim as a preservation premise. Transparent ordinary/disguised callers and checked-multiplication deferral remain extracted computation.",
"Supply the four U64 BitAnd, BitOr, Shl<U32> and Shr<U32> trait externals identified by Generated/M.lean core ops/bit.rs provenance. Reuse installed scalar/BitVec operations with fresh applicability checks: AND/OR preserve the full word; shifts preserve low-word behavior for valid counts and checked failure for counts >=64. traits.rs integer_decode and unrestricted biased_fp_to_float require the existing Rust casts and fixed 52-bit assembly shift, not normalized or well-formed field assumptions.",
"Supply core.num.U8.is_ascii_digit, Option Try.branch and FromResidual.from_residual, Slice.first, Slice.split_first and Str.as_bytes. Generated provenance and parse.rs/decimal.rs call sites identify their exact byte tests, optional head/suffix, early rejection and checked-multiply deferral meanings. Preserve empty cases, byte order and source suffix lengths. State source-valid byte slices with target isize::MAX/reference invariants and Rust strings with UTF-8; do not impose an installed convenience constructor's smaller bound or confuse Aeneas failure/divergence with the parser's returned Rust Err.",
"Author the missing mathematical observation vocabulary against GOAL.md and current parse.rs/decimal_seq.rs: whole-input numeric/special/invalid classification, lexical sign, distinct ordinary exact and full-significand accumulated values, and binary64 rounding on every nonnegative real. The accumulated explicit exponent is the shared pre-update 2^59 fold, including possible overshoot and continued digit consumption, not the predecessor's 65536 fold or the slow parser's clamped stored point. Refresh saved-count/final-point observations and obsolete removed-helper references. The transparent final_decimal_point already resolves to installed I64.saturating_add and OrdI64.clamp; it needs correspondence/application checks, not replacement computation.",
"Bind the current extracted dispatcher trace and component observations with preservation applications to all affected GOALs. dec2flt/mod.rs records actual selected final assembly pairs and public-result projection, with no pair for special/native direct returns. GOAL.md requires complete-string A/B bounds for public obligations, unsigned-body bounds for the named lexical contracts, unrestricted direct slow/helper domains, and genuinely inhabited compatible component contracts plus abstract normal-output existence. Preserve these distinctions and checked panic versus normal return. Reusable predecessor Model*, Binary64ModelDefault and vocabulary nodes require fresh paired meanings and independent preservation proofs; none is accepted by this audit. Rerun complete elaboration and dependency/policy checks after supplying support, including all 64 currently pending declarations and their dependents."
]
}Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]crate/dec2flt/common.rs
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Upstream → extraction-crate adaptation diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -2,6 +2,10 @@
/// Helper methods to process immutable bytes.
pub(crate) trait ByteSlice {
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
/// Reads 8 bytes as a 64-bit integer in little-endian order.
fn read_u64(&self) -> u64;
@@ -11,10 +15,6 @@
/// Calculate the difference in length between two slices.
fn offset_from(&self, other: &Self) -> isize;
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
}
impl ByteSlice for [u8] {
@@ -35,22 +35,6 @@
other.len() as isize - self.len() as isize
}
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
}
/// Determine if all characters in an 8-byte byte string (represented as a `u64`) are all decimal
@@ -65,7 +49,10 @@
/// A custom 64-bit floating point type, representing `m * 2^p`.
/// p is biased, so it be directly shifted into the exponent bits.
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
pub struct BiasedFp {
/// The significant digits.
pub m: u64,
Record details
| Kind | source adaptation site (file-level diff) |
|---|
Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]crate/dec2flt/decimal.rs
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Upstream → extraction-crate adaptation diff
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -25,7 +25,10 @@
];
/// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
pub struct Decimal {
pub exponent: i64,
pub mantissa: u64,
@@ -53,7 +56,17 @@
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
// Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
// The fast path crucially depends on arithmetic being rounded to the correct number of bits
// without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
@@ -70,9 +83,11 @@
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
@@ -81,9 +96,16 @@
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
};
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
}
}
Record details
| Kind | source adaptation site (file-level diff) |
|---|
Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]crate/dec2flt/decimal_seq.rs
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Upstream → extraction-crate adaptation diff
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -15,7 +15,10 @@
use crate::num::imp::dec2flt;
/// A decimal floating-point number, represented as a sequence of decimal digits.
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
pub struct DecimalSeq {
/// The number of significant digits in the decimal.
pub num_digits: usize,
@@ -174,12 +177,16 @@
let mut read_index = 0;
let mut write_index = 0;
let mut n = 0_u64;
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
if read_index < self.num_digits {
n = (10 * n) + self.digits[read_index] as u64;
read_index += 1;
} else if n == 0 {
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
} else {
while (n >> shift) == 0 {
n *= 10;
@@ -187,6 +194,9 @@
}
break;
}
+ }
+ if all_zero {
+ return;
}
self.decimal_point -= read_index as i32 - 1;
if self.decimal_point < -Self::DECIMAL_POINT_RANGE {
@@ -219,6 +229,41 @@
}
}
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
/// Combine counts in i64 and clamp before casting to i32.
#[inline]
pub(super) fn final_decimal_point(
@@ -226,6 +271,10 @@
fractional_count: usize,
explicit: i64,
) -> i32 {
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
if significant_count == 0 {
return 0;
}
@@ -241,19 +290,24 @@
let start = s;
let mut fractional_count = 0;
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
- }
-
- s = s.parse_digits(|digit| d.try_add_digit(digit));
-
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
+ }
+
+ s = parse_digits_into_seq(s, &mut d);
+
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
let first = s;
// Skip leading zeros.
if d.num_digits == 0 {
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
}
}
while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
@@ -265,21 +319,22 @@
d.num_digits += 8;
s = &s[8..];
}
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
fractional_count = first.len() - s.len();
}
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
let significant_count = d.num_digits;
if d.num_digits != 0 {
// Ignore the trailing zeros if there are any
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
d.num_digits -= n_trailing_zeros;
if d.num_digits > DecimalSeq::MAX_DIGITS {
d.truncated = true;
@@ -287,11 +342,25 @@
}
}
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
let mut explicit = 0;
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
if ch == b'e' || ch == b'E' {
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
}
}
d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
Record details
| Kind | source adaptation site (file-level diff) |
|---|
Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]crate/dec2flt/mod.rs
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Upstream → extraction-crate adaptation diff
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -87,7 +87,7 @@
issue = "none"
)]
-use common::BiasedFp;
+pub use common::BiasedFp;
use lemire::compute_float;
use parse::{parse_inf_nan, parse_number};
use slow::parse_long_mantissa;
@@ -115,18 +115,14 @@
pub trait Lemire: FloatExt {
/// Maximum exponent for a fast path case, or `⌊(SIG_BITS+1)/log2(5)⌋`
// assuming FLT_EVAL_METHOD = 0
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
/// Minimum exponent for a fast path case, or `-⌊(SIG_BITS+1)/log2(5)⌋`
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
/// Maximum exponent that can be represented for a disguised-fast path case.
/// This is `MAX_EXPONENT_FAST_PATH + ⌊(SIG_BITS+1)/log2(10)⌋`
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
@@ -142,29 +138,76 @@
}
#[cfg(target_has_reliable_f16)]
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
impl Lemire for f16 {
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
fn pow10_fast_path(exponent: usize) -> Self {
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
}
#[inline]
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
}
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
impl Lemire for f32 {
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
fn pow10_fast_path(exponent: usize) -> Self {
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
}
#[inline]
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
@@ -172,15 +215,51 @@
}
impl Lemire for f64 {
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
fn pow10_fast_path(exponent: usize) -> Self {
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
}
#[inline]
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
@@ -206,51 +285,239 @@
F::from_u64_bits(word)
}
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
+ let negative = c == b'-';
+ if c == b'-' || c == b'+' {
+ body = &body[1..];
+ }
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
+ }
+
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
+ Some(r) => r,
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
+ };
+
+ let mut num = parsed;
+ num.negative = negative;
+ if !cfg!(feature = "optimize_for_size") {
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
+ }
+ }
+
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
+ }
+ let post_comparison_pair = fp;
+
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
- let negative = c == b'-';
- if c == b'-' || c == b'+' {
- s = &s[1..];
- }
- if s.is_empty() {
- return Err(pfe_invalid());
- }
-
- let mut num = match parse_number(s) {
- Some(r) => r,
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
- };
- num.negative = negative;
- if !cfg!(feature = "optimize_for_size") {
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
- }
- }
-
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
- }
-
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
-}
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
+}
Record details
| Kind | source adaptation site (file-level diff) |
|---|
Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]crate/dec2flt/parse.rs
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Upstream → extraction-crate adaptation diff
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -31,18 +31,28 @@
// may cause overflows, to be handled later
while s.len() >= 8 {
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
s = &s[8..];
} else {
break;
}
}
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
x = x.wrapping_mul(10).wrapping_add(digit as _);
- });
+ count += 1;
+ }
+ s = &s[count..];
(s, x)
}
@@ -69,6 +79,44 @@
*s_ref = s;
}
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
/// Parse the scientific notation component of a float.
pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
let mut exponent = 0i64;
@@ -83,13 +131,25 @@
}
}
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
if exponent < (1_i64 << 59) {
exponent = 10 * exponent + digit as i64;
}
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
if negative { Some(-exponent) } else { Some(exponent) }
} else {
*s_ref = s;
@@ -152,32 +212,17 @@
n_digits -= 19;
let mut many_digits = false;
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
if n_digits > 0 {
// at this point we have more than 19 significant digits, let's try again
many_digits = true;
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
}
Some((Decimal { exponent, mantissa, negative: false, many_digits }, len))
Record details
| Kind | source adaptation site (file-level diff) |
|---|
Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]crate/dec2flt/slow.rs
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Upstream → extraction-crate adaptation diff
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -46,18 +46,27 @@
return fp_inf;
}
let mut exp2 = 0_i32;
+ let mut loop_result = None;
// Shift right toward (1/2 ... 1].
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
}
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
}
// Shift left toward (1/2 ... 1].
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
@@ -69,9 +78,16 @@
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
}
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
Record details
| Kind | source adaptation site (file-level diff) |
|---|
Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]crate/traits.rs
Historical preparation document: preparation source-adaptation audit. It describes the state and obligations at preparation. This generation is captured in Complete. Later closure and review results appear in the proof and modeling views. This original document remains available as history.
Shared extraction-boundary explanation (Preamble)
Preservation argument
Claim
x86_64-unknown-linux-gnu, the library's empty default feature set
(so optimize_for_size is disabled), the unoptimized development
profile, enabled debug assertions and integer overflow checks, and the target's
SSE2 precision-setting branch. Interpret each of the frozen extraction's 24
external operations by the separately justified model-support definition that
owns that operation. Under those interpretations, the composed Aeneas model
represents the supplied source's f64 specialization on all of these
domains, without a correctness premise: every Rust str whose bytes
are valid UTF-8 and whose 64-bit slice length is at most
\mathtt{isize::MAX}=2^{63}-1; every Rust &[u8] whose length is at
most that bound, with arbitrary byte contents; every Decimal; every
i64/u64 pair; and every BiasedFp.dec2flt::<f64> the relation preserves panic versus normal return,
the outer returned Result's Ok/Err discriminant,
and, on success, the exact binary64 word and its NaN classification. For
parse_number it preserves panic versus normal return, the
Option discriminant, and all four returned Decimal fields.
For parse_inf_nan::<f64> and
Decimal::try_fast_path::<f64> it preserves panic versus normal
return, None versus Some, and every returned word and NaN
classification. For compute_float::<f64> and
parse_long_mantissa::<f64> it preserves panic versus normal return
and both fields of every returned BiasedFp. For
biased_fp_to_float::<f64> it preserves panic versus normal return
and the exact returned word, with no restriction on the pair fields.dec2flt_with_trace::<f64> it additionally preserves the public
result and the complete trace: its control-flow variant; sign-stripped body and
lexical sign; numeric and special helper results; signed native input and
native result; first integer operands and result; second-call guard, optional
operands and result, comparison and forced-deferral fact; post-comparison pair;
slow-path guard and optional result; selected pair; assembled unsigned word;
pre-sign assembly result; sign-application fact; and final word. Public
dec2flt::<f64> is exactly the first projection of that interface, and
direct special and native returns select no raw pair.Proof
generated.lean, with SHA-256
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9.
The raw source has no placeholder. The compatibility check reports no
unapproved axiom and isolates exactly 24 external declarations; the complete
inventory equals the 24 entries of Tablet/model-support.json.
compose-native --check reports an unchanged composition and equal
expected and actual Preamble hashes. Thus all transparent extracted
declarations come from this one pinned source and every nontransparent
operation is explicit. The premise assigning each external its owning
definition deliberately leaves that definition's primitive-semantics proof to
its own preservation record; no primitive binding is re-proved here.fpu.rs, lemire.rs, and table.rs are
byte-identical. The standalone namespace and local error shell introduce no
call. The GOALs observe only panic versus normal return and the outer
Ok/Err discriminant, so the shell's private kind and
formatting are unobserved; no identity with an unpinned core error payload is
asserted. Visibility and removed Debug derives do not affect values.
The retained generic bodies use none of the removed trait operations;
the direct Mul, Div, and Neg clauses and calls are
the operations already implied by Lemire. Only the u64
integer instance and f64 Float, FloatExt, and
Lemire instances can participate in an f64 execution, so
disabling the u16/u32 and f16/f32
instances changes no such call.f64/u64 field widths and
masks; the fast-path bounds are the source formula results; and the match over
power-of-ten words has the same masked index and exact words as the source
array. The toolchain-specific words, masks, classifications, casts, and
rounding behavior are independently pinned in
reference/model-evidence/binary64-boundary.txt. The frozen
from_u64 Rust body is the enabled assertion followed by the
u64 as f64 conversion. Because #[charon::opaque] applies to
the whole function, neither operation inside that body is transparent in the
extraction: the whole method is the single inventoried external. Its callers,
their guards, and the surrounding native computation remain transparent.
ModelF64FromU64 supplies exactly successful integer conversion for
v\leq2^{53} and assertion failure otherwise.split_first loops. Extracted helpers receive the same
slices and mutable values, visit bytes in the same forward or reverse order,
and retain every saturating, wrapping, and checked operation. Delayed returns
set a result flag, execute no intervening state update, leave the loop through
that flag, and immediately return the source value. In particular, casts and
length-derived additions on very large inputs keep their original panic or
normal behavior rather than acquiring a convenience size bound.first before any fractional zero skipping. Zero skipping consumes
only zeros and occurs only while the logical count is zero; the two following
digit scans consume all remaining fractional digits. Since all subsequent
slices are suffixes of first, the checked subtraction
first.len()-s.len() is exact and counts every fractional digit,
including those skipped zeros. The source separately saves
significant_count=d.num_digits before terminal-zero trimming and
storage capping. Neither later mutation of the stored count changes either
saved local. Both saved counts are at most the original source-valid length
M=2^{63}-1. Thus each Usize-to-I64
cast is exact and their difference is within I64 range, by
FinalPointArithmetic. The source then saturating-adds the
shared explicit exponent, clips once to [-2047,2047] and narrows exactly
to I32. The same arithmetic lemma shows that this final clip absorbs the
earlier I64 saturation; FinalPointExact proves the actual
checked finalizer's normal return and integer value, retaining cancellation
between the untrimmed count,
full fractional count and explicit exponent. It is not separate clipping
of those terms. A zero significant count yields point zero, but only after
the enclosing parser has made any earlier exponent call. Only normally
returned None defaults to exponent zero; failure and divergence still
propagate through the bind. Storage, trimming, truncation and digit fill
are unchanged. The full source/extraction excerpts supporting these counts
and sequencing are in reference/model-evidence/goal-vocabulary.txt.None, overwrite only the parsed sign, try the enabled native
path, make the first integer call, and evaluate the checked
mantissa+1 and second call under exactly the source short-circuit
guard. Both force the same deferral on unequal pairs, call the slow helper on
the unchanged body exactly for a negative post-comparison exponent, assemble
the same selected pair, and apply the sign last. Every trace field is either
one of those already computed values or the same nonmutating cast/shift/OR word
used by assembly. Hence recording the trace and discarding it in the public
projection changes neither call order, guards, state, panic points, nor any
returned observation.isize::MAX, while a Rust string adds UTF-8 validity. Sub-slicing
preserves the length bound and need not preserve an independent string type.
These facts establish all domains and observations in the claim independently
of the truth or falsity of any GOAL.Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
extraction-evidence/COMMAND.json
{"declaration_reader_sha256":"76f60cf0b867fad9727d2256d32b306c8cba3725216a4225d0f83add77fd6158","extraction_provenance":{"extraction_toolchain":{"aeneas":"fa699427","aeneas_revision":"fa699427cdfa8f604b891fb0223ef42883dd7dc4","cargo_features":[{"features":["default"],"name":"dec2flt-model","source":"workspace:Cargo.toml","version":"0.1.0"}],"cargo_lock_sha256":"bc644c624ded89197356bbd65d995054b7fb08e5bdfbaa38c6e7c7a53772cecf","cfg":["debug_assertions","emscripten_wasm_eh","feature=\"default\"","fmt_debug=\"full\"","overflow_checks","panic=\"unwind\"","relocation_model=\"pic\"","target_abi=\"\"","target_arch=\"x86_64\"","target_endian=\"little\"","target_env=\"gnu\"","target_family=\"unix\"","target_feature=\"fxsr\"","target_feature=\"sse\"","target_feature=\"sse2\"","target_feature=\"x87\"","target_has_atomic","target_has_atomic=\"16\"","target_has_atomic=\"32\"","target_has_atomic=\"64\"","target_has_atomic=\"8\"","target_has_atomic=\"ptr\"","target_has_atomic_load_store","target_has_atomic_load_store=\"16\"","target_has_atomic_load_store=\"32\"","target_has_atomic_load_store=\"64\"","target_has_atomic_load_store=\"8\"","target_has_atomic_load_store=\"ptr\"","target_has_atomic_primitive_alignment=\"16\"","target_has_atomic_primitive_alignment=\"32\"","target_has_atomic_primitive_alignment=\"64\"","target_has_atomic_primitive_alignment=\"8\"","target_has_atomic_primitive_alignment=\"ptr\"","target_has_reliable_f128","target_has_reliable_f16","target_has_reliable_f16_math","target_object_format=\"elf\"","target_os=\"linux\"","target_pointer_width=\"64\"","target_thread_local","target_vendor=\"unknown\"","ub_checks","unix"],"charon":"0.1.216","charon_revision":"6f058254eb741c12e9b388df07adaf7cc8aac8ed","extraction_profile":"dev","lean":"4.30.0-rc2","overflow_checks":true,"panic_strategy":"unwind","rustc_vv":"rustc 1.98.0-nightly (14210df0e 2026-05-31)\nbinary: rustc\ncommit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65\ncommit-date: 2026-05-31\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.0-nightly\nLLVM version: 22.1.6\n","target_pointer_width":64,"target_triple":"x86_64-unknown-linux-gnu"},"extractor_stack":["charon@0.1.216","aeneas@fa699427"],"extractor_toolchain_sha256":"18657da0659dee7889ed8a937b136c9abbc3a35e9050241cd8201c94fd232323","not_recorded":[],"source_digests":[{"source_file":"lib.rs","source_sha256":"31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516"}]},"extractor_script_path":"/home/leanagent/pv_runs/trellis-native-implementation-v209/scripts/extract_pv_model.py","extractor_script_sha256":"e8f80bcaf51eadd5bf7fc534ecc09061462990b4ca7ff4877741afb51522ee37","kernel_gate_checkers":[],"log_concatenation_order":"runs_then_steps_in_array_order","runs":[{"run_role":"primary","steps":[{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","-vV"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"rustc-version","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/charon/bin/charon","cargo","--preset=aeneas","--dest-file","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc","--","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--locked"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"charon","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","metadata","--format-version=1","--locked","--offline","--filter-platform","x86_64-unknown-linux-gnu"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-metadata","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo","rustc","--lib","--locked","--offline","--profile","dev","--target","x86_64-unknown-linux-gnu","--","--print","cfg"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"cargo-rustc-cfg","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"},{"argv":["/home/leanagent/pv_spike/tools/aeneas/bin/aeneas","-backend","lean","-dest","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen","-emit-json","/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc"],"effective_environment":{"CAML_LD_LIBRARY_PATH":"/home/leanagent/.opam/5.3.0/lib/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml/stublibs:/home/leanagent/.opam/5.3.0/lib/ocaml","CARGO_BUILD_TARGET":"x86_64-unknown-linux-gnu","CARGO_HOME":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/cargo-home","CARGO_NET_OFFLINE":"true","CARGO_TARGET_DIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","CHARON_TOOLCHAIN_IS_IN_PATH":"1","HOME":"/home/leanagent","LANG":"en_US.UTF-8","LC_ALL":"C.UTF-8","LD_LIBRARY_PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib","LEAN_PATH":"/home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/batteries/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/mathlib/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/plausible/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/aesop/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/Qq/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/leanagent/pv_genesis/dec2flt-trust-v1-20260729T150751Z/.lake/packages/importGraph/.lake/build/lib/lean","LOGNAME":"leanagent","MANPATH":":/home/leanagent/.opam/5.3.0/man","OCAMLTOP_INCLUDE_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OCAML_TOPLEVEL_PATH":"/home/leanagent/.opam/5.3.0/lib/toplevel","OPAMSWITCH":"5.3.0","OPAM_LAST_ENV":"/home/leanagent/.opam/.last-env/env-b63c98443275b747a73beff03ead5f21-0","OPAM_SWITCH_PREFIX":"/home/leanagent/.opam/5.3.0","PATH":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/pv_spike/tools/aeneas/bin:/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin:/home/leanagent/pv_spike/tools/charon/bin:/home/leanagent/.opam/5.3.0/bin:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.codex/tmp/arg0/codex-arg0bp3RGv:/home/leanagent/.codex/packages/standalone/releases/0.162.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0zoaUFO:/home/leanagent/.codex/packages/standalone/releases/0.161.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0I2AG9N:/home/leanagent/.codex/packages/standalone/releases/0.160.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0uXbMTF:/home/leanagent/.codex/packages/standalone/releases/0.160.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0bfx3A7:/home/leanagent/.codex/packages/standalone/releases/0.159.3-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0Lbl9Kq:/home/leanagent/.codex/packages/standalone/releases/0.159.2-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg014vrtg:/home/leanagent/.codex/packages/standalone/releases/0.159.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0sTdpjQ:/home/leanagent/.codex/packages/standalone/releases/0.159.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg0mQVsSO:/home/leanagent/.codex/packages/standalone/releases/0.158.0-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg03AxsLj:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.codex/tmp/arg0/codex-arg06eKaTo:/home/leanagent/.codex/packages/standalone/releases/0.157.1-x86_64-unknown-linux-musl/codex-path:/home/leanagent/.elan/bin:/home/leanagent/.local/bin:/home/leanagent/.cargo/bin:/home/leanagent/.nvm/versions/node/v22.23.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","RUSTC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc","RUSTDOC":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc","RUSTUP_TOOLCHAIN":"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu","SHELL":"/bin/bash","TEMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMP":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","TMPDIR":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/execution/tmp","USER":"leanagent"},"tool":"aeneas","working_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate"}]}],"schema":"trellis-extraction-command/v1","tool_source_checkouts":[]}extraction-evidence/DETERMINISM.json
{"comparison":"generated_lean_and_complete_tablet_tree_byte_identity","generated_lean_byte_identical":false,"generated_lean_sha256":["438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9"],"kernel_filespec_gate":"not_run","kernel_prescribed_region_gate":"not_run","namespace_context_roundtrip_gate":"not_run","result_sha256":"2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d","run_roles":["primary"],"schema":"trellis-extraction-determinism/v2","status":"not_run","tablet_root_sha256":["65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"],"tablet_tree_byte_identical":false}extraction-evidence/RESULT.json
{"command_sha256":"ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443","runs":[{"generated_lean_sha256":"438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9","run_role":"primary","steps":[{"exit_status":0,"stderr_byte_length":0,"stderr_offset":0,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":212,"stdout_offset":0,"stdout_sha256":"e6ea0da4a3301256a0a0dc0d67d11acf4e83e0d1bff5dd987ccdaa43708714bc","tool":"rustc-version"},{"exit_status":0,"stderr_byte_length":654,"stderr_offset":0,"stderr_sha256":"f9c6868a5426537d46aa5cee0eede13e81ee1c227eb07416fed3458a9a21d995","stdout_byte_length":0,"stdout_offset":212,"stdout_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","tool":"charon"},{"exit_status":0,"stderr_byte_length":0,"stderr_offset":654,"stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stdout_byte_length":2897,"stdout_offset":212,"stdout_sha256":"d56683b88328db7ea0afd000fff084a7beaf4d8aa9fdb413de1c42b4666498ae","tool":"cargo-metadata"},{"exit_status":0,"stderr_byte_length":302,"stderr_offset":654,"stderr_sha256":"5f1d7bb1b87b9bba4c28fe1b0a15b43d00967aa85d004e22e29c00ea126e5ea0","stdout_byte_length":1062,"stdout_offset":3109,"stdout_sha256":"4081a320e6292139b4a673d225682dc054b77cba113b8c8a8fbb0593f824b713","tool":"cargo-rustc-cfg"},{"exit_status":0,"stderr_byte_length":7588,"stderr_offset":956,"stderr_sha256":"fe9bece58aeff65b17ec4aadb9aec943086bfab28ee18b26a1b1f56d5d88bc4c","stdout_byte_length":933,"stdout_offset":4171,"stdout_sha256":"369f136627b1b5e7bb8fc7ef0c52ecd9bc1bdb8158664c0cde9095b3ba7b8e23","tool":"aeneas"}],"tablet_root_sha256":"65d3a1252fd09231519f14fa8fe89cee5eb84e4732a65e4df92744e1b9bf2d08"}],"schema":"trellis-extraction-result/v2","stderr_byte_length":8544,"stderr_sha256":"b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1","stdout_byte_length":5104,"stdout_sha256":"35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5"}extraction-evidence/STDERR.bin
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
warning: feature `f16` is declared but not used
--> lib.rs:2:46
|
2 | #![feature(cfg_target_has_reliable_f16_f128, f16, float_masks, register_tool, staged_api)]
| ^^^
|
= note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
warning: `dec2flt-model` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
Compiling dec2flt-model v0.1.0 (/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
[?25lApplied prepasses: [------------------------------------------------] 0/211 ⠋
Applied prepasses: [------------------------------------------------] 1/211 ⠋
Applied prepasses: [#####-------------------------------------------] 24/211 ⠋
Applied prepasses: [########----------------------------------------] 38/211 ⠋
Applied prepasses: [#############################-------------------] 131/211 ⠙
Applied prepasses: [################################################] 211/211 ✔️
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/50 ⠋
Translated globals: [#################################################] 50/50 ✔️
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/90 ⠋
Translated opaque functions: [########################################] 90/90 ✔️
[?25h[?25lTranslated transparent functions: [---------------------------------] 0/107 ⠋
Translated transparent functions: [---------------------------------] 1/107 ⠋
Translated transparent functions: [###------------------------------] 10/107 ⠙
Translated transparent functions: [######---------------------------] 22/107 ⠙
Translated transparent functions: [##########-----------------------] 35/107 ⠹
Translated transparent functions: [##############-------------------] 48/107 ⠹
Translated transparent functions: [################-----------------] 54/107 ⠹
Translated transparent functions: [##################---------------] 60/107 ⠸
Translated transparent functions: [###################--------------] 62/107 ⠸
Translated transparent functions: [####################-------------] 65/107 ⠸
Translated transparent functions: [#####################------------] 69/107 ⠸
Translated transparent functions: [#####################------------] 70/107 ⠼
Translated transparent functions: [######################-----------] 72/107 ⠼
Translated transparent functions: [######################-----------] 73/107 ⠴
Translated transparent functions: [######################-----------] 74/107 ⠴
Translated transparent functions: [#######################----------] 75/107 ⠴
Translated transparent functions: [#######################----------] 76/107 ⠦
Translated transparent functions: [########################---------] 79/107 ⠦
Translated transparent functions: [########################---------] 80/107 ⠧
Translated transparent functions: [#########################--------] 82/107 ⠧
Translated transparent functions: [#########################--------] 83/107 ⠧
Translated transparent functions: [#########################--------] 84/107 ⠇
Translated transparent functions: [##########################-------] 85/107 ⠇
Translated transparent functions: [##########################-------] 86/107 ⠇
Translated transparent functions: [##########################-------] 87/107 ⠏
Translated transparent functions: [###########################------] 88/107 ⠏
Translated transparent functions: [###########################------] 89/107 ⠋
Translated transparent functions: [###########################------] 90/107 ⠋
Translated transparent functions: [############################-----] 92/107 ⠋
Translated transparent functions: [############################-----] 93/107 ⠙
Translated transparent functions: [############################-----] 94/107 ⠙
Translated transparent functions: [#############################----] 96/107 ⠹
Translated transparent functions: [#############################----] 97/107 ⠹
Translated transparent functions: [##############################---] 98/107 ⠸
Translated transparent functions: [##############################---] 99/107 ⠼
Translated transparent functions: [###############################--] 101/107 ⠼
Translated transparent functions: [###############################--] 102/107 ⠴
Translated transparent functions: [###############################--] 103/107 ⠦
Translated transparent functions: [################################-] 104/107 ⠦
Translated transparent functions: [################################-] 105/107 ⠧
Translated transparent functions: [################################-] 106/107 ⠇
Translated transparent functions: [#################################] 107/107 ⠏
Translated transparent functions: [#################################] 107/107 ✔️
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/49 ⠋
Translated trait declarations: [########################--------------] 31/49 ✔️
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/89 ⠋
Translated trait impls: [################################-------------] 64/89 ✔️
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/90 ⠋
Post-processed translated opaque functions: [-------------------------] 1/90 ⠙
Post-processed translated opaque functions: [#########################] 90/90 ✔️
[?25h[?25lPost-processed translated transparent functions: [------------------] 0/107 ⠋
Post-processed translated transparent functions: [------------------] 1/107 ⠋
Post-processed translated transparent functions: [#-----------------] 10/107 ⠙
Post-processed translated transparent functions: [##----------------] 12/107 ⠙
Post-processed translated transparent functions: [##----------------] 13/107 ⠹
Post-processed translated transparent functions: [##----------------] 14/107 ⠹
Post-processed translated transparent functions: [##----------------] 15/107 ⠹
Post-processed translated transparent functions: [##----------------] 16/107 ⠸
Post-processed translated transparent functions: [##----------------] 17/107 ⠸
Post-processed translated transparent functions: [###---------------] 18/107 ⠸
Post-processed translated transparent functions: [###---------------] 19/107 ⠸
Post-processed translated transparent functions: [###---------------] 22/107 ⠼
Post-processed translated transparent functions: [####--------------] 24/107 ⠼
Post-processed translated transparent functions: [#####-------------] 30/107 ⠼
Post-processed translated transparent functions: [#####-------------] 33/107 ⠼
Post-processed translated transparent functions: [#####-------------] 35/107 ⠴
Post-processed translated transparent functions: [######------------] 38/107 ⠴
Post-processed translated transparent functions: [########----------] 50/107 ⠴
Post-processed translated transparent functions: [##############----] 89/107 ⠴
Post-processed translated transparent functions: [################--] 99/107 ⠦
Post-processed translated transparent functions: [################--] 100/107 ⠦
Post-processed translated transparent functions: [################--] 101/107 ⠧
Post-processed translated transparent functions: [#################-] 102/107 ⠧
Post-processed translated transparent functions: [#################-] 103/107 ⠧
Post-processed translated transparent functions: [#################-] 104/107 ⠇
Post-processed translated transparent functions: [#################-] 105/107 ⠏
Post-processed translated transparent functions: [#################-] 106/107 ⠏
Post-processed translated transparent functions: [##################] 107/107 ⠋
Post-processed translated transparent functions: [##################] 107/107 ✔️
[?25hextraction-evidence/STDOUT.bin
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
{"packages":[{"name":"dec2flt-model","version":"0.1.0","id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["lib"],"crate_types":["lib"],"name":"dec2flt_model","src_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/lib.rs","edition":"2024","doc":true,"doctest":true,"test":true}],"features":{"default":[],"optimize_for_size":[]},"manifest_path":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate/Cargo.toml","metadata":null,"publish":[],"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}],"workspace_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"workspace_default_members":["path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"],"resolve":{"nodes":[{"id":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0","dependencies":[],"deps":[],"features":["default"]}],"root":"path+file:///home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate#dec2flt-model@0.1.0"},"target_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","build_directory":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/cargo-target/extract","version":1,"workspace_root":"/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/crate","metadata":null}
debug_assertions
emscripten_wasm_eh
feature="default"
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
[[92mInfo[39m ] Imported: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/m.llbc
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/M.lean
[[92mInfo[39m ] Generated: /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/.trellis/modeling/exports/dec2flt-r0003-844b5eb1a475/extraction/extract.jb_up9zy/gen/translation.json
[[93mWarn[39m ] The crate contains extracted external, unknown definitions: we advise using the option -split-files to allow manually providing these definitions in separate files.
[[92mInfo[39m ] Total execution time: 6.240510 seconds
reference/model-evidence/adaptation-constants-probe.rs
fn main() {
let largest_power_of_ten = (1024_f64 / std::f64::consts::LOG2_10) as i32;
let log2_5 = std::f64::consts::LOG2_10 - 1.0;
let max_exponent_fast_path = (53_f64 / log2_5) as i64;
let max_exponent_disguised =
max_exponent_fast_path + (53_f64 / std::f64::consts::LOG2_10) as i64;
println!("largest_power_of_ten={largest_power_of_ten}");
println!("max_exponent_fast_path={max_exponent_fast_path}");
println!("max_exponent_disguised={max_exponent_disguised}");
println!("neg_nan={:016x}", (-f64::NAN).to_bits());
for (exponent, value) in IntoIterator::into_iter([
1e0_f64, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,
])
.enumerate()
{
println!("pow10_{exponent}={:016x}", value.to_bits());
}
}
reference/model-evidence/binary64-boundary.txt
Current native source guards (2026-10-09)
========================================
Raw extraction SHA256:
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current source identities (sha256sum):
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
Independent reached-domain argument:
For every Decimal record, can_use_fast_path true entails many_digits=false,
mantissa<=2^53 and exponent>=-22 and <=37. The ordinary arm further tests
exponent<=22. Its negative exponent table index is -exponent in 1..22;
its nonnegative exponent index is exponent in 0..22. Only these arms call
native division/multiplication. In the disguised arm exponent>22, shift is
exponent-22 in 1..15. This indexes INT_POW10 safely; checked_mul failure
returns ordinary None before any float call. Its successful product must pass
the explicit <=2^53 test before conversion and multiply by fixed entry 22.
The conversion assertion thus holds at every reached native conversion,
regardless of whether the native result is mathematically correct.
The conversion returns nonnegative finite exact integers; all reached table
entries are positive finite exact words (Binary64NativeCallDomain). Hence
every reached multiplication has finite non-NaN operands and every reached
division has finite numerator and positive finite nonzero denominator.
No native_correct_or_defer or other GOAL conclusion is used here.
Complete current source of decimal.rs:
1 //! Representation of a float as the significant digits and exponent.
2
3 use dec2flt::Lemire;
4 use dec2flt::fpu::set_precision;
5
6 use crate::num::imp::dec2flt;
7
8 const INT_POW10: [u64; 16] = [
9 1,
10 10,
11 100,
12 1000,
13 10000,
14 100000,
15 1000000,
16 10000000,
17 100000000,
18 1000000000,
19 10000000000,
20 100000000000,
21 1000000000000,
22 10000000000000,
23 100000000000000,
24 1000000000000000,
25 ];
26
27 /// A floating point number with up to 64 bits of mantissa and an `i64` exponent.
28 // Debug output is absent from the scoped observations. Removing only that
29 // implementation leaves all fields, computational derives, and parser
30 // operations unchanged independently of GOAL truth.
31 #[derive(Clone, Copy, Default, PartialEq, Eq)]
32 pub struct Decimal {
33 pub exponent: i64,
34 pub mantissa: u64,
35 pub negative: bool,
36 pub many_digits: bool,
37 }
38
39 impl Decimal {
40 /// Detect if the float can be accurately reconstructed from native floats.
41 #[inline]
42 fn can_use_fast_path<F: Lemire>(&self) -> bool {
43 F::MIN_EXPONENT_FAST_PATH <= self.exponent
44 && self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
45 && self.mantissa <= F::MAX_MANTISSA_FAST_PATH
46 && !self.many_digits
47 }
48
49 /// Try turning the decimal into an exact float representation, using machine-sized integers
50 /// and floats.
51 ///
52 /// This is extracted into a separate function so that it can be attempted before constructing
53 /// a Decimal. This only works if both the mantissa and the exponent
54 /// can be exactly represented as a machine float, since IEE-754 guarantees
55 /// no rounding will occur.
56 ///
57 /// There is an exception: disguised fast-path cases, where we can shift
58 /// powers-of-10 from the exponent to the significant digits.
59 pub fn try_fast_path<
60 F: Lemire
61 + core::ops::Div<Output = F>
62 + core::ops::Mul<Output = F>
63 + core::ops::Neg<Output = F>,
64 >(
65 &self,
66 ) -> Option<F> {
67 // `Lemire` already entails these three operator bounds through
68 // `Float`; spelling them directly changes no admitted type. Charon
69 // needs the direct clauses to resolve each explicit call's `Output`.
70 // Here we need to work around <https://github.com/rust-lang/rust/issues/114479>.
71 // The fast path crucially depends on arithmetic being rounded to the correct number of bits
72 // without any intermediate rounding. On x86 (without SSE or SSE2) this requires the precision
73 // of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
74 // The `set_precision` function takes care of setting the precision on architectures which
75 // require setting it by changing the global state (like the control word of the x87 FPU).
76 let _cw = set_precision::<F>();
77
78 if !self.can_use_fast_path::<F>() {
79 return None;
80 }
81
82 let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
83 // normal fast path
84 let value = F::from_u64(self.mantissa);
85 if self.exponent < 0 {
86 // Explicit trait calls preserve Rust arithmetic and resolve
87 // the generic output type that Charon leaves ambiguous.
88 core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
89 } else {
90 core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
91 }
92 } else {
93 // disguised fast path
94 let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
95 let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
96 if mantissa > F::MAX_MANTISSA_FAST_PATH {
97 return None;
98 }
99 core::ops::Mul::mul(
100 F::from_u64(mantissa),
101 F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
102 )
103 };
104
105 if self.negative {
106 Some(core::ops::Neg::neg(value))
107 } else {
108 Some(value)
109 }
110 }
111 }
Current source mod.rs native f64 constants/conversion and lookup, lines217-267:
217 impl Lemire for f64 {
218 // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
219 const MAX_EXPONENT_FAST_PATH: i64 = 22;
220 const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
221
222 fn pow10_fast_path(exponent: usize) -> Self {
223 // These bit patterns are exactly the source table's rounded binary64
224 // literals. The match is the same masked lookup; it merely keeps float
225 // constants out of Aeneas's unsupported constant interpreter.
226 match exponent & 31 {
227 0 => f64::from_bits(0x3FF0_0000_0000_0000),
228 1 => f64::from_bits(0x4024_0000_0000_0000),
229 2 => f64::from_bits(0x4059_0000_0000_0000),
230 3 => f64::from_bits(0x408F_4000_0000_0000),
231 4 => f64::from_bits(0x40C3_8800_0000_0000),
232 5 => f64::from_bits(0x40F8_6A00_0000_0000),
233 6 => f64::from_bits(0x412E_8480_0000_0000),
234 7 => f64::from_bits(0x4163_12D0_0000_0000),
235 8 => f64::from_bits(0x4197_D784_0000_0000),
236 9 => f64::from_bits(0x41CD_CD65_0000_0000),
237 10 => f64::from_bits(0x4202_A05F_2000_0000),
238 11 => f64::from_bits(0x4237_4876_E800_0000),
239 12 => f64::from_bits(0x426D_1A94_A200_0000),
240 13 => f64::from_bits(0x42A2_309C_E540_0000),
241 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
242 15 => f64::from_bits(0x430C_6BF5_2634_0000),
243 16 => f64::from_bits(0x4341_C379_37E0_8000),
244 17 => f64::from_bits(0x4376_3457_85D8_A000),
245 18 => f64::from_bits(0x43AB_C16D_674E_C800),
246 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
247 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
248 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
249 22 => f64::from_bits(0x4480_F0CF_064D_D592),
250 _ => f64::from_bits(0),
251 }
252 }
253
254 #[inline]
255 // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
256 // `charon::opaque` makes this entire asserted conversion external: both the
257 // unchanged `debug_assert!` and the unchanged cast below are in the opaque
258 // body. The callers, their fast-path guards, and their surrounding
259 // computation remain mechanically visible. A corresponding model binding
260 // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
261 // exact binary64 conversion at or below that bound.
262 #[charon::opaque]
263 fn from_u64(v: u64) -> Self {
264 debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
265 v as _
266 }
267 }
The existing platform-primitive evidence below concerns unchanged toolchain
operations. Its predecessor source line pointers must be read together with
the current complete source above, not as current extraction provenance.
Primary evidence for the binary64 boundary
==========================================
Scope and identities
--------------------
This record concerns the frozen x86_64-unknown-linux-gnu extraction, the
adapted Rust crate retained in this repository, and the installed toolchain
named by modeling-input/SETUP.md. The probe source is retained at
reference/model-evidence/binary64-probe.rs; no scratch source is required to
reproduce it.
Toolchain executable:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Target:
x86_64-unknown-linux-gnu
rustc executable SHA-256:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
Probe source SHA-256:
68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
Compiled probe SHA-256:
f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
Frozen generated.lean SHA-256:
45b5027c42f9bb25bf22d3573fdb0f93784cf93d2a7b92ef1a7687c8f66c25a9
Frozen modeling-input/manifest.json SHA-256:
a1fadc68519dfb08ec739d1f2e5d7ff558f696a3145a25bbb2934f2bf4aa04d2
Approved Binary64ModelDefault.lean SHA-256 at the time of this record:
03ae48fb631e6242bd21bf95d0481b66acae05f8cab343c7ab279b3c116538a3
Exact reproduction commands
---------------------------
Run from the repository root:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/binary64-probe.rs
B=.trellis/scratch/binary64-probe
"$R" --version --verbose
sha256sum "$R"
sha256sum "$P"
"$R" --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$B"
"$B"
Raw output
----------
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
rustc_sha256=162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
probe_sha256=68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e
binary_sha256=f49942b5558d9073d879c724067a771cddd07f1543efc6d1d8ee691f8e25a322
target_arch=x86_64
mantissa_digits=53
exponent_mask=7ff0000000000000
mantissa_mask=000fffffffffffff
nan=7ff8000000000000
infinity=7ff0000000000000
neg_infinity=fff0000000000000
nan_category=Nan
infinity_category=Infinite
zero_category=Zero
subnormal_category=Subnormal
normal_category=Normal
from_bits_to_bits=7ff0000000000001
neg_payload_nan=fff0000000000001
neg_zero=8000000000000000
subnormal_tie_to_even_zero=0000000000000000
subnormal_tie_to_even_two=0000000000000002
normal_division=3fb999999999999a
mul_negative_zero=8000000000000000
div_negative_zero=8000000000000000
div_negative_infinity=fff0000000000000
mul_overflow=7ff0000000000000
mul_zero_infinity_is_nan=true
div_zero_zero_is_nan=true
mul_nan_is_nan=true
cast_2_pow_53=4340000000000000
cast_2_pow_53_plus_1=4340000000000000
Pinned Rust library sources
---------------------------
The installed sources below belong to the same named toolchain. Their
SHA-256 identities are:
core/src/primitive_docs.rs
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5
core/src/num/f64.rs
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618
core/src/clone.rs
23f9cfc80347fde6b8457d46fbf7a2b8d9f34c8c58601b0b6f714ca2f6d1976b
The exact relevant text of core/src/primitive_docs.rs is:
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
/// values][wikipedia] for more information.
The referenced primitive-f32 documentation supplies the common primitive
floating-point operation rules quoted next:
/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
/// [−∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
///
/// When a primitive operation (addition, subtraction, multiplication, or
/// division) is performed on this type, the result is rounded according to the
/// roundTiesToEven direction defined in IEEE 754-2008. That means:
///
/// - The result is the representable value closest to the true value, if there
/// is a unique closest representable value.
/// - If the true value is exactly half-way between two representable values,
/// the result is the one with an even least-significant binary digit.
/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` −
/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the
/// true value's sign).
The same file explicitly separates arithmetic NaN choice from exact bitwise
operations; its exact relevant text is:
/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
/// changing the sign bit.
///
/// The following rules apply when a NaN value is returned from an arithmetic operation:
/// - The result has a non-deterministic sign.
/// - The quiet bit and payload are non-deterministically chosen from
/// the following set of options:
///
/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
/// `as` casts), then
/// - If the output is smaller than the input, low-order bits of the payload get dropped.
/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
/// bits.
/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
/// than the input, dropping the low-order bits may result in a payload of 0; a payload of 0 is not
/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
/// propagation cannot occur with some inputs.
/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
/// See the table below for the concrete NaNs this set contains on various targets.
///
/// | `target_arch` | Extra payloads possible on this platform |
/// |---------------|------------------------------------------|
/// | `aarch64`, `arm`, `arm64ec`, `loongarch64`, `powerpc` (except when `target_abi = "spe"`), `powerpc64`, `riscv32`, `riscv64`, `s390x`, `x86`, `x86_64` | None |
Thus the model's preferred quiet NaN is one permitted result whenever
multiplication or division returns NaN. This does not claim that arbitrary
Rust arithmetic NaNs have those exact bits. By contrast, unary negation and
bit conversion must preserve all non-sign bits exactly, including for every
NaN payload.
The exact relevant declarations in core/src/num/f64.rs are:
pub const MANTISSA_DIGITS: u32 = 53;
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
pub const SIGN_MASK: u64 = 0x8000_0000_0000_0000;
pub const EXPONENT_MASK: u64 = 0x7ff0_0000_0000_0000;
pub const MANTISSA_MASK: u64 = 0x000f_ffff_ffff_ffff;
pub const fn classify(self) -> FpCategory {
// We used to have complicated logic here that avoids the simple bit-based tests to work
// around buggy codegen for x87 targets (see
// https://github.com/rust-lang/rust/issues/114479). However, some LLVM versions later, none
// of our tests is able to find any difference between the complicated and the naive
// version, so now we are back to the naive version.
let b = self.to_bits();
match (b & Self::MANTISSA_MASK, b & Self::EXPONENT_MASK) {
(0, Self::EXPONENT_MASK) => FpCategory::Infinite,
(_, Self::EXPONENT_MASK) => FpCategory::Nan,
(0, 0) => FpCategory::Zero,
(_, 0) => FpCategory::Subnormal,
_ => FpCategory::Normal,
}
}
pub const fn to_bits(self) -> u64 {
// SAFETY: `u64` is a plain old datatype so we can always transmute to it.
unsafe { mem::transmute(self) }
}
pub const fn from_bits(v: u64) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u64` is a plain old datatype so we can always transmute from it.
unsafe { mem::transmute(v) }
}
The exact scalar clone body in core/src/clone.rs is:
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
Frozen adapted source
---------------------
The relevant retained source file hashes are:
crate/traits.rs
9013270fb846edcb0bdf2abd0353f575fdd727974cba9e89bdab8bb4c2b4f0bf
crate/dec2flt/mod.rs
ecadc1d7df05dfda85fcf99fc45da7e40cb36aa9736d12d1b3a75f60f532907d
crate/dec2flt/parse.rs
50d95265e5b1af43ee4f0033c9ff8d1b8dfd62d766ab14668ceec19955adba1f
crate/dec2flt/decimal.rs
633658be803b7369b18feb098a8aa1b5f714a933d3b79ecbc4899a1b05f35beb
crate/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1
crate/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485
The dispatcher excerpts below are reproduced from the identified file by
running these commands from the repository root:
sha256sum crate/dec2flt/mod.rs
sed -n '354,403p' crate/dec2flt/mod.rs
sed -n '405,422p' crate/dec2flt/mod.rs
sed -n '465,475p' crate/dec2flt/mod.rs
sed -n '506,523p' crate/dec2flt/mod.rs
Exact constant and bit-conversion excerpt from crate/traits.rs:
impl Float for f64 {
type Int = u64;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
// Bit-identical to the upstream `-f64::NAN`, without the unsupported
// compile-time float negation.
const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
const EXP_MASK: Self::Int = Self::EXPONENT_MASK;
const SIG_MASK: Self::Int = Self::MANTISSA_MASK;
fn to_bits(self) -> Self::Int {
self.to_bits()
}
fn classify(self) -> FpCategory {
self.classify()
}
}
impl FloatExt for f64 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
Exact derived-constant defaults from crate/traits.rs:
/// The number of bits in the significand, *excluding* the hidden bit.
const SIG_BITS: u32 = Self::SIG_TOTAL_BITS - 1;
/// Number of bits in the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
/// representation.
///
/// This shifted fully right, use `EXP_MASK` for the shifted value.
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
/// Signed version of `EXP_SAT` since we convert a lot.
const INFINITE_POWER: i32 = Self::EXP_SAT as i32;
/// The exponent bias value. This is also the maximum value of the exponent.
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
/// Minimum exponent value of normal values.
const EXP_MIN: i32 = -(Self::EXP_BIAS as i32 - 1);
Together with the f64-instance lines `BITS = 64` and
`SIG_TOTAL_BITS = Self::MANTISSA_DIGITS` in the preceding excerpt, these
defaults derive SIG_BITS, EXP_MIN, and INFINITE_POWER from the primitive
mantissa-digit constant rather than introducing independent parameters.
Exact asserted-conversion excerpt from crate/dec2flt/mod.rs:
#[inline]
// Aeneas cannot translate the source `u64 as f64` primitive conversion, so
// `charon::opaque` makes this entire asserted conversion external: both the
// unchanged `debug_assert!` and the unchanged cast below are in the opaque
// body. The callers, their fast-path guards, and their surrounding
// computation remain mechanically visible. A corresponding model binding
// must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
// exact binary64 conversion at or below that bound.
#[charon::opaque]
fn from_u64(v: u64) -> Self {
debug_assert!(v <= Self::MAX_MANTISSA_FAST_PATH);
v as _
}
Here MAX_MANTISSA_FAST_PATH is the retained default 1 << 53. The attribute is
attached to the function item, so the generated external stands for the whole
method, not merely the cast. In the enabled-debug configuration the source
succeeds only when v <= 2^53; above it the assertion fails before the cast. On
the successful branch every integer is exactly representable, so the source
cast and the model rounder return the same word.
Exact power-table and assembly excerpts from crate/dec2flt/mod.rs:
/// Maximum mantissa for the fast-path (`1 << 53` for f64).
const MAX_MANTISSA_FAST_PATH: u64 = 1 << Self::SIG_TOTAL_BITS;
const MAX_EXPONENT_FAST_PATH: i64 = 22;
const MIN_EXPONENT_FAST_PATH: i64 = -Self::MAX_EXPONENT_FAST_PATH;
const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
fn pow10_fast_path(exponent: usize) -> Self {
// These bit patterns are exactly the source table's rounded binary64
// literals. The match is the same masked lookup; it merely keeps float
// constants out of Aeneas's unsupported constant interpreter.
match exponent & 31 {
0 => f64::from_bits(0x3FF0_0000_0000_0000),
1 => f64::from_bits(0x4024_0000_0000_0000),
2 => f64::from_bits(0x4059_0000_0000_0000),
3 => f64::from_bits(0x408F_4000_0000_0000),
4 => f64::from_bits(0x40C3_8800_0000_0000),
5 => f64::from_bits(0x40F8_6A00_0000_0000),
6 => f64::from_bits(0x412E_8480_0000_0000),
7 => f64::from_bits(0x4163_12D0_0000_0000),
8 => f64::from_bits(0x4197_D784_0000_0000),
9 => f64::from_bits(0x41CD_CD65_0000_0000),
10 => f64::from_bits(0x4202_A05F_2000_0000),
11 => f64::from_bits(0x4237_4876_E800_0000),
12 => f64::from_bits(0x426D_1A94_A200_0000),
13 => f64::from_bits(0x42A2_309C_E540_0000),
14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
15 => f64::from_bits(0x430C_6BF5_2634_0000),
16 => f64::from_bits(0x4341_C379_37E0_8000),
17 => f64::from_bits(0x4376_3457_85D8_A000),
18 => f64::from_bits(0x43AB_C16D_674E_C800),
19 => f64::from_bits(0x43E1_58E4_6091_3D00),
20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
22 => f64::from_bits(0x4480_F0CF_064D_D592),
_ => f64::from_bits(0),
}
}
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
Exact native-call excerpt from crate/dec2flt/decimal.rs:
fn can_use_fast_path<F: Lemire>(&self) -> bool {
F::MIN_EXPONENT_FAST_PATH <= self.exponent
&& self.exponent <= F::MAX_EXPONENT_DISGUISED_FAST_PATH
&& self.mantissa <= F::MAX_MANTISSA_FAST_PATH
&& !self.many_digits
}
if !self.can_use_fast_path::<F>() {
return None;
}
let value = if self.exponent <= F::MAX_EXPONENT_FAST_PATH {
// normal fast path
let value = F::from_u64(self.mantissa);
if self.exponent < 0 {
// Explicit trait calls preserve Rust arithmetic and resolve
// the generic output type that Charon leaves ambiguous.
core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
} else {
core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
}
} else {
// disguised fast path
let shift = self.exponent - F::MAX_EXPONENT_FAST_PATH;
let mantissa = self.mantissa.checked_mul(INT_POW10[shift as usize])?;
if mantissa > F::MAX_MANTISSA_FAST_PATH {
return None;
}
core::ops::Mul::mul(
F::from_u64(mantissa),
F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
)
};
if self.negative {
Some(core::ops::Neg::neg(value))
} else {
Some(value)
}
The preceding can_use_fast_path body, together with
MAX_MANTISSA_FAST_PATH = 1 << SIG_TOTAL_BITS and SIG_TOTAL_BITS = 53 for f64,
requires the exponent to lie between -22 and 37, the input mantissa to be at
most 2^53, and many_digits to be false. Consequently an ordinary arithmetic
call has a from_u64 operand in 0..=2^53. In its negative-exponent arm,
`-self.exponent` lies in 1..=22; in its nonnegative arm, `self.exponent` lies
in 0..=22. The disguised branch checks its multiplied mantissa against 2^53
before from_u64 and uses table index 22. The paired statement
Binary64NativeCallDomain does not assert this source reachability. It says
conditionally that a from_u64 argument at most 2^53 succeeds with a finite,
non-NaN word and that a table index at most 22 succeeds with a positive,
nonzero, finite, non-NaN word. Applying that conditional statement to the
guards just derived establishes those properties for the actual ordinary and
disguised calls, and in particular establishes that every executed divisor is
nonzero.
Exact special-value excerpt from crate/dec2flt/parse.rs:
let float = match (register, len) {
(INF_3, 3) => F::INFINITY,
(INF_8, 8) => F::INFINITY,
(NAN, 3) => F::NAN,
_ => return None,
};
if negative { Some(-float) } else { Some(float) }
Thus the executed special route is INFINITY or NAN followed by conditional
negation; it does not select NEG_INFINITY or NEG_NAN directly.
The number helper has the exact source body
pub fn parse_number(s: &[u8]) -> Option<Decimal> {
if let Some((float, rest)) = parse_partial_number(s) {
if rest == s.len() {
return Some(float);
}
}
None
}
It returns only the Decimal produced by parse_partial_number; there is no
float type parameter or float operation at this boundary.
Exact dispatcher excerpts from crate/dec2flt/mod.rs
---------------------------------------------------
The entry of `dec2flt_with_trace` strips at most one leading sign, rejects
empty and sign-only inputs, calls `parse_number` on the unsigned body, and
calls `parse_inf_nan` only when `parse_number` returns `None`:
/// Run the actual dispatcher while retaining its approved internal observations.
pub fn dec2flt_with_trace<
'a,
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &'a str,
) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
let mut body = s.as_bytes();
let Some(&c) = body.first() else {
return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
};
let negative = c == b'-';
if c == b'-' || c == b'+' {
body = &body[1..];
}
if body.is_empty() {
return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
}
let parse_number_result = parse_number(body);
let parsed = match parse_number_result {
Some(r) => r,
None => {
let parse_inf_nan_result = parse_inf_nan(body, negative);
return match parse_inf_nan_result {
Some(value) => (
Ok(value),
Dec2FltTrace::Special {
body,
negative,
parse_number_result,
parse_inf_nan_result,
result: value,
},
),
None => (
Err(pfe_invalid()),
Dec2FltTrace::Invalid {
body,
negative,
parse_number_result,
parse_inf_nan_result,
},
),
};
}
};
Thus every `Err` arm shown here returns before `parsed` is available and before
the native, integer, slow, assembly, or final-negation code below it can run.
On a numeric result, the lexical sign is copied into the parsed record before
the native attempt, whose successful result also returns before raw-pair
assembly:
let mut num = parsed;
num.negative = negative;
if !cfg!(feature = "optimize_for_size") {
let fast_path_result = num.try_fast_path::<F>();
if let Some(value) = fast_path_result {
return (
Ok(value),
Dec2FltTrace::FastPath {
body,
negative,
parse_number_result,
fast_path_input: num,
fast_path_result,
result: value,
},
);
}
}
If the native attempt does not return, the selected raw pair is assembled and
the source then conditionally negates it according to the lexical-sign flag:
let selected_pair = fp;
// This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
// it neither changes the selected pair nor introduces a new branch or call.
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
The public `dec2flt` executes that same route and returns its result projection;
it does not reimplement or reorder any parsing or float operation:
/// Converts a decimal string into a floating point number.
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<
F: Lemire
+ core::ops::Div<Output = F>
+ core::ops::Mul<Output = F>
+ core::ops::Neg<Output = F>,
>(
s: &str,
) -> Result<F, ParseFloatError> {
// `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
// clause admits exactly the same instances and lets Charon resolve the
// explicit, source-equivalent final negation.
// The public function is now exactly the result projection of the single
// instrumented implementation. No conversion step is duplicated, and
// discarding the trace cannot affect Rust evaluation or the returned bits.
dec2flt_with_trace::<F>(s).0
}
The integer-tier helper has the source type and exact executable excerpts
below (long explanatory comments are elided). In particular it returns a raw
BiasedFp and contains no from_u64 cast, primitive float multiplication,
division, negation, or from_bits call:
pub fn compute_float<F: Float>(q: i64, mut w: u64) -> BiasedFp {
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let fp_error = BiasedFp::zero_pow2(-1);
// Short-circuit if the value can only be a literal 0 or infinity.
if w == 0 || q < F::SMALLEST_POWER_OF_TEN as i64 {
return fp_zero;
} else if q > F::LARGEST_POWER_OF_TEN as i64 {
return fp_inf;
}
// Normalize our significant digits, so the most-significant bit is set.
let lz = w.leading_zeros();
w <<= lz;
let (lo, hi) = compute_product_approx(q, w, F::SIG_BITS as usize + 3);
if lo == 0xFFFF_FFFF_FFFF_FFFF {
let inside_safe_exponent = (q >= -27) && (q <= 55);
if !inside_safe_exponent {
return fp_error;
}
}
let upperbit = (hi >> 63) as i32;
let mut mantissa = hi >> (upperbit + 64 - F::SIG_BITS as i32 - 3);
let mut power2 = power(q as i32) + upperbit - lz as i32 - F::EXP_MIN + 1;
if power2 <= 0 {
if -power2 + 1 >= 64 {
// Have more than 64 bits below the minimum exponent, must be 0.
return fp_zero;
}
// Have a subnormal value.
mantissa >>= -power2 + 1;
mantissa += mantissa & 1;
mantissa >>= 1;
power2 = (mantissa >= (1_u64 << F::SIG_BITS)) as i32;
return BiasedFp { m: mantissa, p_biased: power2 };
}
// Need to handle rounding ties. Normally, we need to round up,
// but if we fall right in between and we have an even basis, we
// need to round down.
if lo <= 1
&& q >= F::MIN_EXPONENT_ROUND_TO_EVEN as i64
&& q <= F::MAX_EXPONENT_ROUND_TO_EVEN as i64
&& mantissa & 0b11 == 0b01
&& (mantissa << (upperbit + 64 - F::SIG_BITS as i32 - 3)) == hi
{
// Zero the lowest bit, so we don't round up.
mantissa &= !1_u64;
}
// Round-to-even, then shift the significant digits into place.
mantissa += mantissa & 1;
mantissa >>= 1;
if mantissa >= (2_u64 << F::SIG_BITS) {
// Rounding up overflowed, so the carry bit is set. Set the
// mantissa to 1 (only the implicit, hidden bit is set) and
// increase the exponent.
mantissa = 1_u64 << F::SIG_BITS;
power2 += 1;
}
// Zero out the hidden bit.
mantissa &= !(1_u64 << F::SIG_BITS);
if power2 >= F::INFINITE_POWER {
// Exponent is above largest normal value, must be infinite.
return fp_inf;
}
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact slow-tier source body from crate/dec2flt/slow.rs:
pub(crate) fn parse_long_mantissa<F: Float>(s: &[u8]) -> BiasedFp {
const MAX_SHIFT: usize = 60;
const NUM_POWERS: usize = 19;
const POWERS: [u8; 19] =
[0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
let get_shift = |n| {
if n < NUM_POWERS { POWERS[n] as usize } else { MAX_SHIFT }
};
let fp_zero = BiasedFp::zero_pow2(0);
let fp_inf = BiasedFp::zero_pow2(F::INFINITE_POWER);
let mut d = parse_decimal_seq(s);
// Short-circuit if the value can only be a literal 0 or infinity.
if d.num_digits == 0 || d.decimal_point < -324 {
return fp_zero;
} else if d.decimal_point >= 310 {
return fp_inf;
}
let mut exp2 = 0_i32;
let mut loop_result = None;
// Shift right toward (1/2 ... 1].
while d.decimal_point > 0 && loop_result.is_none() {
let n = d.decimal_point as usize;
let shift = get_shift(n);
d.right_shift(shift);
if d.decimal_point < -DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_zero);
} else {
exp2 += shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// Shift left toward (1/2 ... 1].
while d.decimal_point <= 0 && loop_result.is_none() {
let shift = if d.decimal_point == 0 {
match d.digits[0] {
digit if digit >= 5 => break,
0 | 1 => 2,
_ => 1,
}
} else {
get_shift((-d.decimal_point) as _)
};
d.left_shift(shift);
if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {
loop_result = Some(fp_inf);
} else {
exp2 -= shift as i32;
}
}
if let Some(result) = loop_result {
return result;
}
// We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2].
exp2 -= 1;
while F::EXP_MIN > exp2 {
let mut n = (F::EXP_MIN - exp2) as usize;
if n > MAX_SHIFT {
n = MAX_SHIFT;
}
d.right_shift(n);
exp2 += n as i32;
}
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
// Shift the decimal to the hidden bit, and then round the value
// to get the high mantissa+1 bits.
d.left_shift(F::SIG_BITS as usize + 1);
let mut mantissa = d.round();
if mantissa >= (1_u64 << (F::SIG_BITS + 1)) {
// Rounding up overflowed to the carry bit, need to
// shift back to the hidden bit.
d.right_shift(1);
exp2 += 1;
mantissa = d.round();
if (exp2 - F::EXP_MIN + 1) >= F::INFINITE_POWER {
return fp_inf;
}
}
let mut power2 = exp2 - F::EXP_MIN + 1;
if mantissa < (1_u64 << F::SIG_BITS) {
power2 -= 1;
}
// Zero out all the bits above the explicit mantissa bits.
mantissa &= (1_u64 << F::SIG_BITS) - 1;
BiasedFp { m: mantissa, p_biased: power2 }
}
Exact final numeric-sign excerpt from crate/dec2flt/mod.rs:
let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
let assembly_result = biased_fp_to_float::<F>(fp);
let lexical_sign_applied = num.negative;
let result = if lexical_sign_applied {
core::ops::Neg::neg(assembly_result)
} else {
assembly_result
};
Thus a numeric execution that reaches the integer/slow selection route
assembles its selected pair with from_bits through biased_fp_to_float and only
then conditionally negates it. A successful try_fast_path returns earlier and
does not perform this assembly. compute_float and parse_long_mantissa produce
raw BiasedFp pairs and do not call from_u64, primitive float multiplication,
division, negation, or from_bits; they do, however, execute constants derived
from SIG_TOTAL_BITS before producing those pairs.
Retained structural-boundary evidence
-------------------------------------
Several adjacent structural bindings cite this same evidence record. Their
pinned library source identities are:
core/src/num/mod.rs
f0820f9dfb94999440c8cb4a349736fa21df7e5668e19b6b49e016ff67c05ce3
core/src/option.rs
7cf61204b05d98a95bc2e322d5fbfc1f4f91505109971917d9a7fb47151c50e6
core/src/slice/mod.rs
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840
core/src/str/mod.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78
Exact ASCII-digit body from core/src/num/mod.rs:
pub const fn is_ascii_digit(&self) -> bool {
matches!(*self, b'0'..=b'9')
}
Exact Option control-flow bodies from core/src/option.rs:
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
fn from_residual(residual: Option<convert::Infallible>) -> Self {
match residual {
None => None,
}
}
Exact slice observation bodies from core/src/slice/mod.rs:
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
}
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
}
Exact string-byte body from core/src/str/mod.rs:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
reference/model-evidence/binary64-probe.rs
#![feature(float_masks)]
use std::num::FpCategory;
fn bits(label: &str, value: f64) {
println!("{label}={:016x}", value.to_bits());
}
fn main() {
println!("target_arch={}", std::env::consts::ARCH);
println!("mantissa_digits={}", f64::MANTISSA_DIGITS);
println!("exponent_mask={:016x}", f64::EXPONENT_MASK);
println!("mantissa_mask={:016x}", f64::MANTISSA_MASK);
bits("nan", f64::NAN);
bits("infinity", f64::INFINITY);
bits("neg_infinity", f64::NEG_INFINITY);
for (label, value) in [
("nan_category", f64::NAN),
("infinity_category", f64::INFINITY),
("zero_category", 0.0),
("subnormal_category", f64::from_bits(1)),
("normal_category", 1.0),
] {
let category = match value.classify() {
FpCategory::Nan => "Nan",
FpCategory::Infinite => "Infinite",
FpCategory::Zero => "Zero",
FpCategory::Subnormal => "Subnormal",
FpCategory::Normal => "Normal",
};
println!("{label}={category}");
}
let payload_nan_word = 0x7ff0_0000_0000_0001_u64;
println!(
"from_bits_to_bits={:016x}",
f64::from_bits(payload_nan_word).to_bits()
);
bits("neg_payload_nan", -f64::from_bits(payload_nan_word));
bits("neg_zero", -0.0);
bits("subnormal_tie_to_even_zero", f64::from_bits(1) * 0.5);
bits("subnormal_tie_to_even_two", f64::from_bits(3) * 0.5);
bits("normal_division", 1.0 / 10.0);
bits("mul_negative_zero", -0.0 * 2.0);
bits("div_negative_zero", -1.0 / f64::INFINITY);
bits("div_negative_infinity", 1.0 / -0.0);
bits("mul_overflow", f64::MAX * (1.0 + f64::EPSILON));
println!("mul_zero_infinity_is_nan={}", (0.0 * f64::INFINITY).is_nan());
println!("div_zero_zero_is_nan={}", (0.0_f64 / 0.0_f64).is_nan());
println!("mul_nan_is_nan={}", (f64::NAN * 1.0).is_nan());
bits("cast_2_pow_53", (1_u64 << 53) as f64);
bits("cast_2_pow_53_plus_1", ((1_u64 << 53) + 1) as f64);
}
reference/model-evidence/goal-vocabulary.txt
CURRENT GOAL-VOCABULARY PRIMARY EVIDENCE
Date: 2026-10-09; current source, not predecessor.
COMMAND: sha256sum generated.lean GOAL.md modeling-input/manifest.json upstream/dec2flt/parse.rs crate/dec2flt/parse.rs upstream/dec2flt/decimal_seq.rs crate/dec2flt/decimal_seq.rs upstream/dec2flt/mod.rs crate/dec2flt/mod.rs
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
0f19c63a168623bd805c17b753dff6f74a695ff283680c22d356fb623fbb4771 GOAL.md
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
COMMAND: sed -n '3,24p' GOAL.md
## Scope and vocabulary
The subject is the `f64` specialization of Rust's decimal parser and its
helper functions, including executions with integer overflow checks enabled.
Public results are the returned floats and errors.
A numeric literal has an optional leading sign, an ASCII decimal significand
with at least one digit and at most one decimal point, and an optional `e` or
`E` exponent with an optional sign and at least one ASCII digit. Special
literals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,
with an optional leading sign. The whole input must match; whitespace and
other extra characters are invalid. An unsigned literal omits the leading
sign, while its exponent may still have a sign.
The exact value of a numeric literal is its ordinary mathematical decimal
value. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,
including subnormal results, signed zero, and overflow to infinity.
For auxiliary claims, the **accumulated-exponent value** retains every
significand digit but interprets the explicit exponent using the source's
bounded exponent-accumulation rule. This is an implementation-level diagnostic
value, distinct from the exact value required by the public contract.
COMMAND: nl -ba upstream/dec2flt/parse.rs | sed -n '73,102p'
73 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
74 let mut exponent = 0i64;
75 let mut negative = false;
76
77 let mut s = *s_ref;
78
79 if let Some((&c, s_next)) = s.split_first() {
80 negative = c == b'-';
81 if c == b'-' || c == b'+' {
82 s = s_next;
83 }
84 }
85
86 if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
87 *s_ref = s.parse_digits(|digit| {
88 // The exponent is at most 10 * 2^59 - 1, which fits in i64.
89 if exponent < (1_i64 << 59) {
90 exponent = 10 * exponent + digit as i64;
91 }
92 });
93 if negative { Some(-exponent) } else { Some(exponent) }
94 } else {
95 *s_ref = s;
96 None
97 }
98 }
99
100 /// Parse a partial, non-special floating point number.
101 ///
102 /// This creates a representation of the float as the
COMMAND: nl -ba crate/dec2flt/parse.rs | sed -n '121,158p'
121 pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {
122 let mut exponent = 0i64;
123 let mut negative = false;
124
125 let mut s = *s_ref;
126
127 if let Some((&c, s_next)) = s.split_first() {
128 negative = c == b'-';
129 if c == b'-' || c == b'+' {
130 s = s_next;
131 }
132 }
133
134 // `matches!` with a guarded slice pattern triggers an Aeneas internal
135 // error. This short-circuit test reads the same first byte exactly when
136 // it exists and therefore preserves both acceptance and evaluation order.
137 if !s.is_empty() && s[0].is_ascii_digit() {
138 // Specialized form of the revised source callback, shared with the
139 // sibling slow parser. The guard tests the pre-update accumulator:
140 // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
141 // i64::MAX. This is not a clamp. Subsequent digits are still consumed
142 // and the first nondigit remains in the returned suffix, so the caller
143 // performs the same whole-input validation even after updates stop.
144 let mut count = 0;
145 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
146 let digit = s[count].wrapping_sub(b'0');
147 if exponent < (1_i64 << 59) {
148 exponent = 10 * exponent + digit as i64;
149 }
150 count += 1;
151 }
152 *s_ref = &s[count..];
153 if negative { Some(-exponent) } else { Some(exponent) }
154 } else {
155 *s_ref = s;
156 None
157 }
158 }
COMMAND: nl -ba upstream/dec2flt/decimal_seq.rs | sed -n '224,304p'
224 pub(super) fn final_decimal_point(
225 significant_count: usize,
226 fractional_count: usize,
227 explicit: i64,
228 ) -> i32 {
229 if significant_count == 0 {
230 return 0;
231 }
232 let base = significant_count as i64 - fractional_count as i64;
233 base.saturating_add(explicit)
234 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
235 as i32
236 }
237
238 /// Parse a big integer representation of the float as a decimal.
239 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
240 let mut d = DecimalSeq::default();
241 let start = s;
242 let mut fractional_count = 0;
243
244 while let Some((&b'0', s_next)) = s.split_first() {
245 s = s_next;
246 }
247
248 s = s.parse_digits(|digit| d.try_add_digit(digit));
249
250 if let Some((b'.', s_next)) = s.split_first() {
251 s = s_next;
252 let first = s;
253 // Skip leading zeros.
254 if d.num_digits == 0 {
255 while let Some((&b'0', s_next)) = s.split_first() {
256 s = s_next;
257 }
258 }
259 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
260 let v = s.read_u64();
261 if !is_8digits(v) {
262 break;
263 }
264 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
265 d.num_digits += 8;
266 s = &s[8..];
267 }
268 s = s.parse_digits(|digit| d.try_add_digit(digit));
269 fractional_count = first.len() - s.len();
270 }
271
272 let significant_count = d.num_digits;
273 if d.num_digits != 0 {
274 // Ignore the trailing zeros if there are any
275 let mut n_trailing_zeros = 0;
276 for &c in start[..(start.len() - s.len())].iter().rev() {
277 if c == b'0' {
278 n_trailing_zeros += 1;
279 } else if c != b'.' {
280 break;
281 }
282 }
283 d.num_digits -= n_trailing_zeros;
284 if d.num_digits > DecimalSeq::MAX_DIGITS {
285 d.truncated = true;
286 d.num_digits = DecimalSeq::MAX_DIGITS;
287 }
288 }
289
290 let mut explicit = 0;
291 if let Some((&ch, s_next)) = s.split_first() {
292 if ch == b'e' || ch == b'E' {
293 s = s_next;
294 explicit = parse_scientific(&mut s).unwrap_or(0);
295 }
296 }
297 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
298
299 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
300 d.digits[i] = 0;
301 }
302
303 d
304 }
COMMAND: nl -ba crate/dec2flt/decimal_seq.rs | sed -n '269,373p'
269 pub(super) fn final_decimal_point(
270 significant_count: usize,
271 fractional_count: usize,
272 explicit: i64,
273 ) -> i32 {
274 // This is the repaired upstream body, not an extraction replacement.
275 // Source-valid byte slices bound both counts by isize::MAX on this target;
276 // their i64 difference is therefore in range. Retain saturating_add and
277 // clamp as source operations, including the zero-count early return.
278 if significant_count == 0 {
279 return 0;
280 }
281 let base = significant_count as i64 - fractional_count as i64;
282 base.saturating_add(explicit)
283 .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)
284 as i32
285 }
286
287 /// Parse a big integer representation of the float as a decimal.
288 pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {
289 let mut d = DecimalSeq::default();
290 let start = s;
291 let mut fractional_count = 0;
292
293 // Aeneas rejects the literal-pattern `while let`; this loop performs the
294 // same nonempty check, byte comparison, and one-byte consumption in the
295 // same order, with identical slice bounds.
296 while !s.is_empty() && s[0] == b'0' {
297 s = &s[1..];
298 }
299
300 s = parse_digits_into_seq(s, &mut d);
301
302 if !s.is_empty() && s[0] == b'.' {
303 s = &s[1..];
304 let first = s;
305 // Skip leading zeros.
306 if d.num_digits == 0 {
307 // As above, this is the source leading-zero loop written in the
308 // indexed form accepted by Aeneas.
309 while !s.is_empty() && s[0] == b'0' {
310 s = &s[1..];
311 }
312 }
313 while s.len() >= 8 && d.num_digits + 8 < DecimalSeq::MAX_DIGITS {
314 let v = s.read_u64();
315 if !is_8digits(v) {
316 break;
317 }
318 d.digits[d.num_digits..].write_u64(v - 0x3030_3030_3030_3030);
319 d.num_digits += 8;
320 s = &s[8..];
321 }
322 s = parse_digits_into_seq(s, &mut d);
323 // `first` precedes zero skipping and both digit scans. This difference
324 // includes every fractional digit, just as in repaired upstream.
325 fractional_count = first.len() - s.len();
326 }
327
328 // Save the source's logical count before trimming and MAX_DIGITS capping;
329 // the stored digit prefix must not replace this count in point arithmetic.
330 let significant_count = d.num_digits;
331 if d.num_digits != 0 {
332 // Ignore the trailing zeros if there are any
333 let consumed_len = start.len() - s.len();
334 // Walking an index downward visits exactly the same bytes as
335 // `.iter().rev()` and stops on the same first nonzero nondot byte. It
336 // also avoids the missing extracted `Iterator::rev` library field.
337 let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
338 d.num_digits -= n_trailing_zeros;
339 if d.num_digits > DecimalSeq::MAX_DIGITS {
340 d.truncated = true;
341 d.num_digits = DecimalSeq::MAX_DIGITS;
342 }
343 }
344
345 // Indexed tests preserve `split_first`'s nonempty guard and byte order but
346 // avoid the loop-context joins Aeneas creates for nested slice patterns.
347 let mut explicit = 0;
348 if !s.is_empty() {
349 let ch = s[0];
350 if ch == b'e' || ch == b'E' {
351 // Aeneas cannot join this branch when the enclosing `s` is
352 // rebased and mutably borrowed. A fresh slice local translates.
353 // The source never reads `s` after this call: all consumed-prefix,
354 // significant and fractional counts are already saved. Passing
355 // the identical suffix to the unchanged shared parser gives the
356 // same sign, digit consumption, bounded accumulation, checked
357 // operations and failures; only its unobserved suffix mutation
358 // targets a different local. Keep the call even for zero digits,
359 // and keep None-to-zero on missing/malformed exponent digits.
360 // This argument needs no numeric-validity or correctness premise;
361 // parse_number still observes the shared parser's returned suffix.
362 let mut exponent_suffix = &s[1..];
363 explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
364 }
365 }
366 d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);
367
368 for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {
369 d.digits[i] = 0;
370 }
371
372 d
373 }
COMMAND: sed -n '1664,1770p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::final_decimal_point]:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 269:0-285:1 -/
def num.imp.dec2flt.decimal_seq.final_decimal_point
(significant_count : Std.Usize) (fractional_count : Std.Usize)
(explicit : Std.I64) :
Result Std.I32
:= do
if significant_count = 0#usize
then ok 0#i32
else
let i ← lift (UScalar.hcast .I64 significant_count)
let i1 ← lift (UScalar.hcast .I64 fractional_count)
let base ← i - i1
let i2 ← lift (core.num.I64.saturating_add base explicit)
let i3 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i4 ← -. i3
let i5 ←
lift (IScalar.cast .I64
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE)
let i6 ← core.cmp.impls.OrdI64.clamp i2 i4 i5
ok (IScalar.cast .I32 i6)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop body 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop_body]
def num.imp.dec2flt.parse.parse_scientific_loop.body
(s : Slice Std.U8) (exponent : Std.I64) (count : Std.Usize) :
Result (ControlFlow (Std.I64 × Std.Usize) (Std.I64 × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let i3 ← 1#i64 <<< 59#i32
let exponent1 ←
if exponent < i3
then
do
let i4 ← 10#i64 * exponent
let i5 ← lift (UScalar.hcast .I64 digit)
i4 + i5
else ok exponent
let count1 ← count + 1#usize
ok (cont (exponent1, count1))
else ok (done (exponent, count))
else ok (done (exponent, count))
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]: loop 0:
Source: 'num/imp/../../dec2flt/parse.rs', lines 145:8-151:9 -/
@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
(exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
Result (Std.I64 × Std.Usize)
:= do
loop
(fun (exponent1, count1) =>
num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
(exponent, count)
/-- [dec2flt_model::num::imp::dec2flt::parse::parse_scientific]:
Source: 'num/imp/../../dec2flt/parse.rs', lines 121:0-158:1 -/
def num.imp.dec2flt.parse.parse_scientific
(s_ref : Slice Std.U8) : Result ((Option Std.I64) × (Slice Std.U8)) := do
let o ← core.slice.Slice.split_first s_ref
let (negative, s) ←
match o with
| none => ok (false, s_ref)
| some p =>
do
let (c, s_next) := p
let s1 ←
if c = 45#u8
then ok s_next
else if c = 43#u8
then ok s_next
else ok s_ref
ok (c = 45#u8, s1)
let b ← core.slice.Slice.is_empty s
if b
then ok (none, s)
else
let i ← Slice.index_usize s 0#usize
let b1 ← core.num.U8.is_ascii_digit i
if b1
then
let (exponent, count) ←
num.imp.dec2flt.parse.parse_scientific_loop 0#i64 s 0#usize
let s_ref1 ←
core.slice.index.Slice.index
(core.slice.index.SliceIndexRangeFromUsizeSlice Std.U8) s
{ start := count }
if negative
then let i1 ← -. exponent
ok (some i1, s_ref1)
else ok (some exponent, s_ref1)
else ok (none, s)
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::parse_decimal_seq]: loop body 0:
Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 296:4-298:5
Visibility: public -/
COMMAND: sed -n '3633,3649p' generated.lean
/-- [dec2flt_model::num::imp::dec2flt::biased_fp_to_float]:
Source: 'num/imp/../../dec2flt/mod.rs', lines 282:0-286:1 -/
def num.imp.dec2flt.biased_fp_to_float
{F : Type} {Clause0_Clause0_Int : Type} (traitsFloatExtInst :
num.imp.traits.FloatExt F Clause0_Clause0_Int)
(x : num.imp.dec2flt.common.BiasedFp) :
Result F
:= do
let i ← lift (IScalar.hcast .U64 x.p_biased)
let i1 ← traitsFloatExtInst.FloatInst.SIG_BITS
let i2 ← i <<< i1
let word ← lift (x.m ||| i2)
traitsFloatExtInst.from_u64_bits word
/-- [dec2flt_model::num::imp::dec2flt::Dec2FltAssemblyTrace]
Source: 'num/imp/../../dec2flt/mod.rs', lines 329:0-352:1
COMMAND: sed -n '202,209p' upstream/dec2flt/mod.rs
/// Converts a `BiasedFp` to the closest machine float type.
fn biased_fp_to_float<F: FloatExt>(x: BiasedFp) -> F {
let mut word = x.m;
word |= (x.p_biased as u64) << F::SIG_BITS;
F::from_u64_bits(word)
}
/// Converts a decimal string into a floating point number.
The explicit source accumulator tests its OLD value against T=2^59,
updates at most to E=10*T-1<I64::MAX, consumes all subsequent digits even
after updates stop, then returns the first nondigit suffix and applies sign.
This is not a clamp to T, not the old 65536 fold and not the stored point.
For source-valid length L<=2^63-1, saved n and f are each <=L; both I64
casts and their difference are exact. Point finalization absorbs I64
saturation in the final [-2047,2047] clip. n=0 returns point zero only after
the earlier shared exponent call. Normal None is defaulted to zero; fail
or divergence propagate and are not defaulted. Exact mathematical exponent,
full significand, complete grammar and rounding remain independent definitions.
reference/model-evidence/setup-reproduction.txt
Current source and extraction reproduction, 2026-10-09
=====================================================
This records extraction/provenance and support composition, not GOAL truth or
a whole-Tablet Lean closure certificate. Prior predecessor extraction checks
must not be substituted for current elaboration.
Command:
python3 .trellis/scripts/pv_modeling.py check-native . --fresh --output
.trellis/scratch/current-reproduction --timeout 1800
The command exited 0. The following exact structured field selection from
current-reproduction/provenance.json records the complete pass/fail checks
and composition identity; the full 24-binding inventory is in native-boundary.txt.
{
"passed": true,
"checks": {
"provenance_schema": true,
"setup_audit_current": true,
"adaptation_audit_current": true,
"source_basis": true,
"route_decisions": true,
"scope": true,
"declined_goals": true,
"resource_imports": true,
"effective_tools": true,
"resource_identity": true,
"tool_identities_current": true,
"resource_environment": true,
"lean_toolchain": true,
"library_resolution": true,
"library_imports": true,
"support_handoff": true,
"axiom_compatibility": true,
"crate_export": true,
"upstream_export": true,
"export:GOAL.md": true,
"export:modeling-input/goals.json": true,
"export:modeling-input/extraction.json": true,
"export:modeling-input/tool-identities.json": true,
"source_digests:pv_tablet.json": true,
"source_digests:trellis.config.json": true,
"source_digests:tcb_manifest.json": true,
"audited_modules": true,
"audited_model_export": true,
"bootstrap_receipt": true,
"model_support_composition": true,
"fresh_extraction_succeeds": true,
"fresh_model_export": true
},
"source_digest": {
"scope": "canonical_crate_tree_manifest",
"sha256": "31946794bce72fb8a8bc0de7e2e61f62c54a44ad6f5879b7c0886d7532ddd516",
"manifest": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/source-tree.json"
},
"error": "",
"tool_identity_differences": {},
"fresh_observation": "/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/observation.json",
"model_support": {
"matches": true,
"changed": false,
"mismatched_files": [],
"expected_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c",
"actual_sha256": "2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c"
}
}
Pinned extraction configuration:
{"crate":"crate","cargo_args":[],"charon_args":[],"aeneas_args":[]}
The effective source remains the audited f64/u64 library specialization,
x86_64-unknown-linux-gnu, nightly-2026-06-01, empty default features,
optimize_for_size disabled, dev profile with overflow checks and debug
assertions, 64-bit pointers and SSE2. The source tree was copied by the
supplied reproduction tool, not modified.
Pinned executable identity record (all identities checked current):
{
"cargo": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"sha256": "54e05dce8c9ca2f638cc3d87ec1a19425b5d0bf1f31aeb48cf4792aec5cadf27"
},
"charon": {
"path": "/home/leanagent/pv_spike/tools/charon/bin/charon",
"sha256": "6490034f368ce98f3e7ae5a28bf71ed56d03bdf1e3712e71376b96fc55baeade"
},
"aeneas": {
"path": "/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"sha256": "9f446d2aaf59e8e705e36d05cb993f1c6ab0e97f8dc6fd2f19907a86ede30922",
"emit_json": true
},
"lean": {
"path": "/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"sha256": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf"
},
"rustc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc",
"sha256": "162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b"
},
"rustdoc": {
"path": "/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustdoc",
"sha256": "2bf660d140310e28146e2c002dc6fcabd957c0a3b740be0419e6f8e5a9c87523"
}
}
Uncached extraction steps and their exact command arguments:
{
"steps": [
{
"name": "cargo",
"exit_code": 0,
"argv": [
"/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo",
"check",
"--offline"
],
"cached": false,
"seconds": 0.265,
"timeout": false
},
{
"name": "charon",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/charon/bin/charon",
"cargo",
"--preset=aeneas",
"--dest-file",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc",
"--",
"--offline"
],
"cached": false,
"seconds": 16.252,
"timeout": false
},
{
"name": "aeneas",
"exit_code": 0,
"argv": [
"/home/leanagent/pv_spike/tools/aeneas/bin/aeneas",
"-backend",
"lean",
"-dest",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated",
"-emit-json",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Generated/m.llbc"
],
"cached": false,
"seconds": 7.556,
"timeout": false
},
{
"name": "lean",
"exit_code": 1,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"-DmaxErrors=0",
"-o",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.olean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean"
],
"cached": false,
"seconds": 36.803,
"timeout": false
},
{
"name": "lean_axioms",
"exit_code": 0,
"argv": [
"/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean",
"--run",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/runtime/src/scripts/lean_preparation_axioms.lean",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/Lean/M.lean",
"M",
"/home/leanagent/math/dec2flt-r0003-runtime/dispatch/1/repo/.trellis/scratch/current-reproduction/extraction/axioms-M.json"
],
"cached": false,
"seconds": 42.425,
"timeout": false
}
],
"generated": null,
"summary": null
}
Raw generated.lean and fresh extraction/Generated/M.lean are byte-identical:
SHA256 438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9
Current modeling-input/manifest.json:
SHA256 4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
The raw Lean step exited 1 because the raw output deliberately has no F64
carrier and has 24 opaque external operation declarations. These are diagnosed
model-support boundary dependencies, not evidence of composed Tablet success.
The approved axiom scan exited 0; full retained Tablet elaboration is checked
separately with check.py tablet and the worker acceptance command.
Support inventory reconciliation, executed during this burst:
inspect-native gives 24 declarations; model-support.json has 24 bindings;
exact name, extracted_signature, rust_symbol and raw_declaration_sha256
match one-for-one, with zero mismatches.
compose-native --check: matches=true, changed=false, no mismatched files.
Raw extraction SHA256 is the current digest above.
Expected and actual Preamble SHA256:
2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c
170 composed extraction modules and all 24 operation bindings.
check.py model-support-check: ok=true, errors=[].
The declaration inventory and exact current binding table are recorded in
native-boundary.txt. The from_u64 whole-function declaration includes the
enabled assertion and cast; it is not a cast-only abstraction.
Primary logs retained by the supplied checker in current-reproduction:
cargo.log SHA256 a6c5f25572c65db5c47516eef5243f60f30199adaaab78d5b2e36b097aa885d6
charon.log SHA256 3eb0e73de082db83a61c6863cdcbf3ebec3b5df3a856111d4f3aa769b880f1f9
aeneas.log SHA256 cb12b20ba66e8652e82375c93c13547a9ab11af005e59c263eff7f0adf3e1e3c
observation.json SHA256 538f1431fbfb1d4fae30414049c76021813a45ed48458039a4f9ce4f95107d83
Current local-closure observations, 2026-10-09:
For each ordinary node N listed below:
python3 .trellis/scripts/check.py local-closure-axioms N .
--principal dec2flt_model.N --timeout-secs 600
For Preamble:
python3 .trellis/scripts/check.py local-closure-axioms Preamble .
--module-owner --timeout-secs 600
Every command exited 0 and returned returncode=0, status=ok, errors=[],
boundary_theorems=[], axiomization_check.agreed=true and skipped=false.
The records below pin the current source SHA256 and actual kernel axioms.
These are local records with exact declared dependency boundaries. They do
not replace certification of every retained owner or whole-Tablet activation.
{"node":"P9_T1_ExponentFoldBounds","source_sha256":"f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d","kernel_axioms":["Quot.sound","propext"]}
{"node":"P9_T1_FinalPointArithmetic","source_sha256":"051f816699994225b255e40a97678e07f9ccb27fce00a52afb91557ca9879e3b","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificLoopFold","source_sha256":"e027e03f43a848fae41cab46b9b8151886982f91a7fc26d976940906440b91c4","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificScannerFold","source_sha256":"9c2d45ae0b3b4961c81ced5b6db29cc347a64cdf0ffd545154beb677c4f28157","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ScientificVocabularyFold","source_sha256":"de164ddff77a61916e44213eef5751be36d840e6f416c588ce922a881adc5332","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_FinalPointExact","source_sha256":"fe4f0e9d3dcb48f4c0593533b6c0674ddae93276379dc9e491fb8d5d7b02e8d3","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_ActualDispatchFrameEquality","source_sha256":"3fcba38964503c59c5a9e5801f0f6699d50405dfccddd94f09c4eeba25d73e00","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificClassificationSourceLength","source_sha256":"6602cfd4f3b8cfcead77aa1375ced40a0be64fe81bc3320796fa8ac819b1e5f7","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificPrefixSafeLength","source_sha256":"c3e085507ed3a3a9f32621133c119707898e0ecc30ed532ca14129d38653b162","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificRenderedSuffixSafeLength","source_sha256":"650340941d9af95d96f91a51dd18641ae7cc18cbdafcc1bb0d03c710a520e924","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificShortSuffixSafeLength","source_sha256":"8a2306b11891a639f0a7ca338ab149c8b3dacf0bb371f6cad1e8cd55af4131d9","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSignedSuffixSafeLength","source_sha256":"5d0ebb3468d46e05592ab7463cdd42512e83c990157ae4cb026f667d1514f4aa","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSafeLength","source_sha256":"6b7c86316e36a2ca404a3b47915c1bc685906304b27e58bff768c45288d9ac6e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"NumberHelperScientificSuffixSharpSafeLength","source_sha256":"5ddb779a5392498d6bc304a1f871258dd09e8276091ef782018f4d96701fb657","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"ExponentValueAgreement","source_sha256":"003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DecimalGoalVocabularyDefault","source_sha256":"2776b4e144c6f442f32a15e697db2207474ac960013252aa73e90bfa6d5e746a","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"DispatchContracts","source_sha256":"ce5841ff10cd1b05c88e4532a5d929cf655fd36982904c32a37190d4b3c1d80e","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_AbstractComponents","source_sha256":"4db6fc868ba05ac588875e9c80fee55e4be5b79b4b874c1de8b227b6be13410e","kernel_axioms":["propext"]}
{"node":"P9_T1_ActualDispatchOperations","source_sha256":"00b382ce5eb133a085667540397d5d3f125f5164a195a6609328cc3ebfeaf23c","kernel_axioms":[]}
{"node":"P9_T1_DispatchFrame","source_sha256":"f06ef6bb5fe691d7024b708f0bc2b090fc9064c40c808b99d05b23a96b90ca47","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"P9_T1_DispatchOperations","source_sha256":"e78139fa2c5c900a598e3d73e141219e43ec5c994704592e7e9985c89f689eb9","kernel_axioms":["propext"]}
{"node":"P9_T1_EmbedComponents","source_sha256":"564a9cdf36860b8fc296ff269a3a3e45fab29201547670ee79b9c139eaccd5d5","kernel_axioms":["propext"]}
{"node":"P9_T1_NormalComponentRefinement","source_sha256":"e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9","kernel_axioms":["propext"]}
{"node":"P9_T1_DispatchCall","source_sha256":"09d3127aa1aa58e8241605b28e54e0d41bd499f5c4a2513e0ad529401d6388c7","kernel_axioms":["propext"]}
{"node":"P9_T1_ReachedDispatchCall","source_sha256":"6a395027f7f99b757601d904c92280826b5fc020df902508bc7f66168ee00985","kernel_axioms":["Classical.choice","Quot.sound","propext"]}
{"node":"Preamble","source_sha256":"2bf9c25b895e20dd9efe782ae173e2b07b55020eed41a7d9b63b2ae9e1db007c","kernel_axioms":["propext"]}
Whole-build environment failure, not a successful Tablet check:
Managed all-retained build job 479cf169c8064036a9f9f349c59109bf exited 1.
The failing target was Mathlib.Topology.ContinuousOn, with:
error: read-only file system (error code 30)
file: .lake/packages/mathlib/.lake/build/lib/lean/
Mathlib/Topology/ContinuousOn.ir.hash
The authored modules otherwise built. Ordinary check.py node also rejects
replayed sorry warnings from Aeneas/Std/Slice.lean:364:4, while the explicit
local-closure observations above succeed. No warning was hidden and no
library, checker or cache was edited.
Subsequent prescribed whole-Tablet check:
python3 .trellis/scripts/check.py tablet . --json
Completed with process exit 0, ok=true, errors=[] and 347 retained nodes.
The earlier advisory aggregate scratch build failure remains diagnostic
history, not a failure of this subsequent mandatory whole-Tablet check.
Replayed installed-library sorry warnings remain warnings in this result;
explicit local-closure checks above audit the actual authored declarations.
The two new dispatch principal GOAL proofs remain intentionally open.
reference/model-evidence/source-adaptation-delta.diff
--- upstream/dec2flt/common.rs
+++ crate/dec2flt/common.rs
@@ -4,0 +5,4 @@
+ // The removed closure-based parse_digits operation is specialized at its
+ // former call sites in parse.rs and decimal_seq.rs. Their comments record
+ // the same byte test, callback update order, and first-nondigit suffix;
+ // removing this unused trait method adds no new source behavior.
@@ -14,4 +17,0 @@
- /// Iteratively parse and consume digits from bytes.
- ///
- /// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
- fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
@@ -38,16 +37,0 @@
- #[inline]
- fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
- let mut s = self;
-
- while let Some((c, rest)) = s.split_first() {
- let c = c.wrapping_sub(b'0');
- if c < 10 {
- func(c);
- s = rest;
- } else {
- break;
- }
- }
-
- s
- }
@@ -68 +52,4 @@
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
+// Debug output is not a scoped public or trace observation. Removing only
+// that implementation preserves the fields, computational derives, and every
+// algorithm operation independently of GOAL truth.
+#[derive(Copy, Clone, PartialEq, Eq, Default)]
--- upstream/dec2flt/decimal.rs
+++ crate/dec2flt/decimal.rs
@@ -28 +28,4 @@
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation leaves all fields, computational derives, and parser
+// operations unchanged independently of GOAL truth.
+#[derive(Clone, Copy, Default, PartialEq, Eq)]
@@ -56 +59,11 @@
- pub fn try_fast_path<F: Lemire>(&self) -> Option<F> {
+ pub fn try_fast_path<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+ >(
+ &self,
+ ) -> Option<F> {
+ // `Lemire` already entails these three operator bounds through
+ // `Float`; spelling them directly changes no admitted type. Charon
+ // needs the direct clauses to resolve each explicit call's `Output`.
@@ -73 +86,3 @@
- value / F::pow10_fast_path((-self.exponent) as _)
+ // Explicit trait calls preserve Rust arithmetic and resolve
+ // the generic output type that Charon leaves ambiguous.
+ core::ops::Div::div(value, F::pow10_fast_path((-self.exponent) as _))
@@ -75 +90 @@
- value * F::pow10_fast_path(self.exponent as _)
+ core::ops::Mul::mul(value, F::pow10_fast_path(self.exponent as _))
@@ -84 +99,4 @@
- F::from_u64(mantissa) * F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _)
+ core::ops::Mul::mul(
+ F::from_u64(mantissa),
+ F::pow10_fast_path(F::MAX_EXPONENT_FAST_PATH as _),
+ )
@@ -87 +105,5 @@
- if self.negative { Some(-value) } else { Some(value) }
+ if self.negative {
+ Some(core::ops::Neg::neg(value))
+ } else {
+ Some(value)
+ }
--- upstream/dec2flt/decimal_seq.rs
+++ crate/dec2flt/decimal_seq.rs
@@ -18 +18,4 @@
-#[derive(Clone, Debug, PartialEq)]
+// Debug output is absent from the scoped observations. Removing only that
+// implementation preserves the representation, Clone/PartialEq behavior, and
+// every fallback operation independently of GOAL truth.
+#[derive(Clone, PartialEq)]
@@ -177 +180,2 @@
- while (n >> shift) == 0 {
+ let mut all_zero = false;
+ while (n >> shift) == 0 && !all_zero {
@@ -182 +186,4 @@
- return;
+ // The source returns here from inside the loop. Recording the
+ // condition and returning immediately after the loop executes
+ // no intervening operation and preserves the unchanged value.
+ all_zero = true;
@@ -190,0 +198,3 @@
+ if all_zero {
+ return;
+ }
@@ -221,0 +232,35 @@
+// This is exactly the source reverse scan over the already-consumed prefix.
+// It is separate because Aeneas cannot join the loop while `parse_decimal_seq`
+// retains its other slice borrows. The downward index has the same visitation
+// order and counts precisely the same zero bytes while ignoring dots.
+fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {
+ let mut n_trailing_zeros = 0;
+ let mut i = consumed_len;
+ let mut scanning = true;
+ while i != 0 && scanning {
+ let c = start[i - 1];
+ if c == b'0' || c == b'.' {
+ i -= 1;
+ if c == b'0' {
+ n_trailing_zeros += 1;
+ }
+ } else {
+ scanning = false;
+ }
+ }
+ n_trailing_zeros
+}
+
+// Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.
+// An explicit index keeps the closure's mutable borrow out of the enclosing
+// parser context while retaining the same wrapping digit test and updates.
+fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
+ d.try_add_digit(digit);
+ count += 1;
+ }
+ &s[count..]
+}
+
@@ -228,0 +274,4 @@
+ // This is the repaired upstream body, not an extraction replacement.
+ // Source-valid byte slices bound both counts by isize::MAX on this target;
+ // their i64 difference is therefore in range. Retain saturating_add and
+ // clamp as source operations, including the zero-count early return.
@@ -244,2 +293,5 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // Aeneas rejects the literal-pattern `while let`; this loop performs the
+ // same nonempty check, byte comparison, and one-byte consumption in the
+ // same order, with identical slice bounds.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -248 +300 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
@@ -250,2 +302,2 @@
- if let Some((b'.', s_next)) = s.split_first() {
- s = s_next;
+ if !s.is_empty() && s[0] == b'.' {
+ s = &s[1..];
@@ -255,2 +307,4 @@
- while let Some((&b'0', s_next)) = s.split_first() {
- s = s_next;
+ // As above, this is the source leading-zero loop written in the
+ // indexed form accepted by Aeneas.
+ while !s.is_empty() && s[0] == b'0' {
+ s = &s[1..];
@@ -268 +322,3 @@
- s = s.parse_digits(|digit| d.try_add_digit(digit));
+ s = parse_digits_into_seq(s, &mut d);
+ // `first` precedes zero skipping and both digit scans. This difference
+ // includes every fractional digit, just as in repaired upstream.
@@ -271,0 +328,2 @@
+ // Save the source's logical count before trimming and MAX_DIGITS capping;
+ // the stored digit prefix must not replace this count in point arithmetic.
@@ -275,8 +333,5 @@
- let mut n_trailing_zeros = 0;
- for &c in start[..(start.len() - s.len())].iter().rev() {
- if c == b'0' {
- n_trailing_zeros += 1;
- } else if c != b'.' {
- break;
- }
- }
+ let consumed_len = start.len() - s.len();
+ // Walking an index downward visits exactly the same bytes as
+ // `.iter().rev()` and stops on the same first nonzero nondot byte. It
+ // also avoids the missing extracted `Iterator::rev` library field.
+ let n_trailing_zeros = count_trailing_zeros(start, consumed_len);
@@ -289,0 +345,2 @@
+ // Indexed tests preserve `split_first`'s nonempty guard and byte order but
+ // avoid the loop-context joins Aeneas creates for nested slice patterns.
@@ -291 +348,2 @@
- if let Some((&ch, s_next)) = s.split_first() {
+ if !s.is_empty() {
+ let ch = s[0];
@@ -293,2 +351,13 @@
- s = s_next;
- explicit = parse_scientific(&mut s).unwrap_or(0);
+ // Aeneas cannot join this branch when the enclosing `s` is
+ // rebased and mutably borrowed. A fresh slice local translates.
+ // The source never reads `s` after this call: all consumed-prefix,
+ // significant and fractional counts are already saved. Passing
+ // the identical suffix to the unchanged shared parser gives the
+ // same sign, digit consumption, bounded accumulation, checked
+ // operations and failures; only its unobserved suffix mutation
+ // targets a different local. Keep the call even for zero digits,
+ // and keep None-to-zero on missing/malformed exponent digits.
+ // This argument needs no numeric-validity or correctness premise;
+ // parse_number still observes the shared parser's returned suffix.
+ let mut exponent_suffix = &s[1..];
+ explicit = parse_scientific(&mut exponent_suffix).unwrap_or(0);
--- upstream/dec2flt/mod.rs
+++ crate/dec2flt/mod.rs
@@ -90 +90 @@
-use common::BiasedFp;
+pub use common::BiasedFp;
@@ -118,4 +118 @@
- const MAX_EXPONENT_FAST_PATH: i64 = {
- let log2_5 = f64::consts::LOG2_10 - 1.0;
- (Self::SIG_TOTAL_BITS as f64 / log2_5) as i64
- };
+ const MAX_EXPONENT_FAST_PATH: i64;
@@ -128,2 +125 @@
- const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 =
- Self::MAX_EXPONENT_FAST_PATH + (Self::SIG_TOTAL_BITS as f64 / f64::consts::LOG2_10) as i64;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64;
@@ -144,0 +141,4 @@
+// The f16 Lemire instance is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 parser/helper/trace body, native decision, checked
+// operation, debug assertion, return value, and scoped observation unchanged.
+#[cfg(any())]
@@ -145,0 +146,7 @@
+ // These are the exact integer results of the upstream compile-time float
+ // formulae for `SIG_TOTAL_BITS = 11`: floor(11/log2(5)) = 4 and
+ // 4 + floor(11/log2(10)) = 7. Concrete integers avoid unsupported const
+ // float arithmetic without changing either fast-path guard.
+ const MAX_EXPONENT_FAST_PATH: i64 = 4;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 7;
+
@@ -147,3 +154,11 @@
- #[allow(clippy::use_self)]
- const TABLE: [f16; 8] = [1e0, 1e1, 1e2, 1e3, 1e4, 0.0, 0.0, 0.];
- TABLE[exponent & 7]
+ // Each integer is the exact IEEE encoding of the corresponding
+ // upstream table literal; the masked lookup and fallback zeros are
+ // unchanged. Aeneas cannot translate arrays containing float values.
+ match exponent & 7 {
+ 0 => f16::from_bits(0x3C00),
+ 1 => f16::from_bits(0x4900),
+ 2 => f16::from_bits(0x5640),
+ 3 => f16::from_bits(0x63D0),
+ 4 => f16::from_bits(0x70E2),
+ _ => f16::from_bits(0),
+ }
@@ -152,0 +168,4 @@
+ // This method is exactly the upstream primitive `u64 as f16` conversion.
+ // Charon extracts the cast, but Aeneas reports it unreachable; making only
+ // this primitive boundary opaque preserves all guards and dispatcher logic.
+ #[charon::opaque]
@@ -158,0 +178,4 @@
+// The f32 Lemire instance is likewise unused by the retained f64
+// specialization, so disabling it cannot affect any retained body or observed
+// f64 execution independently of the correctness GOALs.
+#[cfg(any())]
@@ -159,0 +183,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 24`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 10;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 17;
+
@@ -161,4 +188,16 @@
- #[allow(clippy::use_self)]
- const TABLE: [f32; 16] =
- [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 0., 0., 0., 0., 0.];
- TABLE[exponent & 15]
+ // Bit constructors preserve the exact table values and masked lookup,
+ // while avoiding Aeneas's unsupported float-valued array constants.
+ match exponent & 15 {
+ 0 => f32::from_bits(0x3F80_0000),
+ 1 => f32::from_bits(0x4120_0000),
+ 2 => f32::from_bits(0x42C8_0000),
+ 3 => f32::from_bits(0x447A_0000),
+ 4 => f32::from_bits(0x461C_4000),
+ 5 => f32::from_bits(0x47C3_5000),
+ 6 => f32::from_bits(0x4974_2400),
+ 7 => f32::from_bits(0x4B18_9680),
+ 8 => f32::from_bits(0x4CBE_BC20),
+ 9 => f32::from_bits(0x4E6E_6B28),
+ 10 => f32::from_bits(0x5015_02F9),
+ _ => f32::from_bits(0),
+ }
@@ -167,0 +207,4 @@
+ // This is exactly the source `u64 as f32` conversion. The narrow opaque
+ // boundary is required because Aeneas rejects the primitive cast itself;
+ // its input guard and every caller remain transparent.
+ #[charon::opaque]
@@ -174,0 +218,4 @@
+ // Exact upstream formula results for `SIG_TOTAL_BITS = 53`.
+ const MAX_EXPONENT_FAST_PATH: i64 = 22;
+ const MAX_EXPONENT_DISGUISED_FAST_PATH: i64 = 37;
+
@@ -176,5 +223,29 @@
- const TABLE: [f64; 32] = [
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
- 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
- ];
- TABLE[exponent & 31]
+ // These bit patterns are exactly the source table's rounded binary64
+ // literals. The match is the same masked lookup; it merely keeps float
+ // constants out of Aeneas's unsupported constant interpreter.
+ match exponent & 31 {
+ 0 => f64::from_bits(0x3FF0_0000_0000_0000),
+ 1 => f64::from_bits(0x4024_0000_0000_0000),
+ 2 => f64::from_bits(0x4059_0000_0000_0000),
+ 3 => f64::from_bits(0x408F_4000_0000_0000),
+ 4 => f64::from_bits(0x40C3_8800_0000_0000),
+ 5 => f64::from_bits(0x40F8_6A00_0000_0000),
+ 6 => f64::from_bits(0x412E_8480_0000_0000),
+ 7 => f64::from_bits(0x4163_12D0_0000_0000),
+ 8 => f64::from_bits(0x4197_D784_0000_0000),
+ 9 => f64::from_bits(0x41CD_CD65_0000_0000),
+ 10 => f64::from_bits(0x4202_A05F_2000_0000),
+ 11 => f64::from_bits(0x4237_4876_E800_0000),
+ 12 => f64::from_bits(0x426D_1A94_A200_0000),
+ 13 => f64::from_bits(0x42A2_309C_E540_0000),
+ 14 => f64::from_bits(0x42D6_BCC4_1E90_0000),
+ 15 => f64::from_bits(0x430C_6BF5_2634_0000),
+ 16 => f64::from_bits(0x4341_C379_37E0_8000),
+ 17 => f64::from_bits(0x4376_3457_85D8_A000),
+ 18 => f64::from_bits(0x43AB_C16D_674E_C800),
+ 19 => f64::from_bits(0x43E1_58E4_6091_3D00),
+ 20 => f64::from_bits(0x4415_AF1D_78B5_8C40),
+ 21 => f64::from_bits(0x444B_1AE4_D6E2_EF50),
+ 22 => f64::from_bits(0x4480_F0CF_064D_D592),
+ _ => f64::from_bits(0),
+ }
@@ -183,0 +255,8 @@
+ // Aeneas cannot translate the source `u64 as f64` primitive conversion, so
+ // `charon::opaque` makes this entire asserted conversion external: both the
+ // unchanged `debug_assert!` and the unchanged cast below are in the opaque
+ // body. The callers, their fast-path guards, and their surrounding
+ // computation remain mechanically visible. A corresponding model binding
+ // must fail the assertion above `MAX_MANTISSA_FAST_PATH` and return the
+ // exact binary64 conversion at or below that bound.
+ #[charon::opaque]
@@ -209,5 +288,80 @@
-/// Converts a decimal string into a floating point number.
-#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
-pub fn dec2flt<F: Lemire>(s: &str) -> Result<F, ParseFloatError> {
- let mut s = s.as_bytes();
- let Some(&c) = s.first() else { return Err(pfe_empty()) };
+/// Observable control-flow record for a dispatcher execution.
+///
+/// These variants add no decisions to the conversion: each stores values
+/// already computed at the corresponding source branch. In particular, the
+/// first component returned by `dec2flt_with_trace` is the ordinary parser
+/// result, so projecting it preserves every public source observation without
+/// assuming any correctness goal.
+pub enum Dec2FltTrace<'a, F> {
+ /// The original string was empty; no helper was called.
+ EmptyInput,
+ /// Removing one lexical sign left an empty body; no helper was called.
+ SignOnly { body: &'a [u8], negative: bool },
+ /// Both lexical helpers returned `None`; no raw pair was selected.
+ Invalid {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ },
+ /// The special helper supplied the directly returned value; no pair was selected.
+ Special {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ parse_inf_nan_result: Option<F>,
+ result: F,
+ },
+ /// The ordinary native shortcut supplied the directly returned value.
+ FastPath {
+ body: &'a [u8],
+ negative: bool,
+ parse_number_result: Option<decimal::Decimal>,
+ fast_path_input: decimal::Decimal,
+ fast_path_result: Option<F>,
+ result: F,
+ },
+ /// The integer/slow path selected and assembled one raw pair.
+ Assembled(Dec2FltAssemblyTrace<'a, F>),
+}
+
+/// Full observation record for the dispatcher path that performs final assembly.
+pub struct Dec2FltAssemblyTrace<'a, F> {
+ pub body: &'a [u8],
+ pub negative: bool,
+ pub parse_number_result: Option<decimal::Decimal>,
+ pub fast_path_input: decimal::Decimal,
+ pub fast_path_result: Option<F>,
+ pub first_compute_exponent: i64,
+ pub first_compute_mantissa: u64,
+ pub first_compute_result: BiasedFp,
+ pub second_compute_guard: bool,
+ pub second_compute_exponent: Option<i64>,
+ pub second_compute_mantissa: Option<u64>,
+ pub second_compute_result: Option<BiasedFp>,
+ pub second_equals_first: Option<bool>,
+ pub forced_deferral: bool,
+ pub post_comparison_pair: BiasedFp,
+ pub slow_path_guard: bool,
+ pub slow_path_result: Option<BiasedFp>,
+ pub selected_pair: BiasedFp,
+ pub assembled_word: u64,
+ pub assembly_result: F,
+ pub lexical_sign_applied: bool,
+ pub result: F,
+}
+
+/// Run the actual dispatcher while retaining its goal-relevant internal observations.
+pub fn dec2flt_with_trace<
+ 'a,
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &'a str,
+) -> (Result<F, ParseFloatError>, Dec2FltTrace<'a, F>) {
+ let mut body = s.as_bytes();
+ let Some(&c) = body.first() else {
+ return (Err(pfe_empty()), Dec2FltTrace::EmptyInput);
+ };
@@ -216 +370 @@
- s = &s[1..];
+ body = &body[1..];
@@ -218,2 +372,2 @@
- if s.is_empty() {
- return Err(pfe_invalid());
+ if body.is_empty() {
+ return (Err(pfe_invalid()), Dec2FltTrace::SignOnly { body, negative });
@@ -222 +376,2 @@
- let mut num = match parse_number(s) {
+ let parse_number_result = parse_number(body);
+ let parsed = match parse_number_result {
@@ -224,2 +379,24 @@
- None if let Some(value) = parse_inf_nan(s, negative) => return Ok(value),
- None => return Err(pfe_invalid()),
+ None => {
+ let parse_inf_nan_result = parse_inf_nan(body, negative);
+ return match parse_inf_nan_result {
+ Some(value) => (
+ Ok(value),
+ Dec2FltTrace::Special {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ result: value,
+ },
+ ),
+ None => (
+ Err(pfe_invalid()),
+ Dec2FltTrace::Invalid {
+ body,
+ negative,
+ parse_number_result,
+ parse_inf_nan_result,
+ },
+ ),
+ };
+ }
@@ -226,0 +404,2 @@
+
+ let mut num = parsed;
@@ -229,2 +408,13 @@
- if let Some(value) = num.try_fast_path::<F>() {
- return Ok(value);
+ let fast_path_result = num.try_fast_path::<F>();
+ if let Some(value) = fast_path_result {
+ return (
+ Ok(value),
+ Dec2FltTrace::FastPath {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result,
+ result: value,
+ },
+ );
@@ -234,15 +424,27 @@
- // If significant digits were truncated, then we can have rounding error
- // only if `mantissa + 1` produces a different result. We also avoid
- // redundantly using the Eisel-Lemire algorithm if it was unable to
- // correctly round on the first pass.
- let mut fp = compute_float::<F>(num.exponent, num.mantissa);
- if num.many_digits
- && fp.p_biased >= 0
- && fp != compute_float::<F>(num.exponent, num.mantissa + 1)
- {
- fp.p_biased = -1;
- }
- // Unable to correctly round the float using the Eisel-Lemire algorithm.
- // Fallback to a slower, but always correct algorithm.
- if fp.p_biased < 0 {
- fp = parse_long_mantissa::<F>(s);
+ let first_compute_exponent = num.exponent;
+ let first_compute_mantissa = num.mantissa;
+ let first_compute_result = compute_float::<F>(first_compute_exponent, first_compute_mantissa);
+ let mut fp = first_compute_result;
+
+ // This expands the source short-circuit conjunction without moving the
+ // checked `mantissa + 1`: that addition and the second helper call still
+ // occur exactly when `many_digits && fp.p_biased >= 0`.
+ let second_compute_guard = num.many_digits && fp.p_biased >= 0;
+ let mut second_compute_exponent = None;
+ let mut second_compute_mantissa = None;
+ let mut second_compute_result = None;
+ let mut second_equals_first = None;
+ let mut forced_deferral = false;
+ if second_compute_guard {
+ let exponent = num.exponent;
+ let mantissa = num.mantissa + 1;
+ let second = compute_float::<F>(exponent, mantissa);
+ let equal = fp == second;
+ second_compute_exponent = Some(exponent);
+ second_compute_mantissa = Some(mantissa);
+ second_compute_result = Some(second);
+ second_equals_first = Some(equal);
+ if !equal {
+ fp.p_biased = -1;
+ forced_deferral = true;
+ }
@@ -249,0 +452 @@
+ let post_comparison_pair = fp;
@@ -251,5 +454,69 @@
- let mut float = biased_fp_to_float::<F>(fp);
- if num.negative {
- float = -float;
- }
- Ok(float)
+ let slow_path_guard = fp.p_biased < 0;
+ let mut slow_path_result = None;
+ if slow_path_guard {
+ // The exact slow-path input is the trace's common `body`; the guard
+ // records whether this call occurred, avoiding a duplicate live slice
+ // reference that Aeneas cannot join across this branch.
+ let replacement = parse_long_mantissa::<F>(body);
+ slow_path_result = Some(replacement);
+ fp = replacement;
+ }
+
+ let selected_pair = fp;
+ // This is the same pure cast/shift/OR used by `biased_fp_to_float`; recording
+ // it neither changes the selected pair nor introduces a new branch or call.
+ let assembled_word = fp.m | ((fp.p_biased as u64) << F::SIG_BITS);
+ let assembly_result = biased_fp_to_float::<F>(fp);
+ let lexical_sign_applied = num.negative;
+ let result = if lexical_sign_applied {
+ core::ops::Neg::neg(assembly_result)
+ } else {
+ assembly_result
+ };
+
+ (
+ Ok(result),
+ Dec2FltTrace::Assembled(Dec2FltAssemblyTrace {
+ body,
+ negative,
+ parse_number_result,
+ fast_path_input: num,
+ fast_path_result: None,
+ first_compute_exponent,
+ first_compute_mantissa,
+ first_compute_result,
+ second_compute_guard,
+ second_compute_exponent,
+ second_compute_mantissa,
+ second_compute_result,
+ second_equals_first,
+ forced_deferral,
+ post_comparison_pair,
+ slow_path_guard,
+ slow_path_result,
+ selected_pair,
+ assembled_word,
+ assembly_result,
+ lexical_sign_applied,
+ result,
+ }),
+ )
+}
+
+/// Converts a decimal string into a floating point number.
+#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
+pub fn dec2flt<
+ F: Lemire
+ + core::ops::Div<Output = F>
+ + core::ops::Mul<Output = F>
+ + core::ops::Neg<Output = F>,
+>(
+ s: &str,
+) -> Result<F, ParseFloatError> {
+ // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct
+ // clause admits exactly the same instances and lets Charon resolve the
+ // explicit, source-equivalent final negation.
+ // The public function is now exactly the result projection of the single
+ // instrumented implementation. No conversion step is duplicated, and
+ // discarding the trace cannot affect Rust evaluation or the returned bits.
+ dec2flt_with_trace::<F>(s).0
--- upstream/dec2flt/parse.rs
+++ crate/dec2flt/parse.rs
@@ -34,3 +34,6 @@
- let num = s.read_u64();
- if is_8digits(num) {
- x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(num));
+ // `chunk` is the source's local `num` under a nonconflicting name.
+ // The rename has no Rust effect and prevents the Lean backend from
+ // resolving `num.imp...` as a field projection on this local value.
+ let chunk = s.read_u64();
+ if is_8digits(chunk) {
+ x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));
@@ -43 +46,6 @@
- s = s.parse_digits(|digit| {
+ // This is the removed `ByteSlice::parse_digits` call specialized to this
+ // accumulator: identical wrapping digit classification, accumulator
+ // update, and first-nondigit stop, without an unsupported closure state.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -45 +53,3 @@
- });
+ count += 1;
+ }
+ s = &s[count..];
@@ -71,0 +82,38 @@
+// This is the source prefix scan isolated from `parse_partial_number` because
+// Aeneas cannot join its loop context while the enclosing function's other
+// slice borrows are live. It visits the same bytes, in order, and performs
+// the identical checked `isize` subtraction for every leading dot or zero.
+fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {
+ let mut scan_index = 0;
+ let mut scanning = true;
+ while scan_index < start.len() && scanning {
+ let c = start[scan_index];
+ if c == b'.' || c == b'0' {
+ n_digits -= c.saturating_sub(b'0' - 1) as isize;
+ scan_index += 1;
+ } else {
+ scanning = false;
+ }
+ }
+ n_digits
+}
+
+// This is the source many-digit retry as a transparent helper. Isolating its
+// rebased slices avoids an Aeneas context-join failure; both calls, the branch,
+// the offset arithmetic, and the explicit-exponent addition are unchanged.
+fn parse_many_digits(start: &[u8], int_end: &[u8], exp_number: i64) -> (u64, i64) {
+ let mut mantissa = 0;
+ let mut s = start;
+ try_parse_19digits(&mut s, &mut mantissa);
+ let mut exponent = if mantissa >= MIN_19DIGIT_INT {
+ int_end.offset_from(s)
+ } else {
+ s = &s[1..];
+ let before = s;
+ try_parse_19digits(&mut s, &mut mantissa);
+ -s.offset_from(before)
+ } as i64;
+ exponent += exp_number;
+ (mantissa, exponent)
+}
+
@@ -86,3 +134,13 @@
- if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {
- *s_ref = s.parse_digits(|digit| {
- // The exponent is at most 10 * 2^59 - 1, which fits in i64.
+ // `matches!` with a guarded slice pattern triggers an Aeneas internal
+ // error. This short-circuit test reads the same first byte exactly when
+ // it exists and therefore preserves both acceptance and evaluation order.
+ if !s.is_empty() && s[0].is_ascii_digit() {
+ // Specialized form of the revised source callback, shared with the
+ // sibling slow parser. The guard tests the pre-update accumulator:
+ // one digit can overshoot 2^59, up to 10 * 2^59 - 1, still below
+ // i64::MAX. This is not a clamp. Subsequent digits are still consumed
+ // and the first nondigit remains in the returned suffix, so the caller
+ // performs the same whole-input validation even after updates stop.
+ let mut count = 0;
+ while count < s.len() && s[count].wrapping_sub(b'0') < 10 {
+ let digit = s[count].wrapping_sub(b'0');
@@ -92 +150,3 @@
- });
+ count += 1;
+ }
+ *s_ref = &s[count..];
@@ -155,9 +215,5 @@
- let mut p = start;
- while let Some((&c, p_next)) = p.split_first() {
- if c == b'.' || c == b'0' {
- n_digits -= c.saturating_sub(b'0' - 1) as isize;
- p = p_next;
- } else {
- break;
- }
- }
+ // The indexed loop is equivalent to the source `while let split_first`:
+ // it tests nonemptiness before the same byte read and consumes one byte
+ // only on the two source continuation cases. This avoids Aeneas's loop
+ // context mismatch without changing checked subtraction or slice bounds.
+ n_digits = adjust_many_digit_count(start, n_digits);
@@ -167,14 +223,3 @@
- mantissa = 0;
- let mut s = start;
- try_parse_19digits(&mut s, &mut mantissa);
- exponent = if mantissa >= MIN_19DIGIT_INT {
- // big int
- int_end.offset_from(s)
- } else {
- s = &s[1..];
- let before = s;
- try_parse_19digits(&mut s, &mut mantissa);
- -s.offset_from(before)
- } as i64;
- // add back the explicit part
- exponent += exp_number;
+ let retried = parse_many_digits(start, int_end, exp_number);
+ mantissa = retried.0;
+ exponent = retried.1;
--- upstream/dec2flt/slow.rs
+++ crate/dec2flt/slow.rs
@@ -48,0 +49 @@
+ let mut loop_result = None;
@@ -50 +51 @@
- while d.decimal_point > 0 {
+ while d.decimal_point > 0 && loop_result.is_none() {
@@ -55 +56,7 @@
- return fp_zero;
+ // The source returns `fp_zero` at this exact point. Storing that
+ // result and terminating the loop performs no later loop update;
+ // the return below is therefore behavior-identical and avoids an
+ // Aeneas restriction on returns from nested loop translation.
+ loop_result = Some(fp_zero);
+ } else {
+ exp2 += shift as i32;
@@ -57 +64,3 @@
- exp2 += shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
@@ -60 +69 @@
- while d.decimal_point <= 0 {
+ while d.decimal_point <= 0 && loop_result.is_none() {
@@ -72 +81,6 @@
- return fp_inf;
+ // This records the source's immediate `fp_inf` return. Since the
+ // guarded loop exits before the exponent update, moving the return
+ // just below the loop preserves every state transition.
+ loop_result = Some(fp_inf);
+ } else {
+ exp2 -= shift as i32;
@@ -74 +88,3 @@
- exp2 -= shift as i32;
+ }
+ if let Some(result) = loop_result {
+ return result;
--- upstream/traits.rs
+++ crate/traits.rs
@@ -11 +11 @@
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
@@ -14 +14,5 @@
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
@@ -18,0 +23,4 @@
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
@@ -23 +30,0 @@
- + fmt::Debug
@@ -52 +59,6 @@
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
@@ -55,0 +68,6 @@
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
@@ -61,6 +78,0 @@
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
@@ -134,4 +146 @@
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
@@ -175,19 +184 @@
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
@@ -196,0 +188,4 @@
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
@@ -203 +198,4 @@
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
@@ -211,0 +210,2 @@
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
@@ -223,0 +224,3 @@
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
@@ -228,0 +232,16 @@
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
@@ -230,0 +250,3 @@
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
@@ -237 +259,3 @@
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
@@ -245,0 +270,2 @@
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
@@ -256,0 +283,3 @@
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
@@ -261,0 +291,16 @@
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
@@ -270 +315,3 @@
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
@@ -278,0 +326,2 @@
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
@@ -293,0 +343,16 @@
+ }
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
reference/model-evidence/source-adaptation-delta.txt
Primary inventory and preservation analysis of the upstream-to-crate delta
============================================================================
Method and complete file inventory
----------------------------------
This record compares the supplied files in upstream/ with the frozen adapted
crate/. It treats the sources and their control flow as primary evidence; it
does not use a prior route decision as semantic proof and makes no assertion
that a supplied GOAL is true. The exact raw aggregate diff is retained as
reference/model-evidence/source-adaptation-delta.diff. It was generated from
the repository root by this exact command (the for-list is the complete
LC_ALL=C-sorted upstream inventory, identical files contribute zero bytes,
labels are literal root-relative paths, hunks are concatenated in listed
order, status 1 is accepted as diff's expected ``files differ'' status, and
every other nonzero status aborts):
export LC_ALL=C
artifact=reference/model-evidence/source-adaptation-delta.diff
: > "$artifact"
saw_difference=0
for supplied in \
dec2flt/common.rs \
dec2flt/decimal.rs \
dec2flt/decimal_seq.rs \
dec2flt/fpu.rs \
dec2flt/lemire.rs \
dec2flt/mod.rs \
dec2flt/parse.rs \
dec2flt/slow.rs \
dec2flt/table.rs \
traits.rs
do
if diff --unified=0 --label "upstream/$supplied" --label "crate/$supplied" \
"upstream/$supplied" "crate/$supplied" >> "$artifact"; then
:
else
diff_status=$?
if [ "$diff_status" -ne 1 ]; then
exit "$diff_status"
fi
saw_difference=1
fi
done
test "$saw_difference" -eq 1
sha256sum "$artifact"
The command used GNU diffutils 3.12 at /usr/bin/diff, whose SHA-256 is
dfab4814355b488934cf8c63ce96d94184ea3d9b5e4f9be50278ad8e080168f5.
Its actual final output was:
1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6 reference/model-evidence/source-adaptation-delta.diff
The retained current byte stream is the exact aggregate of GNU diff --unified=0
on all ten supplied paths, with the same labels and order as above.
The current full source inventory has these SHA-256 identities:
fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace upstream/dec2flt/common.rs
1630bcba29ed89ed899cf814d6a36567df612e16af7c68f04bde715d1eb15593 crate/dec2flt/common.rs
3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d upstream/dec2flt/decimal.rs
f8b69dc3816e99391e45dfa95d4bfa02eafe9f5b1ef8e216d0cbc30d335a0025 crate/dec2flt/decimal.rs
7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d upstream/dec2flt/decimal_seq.rs
193ca485206899f913a3da75b6ac6484ee90b35c3a5d1c7059ae3d5c61110ad9 crate/dec2flt/decimal_seq.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f upstream/dec2flt/fpu.rs
16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f crate/dec2flt/fpu.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 upstream/dec2flt/lemire.rs
fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1 crate/dec2flt/lemire.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3 upstream/dec2flt/parse.rs
fb5f09bf0bc9742dae352ae0c3bf6706e8855ff22079765f6233fd16f975b669 crate/dec2flt/parse.rs
43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2 upstream/dec2flt/slow.rs
93ba8f521d4c3c73dfbcd4c76e0e1cf1fff7fa400cb4cd559218e249a7f62485 crate/dec2flt/slow.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb upstream/dec2flt/table.rs
6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb crate/dec2flt/table.rs
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
The standalone package adds four files having no supplied counterpart:
crate/Cargo.toml 2040ce5dc92c51b5245113f97682b692b876aa57708b5c7c483425ba152943c8
crate/lib.rs 1df2b8bcb2f52068d05a6343923716d0ef4475abdef34a0de3fe7cb8dc2ba95b
crate/num/mod.rs d9ac4f964d124bd4660914dc4c80bbb14f48d7851f9a8edc71a0931e9fce37b3
crate/num/imp/mod.rs df09b97393e97b23b0a558c2fcbbf4e75dd9d68338f1e83f168bab80a37a31f1
Thus fpu.rs, lemire.rs, and the complete 671-line table.rs, including their
algorithmic constants and tables, are byte-identical. The following sections
account for every other file and every changed hunk.
Namespace and error shell
-------------------------
crate/lib.rs:1-12 is a no_std crate root that re-exports core::f64 and
core::ops and introduces the same num module path expected by the supplied
slice. crate/num/imp/mod.rs:1-10 uses path attributes to place traits.rs and
dec2flt/mod.rs at core::num::imp-like module names. These declarations add no
wrapper call or computation. crate/num/mod.rs:1 re-exports
core::num::FpCategory. crate/num/mod.rs:3-26 defines a local private
FloatErrorKind and ParseFloatError shell so the standalone package can name
the parser's error type. The pursued GOALs observe only panic versus normal
return and, on normal return, the outer Result's Ok/Err discriminant; they do
not observe the private error kind or formatting. No identity is asserted
between this local shell and an unpinned core error payload.
crate/Cargo.toml:5-22 selects the package, empty default features, and
checked-overflow profiles. The configuration and fresh build are independently
reproduced in setup-reproduction.txt.
Visibility, derives, and bounds
-------------------------------
upstream/dec2flt/mod.rs:90 versus crate/dec2flt/mod.rs:90 changes only the
visibility of the existing BiasedFp import so a goal-facing caller can name the
same type. It changes neither layout nor execution.
upstream/dec2flt/common.rs:68 and decimal.rs:28 and decimal_seq.rs:17 include
Debug derives. The corresponding crate spans common.rs:48-51,
decimal.rs:28-31, and decimal_seq.rs:17-20 remove only Debug. Copy, Clone,
PartialEq, Eq, and Default used by computation remain where present, and no
accepted observation formats these records.
upstream/traits.rs:11-52 versus crate/traits.rs:11-64 removes formatting from
Int, removes a redundant Copy supertrait from CastInto, and instantiates Int
only for u64. Every call of CastInto is through Int, which still requires
Copy; all retained concrete values are primitive Copy values. The removed
u16/u32 instances are associated only with the disabled f16/f32 formats.
upstream/traits.rs:55-76 versus crate/traits.rs:67-80 removes Add, Debug,
PartialEq, PartialOrd, Default, and Clone from Float while retaining Copy, Mul,
Div, and Neg. A search of all retained generic bodies shows no call using a
removed operation. upstream/dec2flt/decimal.rs:56-89 versus
crate/dec2flt/decimal.rs:59-111 and upstream/dec2flt/mod.rs:209-256 versus
crate/dec2flt/mod.rs:352-520 add direct Div, Mul, and Neg bounds already implied
by Lemire -> Float, and replace operator notation with calls to those same
traits. Rust desugars the original /, *, and unary - to these trait calls, so
the operands, call order, result, and admitted f64 specialization are unchanged.
Exact constants, tables, and specialized decoding
-------------------------------------------------
The source formulae and decimal-literal table were evaluated directly by the
pinned rustc using the retained source
reference/model-evidence/adaptation-constants-probe.rs. The command was:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/adaptation-constants-probe.rs
B=.trellis/scratch/adaptation-constants-probe
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 "$P" -o "$B"
sha256sum "$P" "$B"
"$B"
The source hash was
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
and the resulting executable hash was
b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5.
Raw output was:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
upstream/traits.rs:134-137 computes LARGEST_POWER_OF_TEN through a Float
default, and upstream/traits.rs:175-193 gives the generic integer_decode and
the helper used by that constant. crate/traits.rs:146 makes the constant an
associated requirement; crate/traits.rs:309-359 supplies the retained f64
values and decoder after substituting BITS=64, SIG_BITS=52, EXP_BIAS=1023,
EXPONENT_MASK, MANTISSA_MASK, and the u64 operations. Each source expression
then becomes exactly the corresponding crate expression: sign is bits>>63,
exponent is (bits & mask)>>52 cast to i16, the subnormal mantissa is shifted
once, the normal mantissa receives 1<<52, and 1023+52 is subtracted. The
resulting tuple and every bit operation are unchanged. The probe output above
shows that the computed f64 LARGEST_POWER_OF_TEN is 308 and that the source
-f64::NAN word is fff8000000000000, exactly crate/traits.rs:315-327; the
independent binary64-boundary.txt record fixes the masks and primitive bit
semantics used by the decoder.
upstream/dec2flt/mod.rs:118-129 gives the two Lemire default formulae.
crate/dec2flt/mod.rs:115-128 makes them associated requirements, and the
retained f64 instance at crate/dec2flt/mod.rs:217-220 supplies 22 and 37, the
integer results of the two source formulae for 53 significand bits.
upstream/dec2flt/mod.rs:176-181 indexes a 32-entry f64 table with exponent&31.
crate/dec2flt/mod.rs:222-251 performs the same masked selection using from_bits:
cases 0 through 22 are the exact pinned binary64 words printed above for 1e0 through 1e22 and
all other cases return positive zero, as did entries 23 through 31. The full
word list and the pinned float semantics are recorded in binary64-boundary.txt.
The analogous f16/f32 replacements at crate/dec2flt/mod.rs:145-215 and
crate/traits.rs:187-307 lie under cfg(any()) and cannot enter this build.
Whole-function from_u64 opacity
-------------------------------
upstream/dec2flt/mod.rs:184-188 and crate/dec2flt/mod.rs:263-266 have the same
f64 body: the same enabled debug_assert that v <= 1<<53, followed by the same
primitive `v as f64` cast. The sole semantic-boundary annotation is
#[charon::opaque] at crate line 262, syntactically attached to the function
item. It therefore hides the entire from_u64 body from translation: neither
the debug assertion nor the cast is transparent in the extraction. The
callers, their guards, and the surrounding native-path computation remain
transparent. The fresh external inventory contains the whole method as the
single external F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64. Its
separately reviewed ModelF64FromU64 binding supplies exactly successful integer
conversion for v <= 2^53 and assertion failure otherwise.
Digit scans, slice patterns, and helper extraction
-------------------------------------------------
upstream/dec2flt/common.rs:14-53 supplies ByteSlice::parse_digits: repeatedly
split_first, wrapping-subtract ASCII zero, invoke the closure exactly when the
result is below 10, consume that byte, and stop at the first other byte.
crate/dec2flt/common.rs:11-36 removes only this method. Its complete set of
uses is replaced as follows.
* upstream/dec2flt/parse.rs:31-48 versus crate/dec2flt/parse.rs:31-58 keeps the
eight-byte loop, wrapping multiply/add, and then performs the same digit test,
accumulator update, and one-byte progress with an index. The local rename
num to chunk is lexical only.
** upstream/dec2flt/parse.rs:73-102 versus crate/dec2flt/parse.rs:121-158
expands the same optional sign and first-digit test, pre-update 2^59
accumulator cutoff, exact first-nondigit suffix and final sign. Each update
stays at most 10*2^59-1 below I64 maximum; the cutoff does not stop scanning.
* upstream/dec2flt/decimal_seq.rs:224-304 versus
crate/dec2flt/decimal_seq.rs:269-373 preserves the repaired upstream
final_decimal_point body and calls the same parse_scientific with normal
Option None defaulting to zero. It extracts parse_digits_into_seq and
count_trailing_zeros, not an obsolete separate decimal exponent fold.
The digit helper preserves digit tests, forward order, try_add_digit and
logical count increments. The reverse helper visits the same consumed
bytes in reverse order, counts zeros, ignores dots and stops at a nonzero
nondot byte.
In all these replacements, indexing occurs only under count<len or !is_empty,
so it has the same bounds as split_first. Slicing advances by exactly the same
one or eight bytes. No wrapping operation is replaced by checked arithmetic,
and no checked source operation is replaced by wrapping arithmetic.
upstream/dec2flt/parse.rs:155-181 versus crate/dec2flt/parse.rs:82-119 and
212-226 moves two loops into adjust_many_digit_count and parse_many_digits.
The prefix helper visits the same start bytes in the same order, performs the
same saturating_sub and checked isize subtraction, and stops on the same byte.
The retry helper makes the same first 19-digit call, tests the same threshold,
makes the same one-byte rebase and second call in the alternate branch,
computes the same offset with the same sign, casts it to i64, and performs the
same checked addition of exp_number last. Thus any large-input panic is
preserved rather than excluded.
upstream/dec2flt/decimal_seq.rs:239-304 versus
crate/dec2flt/decimal_seq.rs:288-373 preserves the logical significant count
before trimming/capping and the full fractional count from the saved slice
after the point, before zero skipping. Counts n,f are bounded by the original
source-valid length M; their I64 casts and difference are exact. The final
I64 saturating addition, ordered clamp to +/-2047 and safe I32 narrowing
are the source operations, not adaptations of a desired rounding theorem.
Final clipping absorbs prior I64 saturation, not independent clipping of n,f,e.
Zero-count point finalization happens after the optional exponent call;
normal None defaults to exponent zero, while failure/divergence propagate.
Digit storage, trimming, truncation and fill retain the source transitions.
Delayed returns
---------------
upstream/dec2flt/decimal_seq.rs:173-198 versus
crate/dec2flt/decimal_seq.rs:176-203 replaces one return inside right_shift's
loop by all_zero=true, exits because !all_zero is the loop guard, and returns
immediately afterward. No decimal_point, digit, index, or arithmetic update
occurs between the original and delayed return.
upstream/dec2flt/slow.rs:46-76 versus crate/dec2flt/slow.rs:46-94 replaces two
nested-loop returns by loop_result. In the zero branch it records fp_zero,
skips the source-skipped exp2 addition, exits through is_none(), and returns.
In the infinity branch it records fp_inf, skips the source-skipped exp2
subtraction, exits, and returns. On all other iterations it performs the same
shift, checked state changes, and exponent update. Lines 95-126 after these
returns are otherwise the source lines 77-110 unchanged.
Dispatcher trace and public projection
--------------------------------------
upstream/dec2flt/mod.rs:209-256 is the whole original dispatcher.
crate/dec2flt/mod.rs:285-349 declares trace data only, lines 352-505 execute the
instrumented dispatcher, and lines 507-520 define public dec2flt as its first
projection. Comparing the bodies gives the following branch-by-branch
correspondence.
* Both call as_bytes, inspect the first byte, reject empty input before a helper,
remove at most one sign, and reject a sign-only body. The trace stores the
already obtained body and Boolean sign.
* Both call parse_number first on that exact body. Only None calls
parse_inf_nan on the same body and sign. Its Some is returned directly and
its None returns invalid. The trace stores those existing Option values.
* Both overwrite only Decimal.negative, test the same compile-time
!optimize_for_size condition, call try_fast_path once, and return its Some
directly. The trace stores the copied Decimal and Option; Decimal is Copy.
* Both call compute_float first with num.exponent and num.mantissa. The crate's
second_compute_guard is exactly the first two conjuncts of the source
short-circuit. Therefore the checked mantissa+1 and second compute_float call
occur under precisely the source guard, in the same order. The same pair
comparison either retains fp or changes only p_biased to -1.
* Both test the post-comparison p_biased<0 once, call parse_long_mantissa on the
unchanged body exactly when true, and otherwise retain the same pair. The
trace records both guard and result without another helper call.
* The extra assembled_word expression is the same cast, shift, and OR performed
by biased_fp_to_float at upstream lines 202-206 and crate lines 278-282; these
integer operations neither panic nor mutate fp. Both then call assembly once
on the selected pair and apply unary negation exactly when num.negative.
Public dec2flt returns the identical Result first component.
Consequently the trace does not infer uncomputed data: it records the exact
variant; sign-stripped body and sign; numeric/special Options; fast-path input
and result; first and conditional second integer operands and results;
comparison, forced-deferral and post-comparison pair; slow guard and result;
selected pair; assembled word; pre-sign assembly word; sign-application fact;
and final word. Special and native direct returns create no selected pair.
All source call order, guards, checked arithmetic, mutable-state transitions,
panic points, and returned Result/F64 observations remain in place.
F64-only restriction
--------------------
crate/traits.rs:187-307 and crate/dec2flt/mod.rs:140-215 add cfg(any()) to the
f16/f32 Float, FloatExt, and Lemire implementations. crate/traits.rs:59-64
retains only u64 Int. The retained f64 implementations are
crate/traits.rs:309-360 and crate/dec2flt/mod.rs:217-264. Every goal-facing
function remains generic in the source and extraction, but each pursued source
subject specializes it to f64, whose associated integer is u64. There is no
dynamic format dispatch, so removing other impl blocks cannot change an f64
call, its native decision, checks, result word, NaN classification, fields, or
trace. The fresh boundary inventory in setup-reproduction.txt confirms that
no removed-format external remains.
Conclusion
----------
The inventory is exhaustive: three supplied files are identical, seven have
all hunks classified above, and the four added files are the package shell.
For the configured f64 specialization, the adapted crate has the same input
domains, branch order, guards, checked/wrapping distinction, state transitions,
panic versus normal behavior, and public/helper observations as the supplied
source. The only new observations are the trace fields, each copied from an
existing value or computed by the same pure assembly expression. This
conclusion is independent of whether any parser-correctness GOAL is true.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This is a fresh reproduction in the task's private checkout, not a replacement
for the historical build above, a publication receipt, or preservation approval.
The retained adaptation-constants-probe.rs was restored byte-exactly from:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence/adaptation-constants-probe.rs
Both predecessor and restored source have SHA-256:
b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations, with all
variables expanded to the absolute paths shown. The invocations were issued
from ROOT; execution cwd was ROOT/.trellis/scratch. Each execution used a
600-second timeout and retained its complete argv, environment, stdout, stderr
and exit status in an execution.json below W.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/adaptation-constants-probe.rs"
B="$W/adaptation-constants-probe"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
This is the recorded constants flag set: edition 2024, explicit x86_64 target,
opt-level=0, no feature cfg, and no explicit overflow/debug/debuginfo override.
The standalone probe uses the pinned std/core, not a Cargo profile or a new
parser implementation. Default target cfg reports debug_assertions and
overflow_checks. The wrapper pins RUSTC and RUSTDOC to this toolchain and
RUSTUP_TOOLCHAIN to nightly-2026-06-01-x86_64-unknown-linux-gnu, and creates
per-execution CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under W. The manifest's
LD_LIBRARY_PATH is the same toolchain's lib directory. The manifest is
byte-unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Execution records (relative to W):
exec-1791599082688918194/execution.json compile: exit_code=0, timeout=false
exec-1791599096798355499/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were both empty; run stderr was empty. Raw compiler
version stdout was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Current compiler and library identities
---------------------------------------
Let T be /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". The identity commands were
sha256sum on these exact files (the path abbreviations expand under T or S):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b T/bin/rustc
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
84540a6a59e347c63caabe12cf895ba1239c76a50682471567007138fac1c618 S/num/f64.rs
Current core num/f64.rs:374,412 supplies respectively:
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
pub const MANTISSA_DIGITS: u32 = 53;
Raw run stdout
---------------
The complete raw stdout in W/exec-1791599096798355499/stdout is:
largest_power_of_ten=308
max_exponent_fast_path=22
max_exponent_disguised=37
neg_nan=fff8000000000000
pow10_0=3ff0000000000000
pow10_1=4024000000000000
pow10_2=4059000000000000
pow10_3=408f400000000000
pow10_4=40c3880000000000
pow10_5=40f86a0000000000
pow10_6=412e848000000000
pow10_7=416312d000000000
pow10_8=4197d78400000000
pow10_9=41cdcd6500000000
pow10_10=4202a05f20000000
pow10_11=42374876e8000000
pow10_12=426d1a94a2000000
pow10_13=42a2309ce5400000
pow10_14=42d6bcc41e900000
pow10_15=430c6bf526340000
pow10_16=4341c37937e08000
pow10_17=4376345785d8a000
pow10_18=43abc16d674ec800
pow10_19=43e158e460913d00
pow10_20=4415af1d78b58c40
pow10_21=444b1ae4d6e2ef50
pow10_22=4480f0cf064dd592
sha256sum on B and that stdout gave:
482491502f2589cf12925f50a3fc7eb46e7d7910e46c651b8d373591246f1962 CURRENT executable B
9c89cd66b9531fe4b1ba80035d50940f2844d8c15ca6a2dcdaadb644971bb824 CURRENT raw stdout
The current stdout reproduces every historical value. This current executable
is NOT the historical b02d2f6deb675f17d0dbdc22e57a67d7692689f7a2b0d7b125556c35c4b8a4a5
build and is also distinct from request 270's diagnostic executable
13281453971470a3ca67e9eba0bed2963acf7a0e771bad7a62967b1a07eab961.
Neither older identity is replaced by the new one.
Comparison with CURRENT source
------------------------------
sha256sum and direct reads of the four current source files gave:
66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e upstream/traits.rs
7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a upstream/dec2flt/mod.rs
41724d52fd1408515cc8d0996b3817cf2fdc95ef8bc7ba4431f4116bb816bc66 crate/traits.rs
6ce998fb79493021a6b7af183ba03934fa699ddb6f9c2bfafcea17d26e5c608a crate/dec2flt/mod.rs
The read commands were sed -n '130,140p' upstream/traits.rs,
sed -n '175,195p' upstream/traits.rs, sed -n '110,132p' upstream/dec2flt/mod.rs,
sed -n '175,189p' upstream/dec2flt/mod.rs, sed -n '309,359p' crate/traits.rs,
and sed -n '217,251p' crate/dec2flt/mod.rs, all from ROOT.
At upstream/traits.rs:134-137,175-193, the f64 default substitutes EXP_BIAS=1023
and computes trunc(1024/LOG2_10)=308; its intermediate i64 value also fits i32.
The existing decoder comparison above still applies field by field after
substitution of BITS=64, SIG_BITS=52 and the masks. At upstream/dec2flt/mod.rs:
118-129 the source computes trunc(53/(LOG2_10-1))=22 and
22+trunc(53/LOG2_10)=37. These are exactly the probe expressions and the
associated constants in crate/traits.rs:327 and crate/dec2flt/mod.rs:219-220.
The source negative NAN word matches crate/traits.rs:317 exactly.
For upstream/dec2flt/mod.rs:175-181 and crate/dec2flt/mod.rs:222-251, every
masked-index table word was compared, not just a selected fast-path index.
Indices 0 through 22 agree with each of the 23 separate pow10 lines above,
in order, in both the original decimal-literal array and the adapted from_bits
match. The remaining complete list is:
index 23: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 24: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 25: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 26: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 27: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 28: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 29: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 30: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
index 31: upstream 0. -> 0000000000000000; crate wildcard -> 0000000000000000
Both bodies use exponent & 31, so this covers every possible usize argument
by the identical finite selection rule. The restored probe establishes only
these fixed constant computations and nonzero literal words; the zero cases
and masking come from the current source inspection. It is not an allocation
experiment, a GOAL proof, or a certification of the full adaptation claim.
All Tablet files, source/extraction/provenance files, model-support bindings,
original GOAL meanings and existing configuration delta are unchanged.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Upstream → extraction-crate adaptation diff
--- upstream/traits.rs
+++ crate/traits.rs
@@ -8,19 +8,26 @@
)]
use crate::num::FpCategory;
-use crate::{f64, fmt, ops};
+use crate::{f64, ops};
/// Lossy `as` casting between two types.
-pub trait CastInto<T: Copy>: Copy {
+// All uses are through `Int`, which independently requires `Self: Copy`, and
+// every implementation here is a primitive Copy type. Removing that redundant
+// supertrait changes no call or value but prevents Aeneas from emitting two
+// identically named `Copy` fields for `Self` and `T` in the Lean structure.
+pub trait CastInto<T: Copy> {
fn cast(self) -> T;
}
/// Collection of traits that allow us to be generic over integer size.
+// The scoped observations contain no formatting behavior. Removing the
+// `Debug` supertrait changes neither the concrete primitive integer instances
+// nor any operation used by the algorithms, so it preserves the f64
+// specialization and every inventoried observation independently of GOAL truth.
pub trait Int:
Sized
+ Clone
+ Copy
- + fmt::Debug
+ ops::Shr<u32, Output = Self>
+ ops::Shl<u32, Output = Self>
+ ops::BitAnd<Output = Self>
@@ -49,21 +56,26 @@
}
}
-int!(u16, u32, u64);
+// Only `u64` is the associated integer of the retained `f64` specialization.
+// The removed `u16`/`u32` instances served only the excluded `f16`/`f32`
+// implementations, so their removal changes no f64 public, helper, or trace
+// body, native decision, checked arithmetic, debug assertion, return value, or
+// scoped observation.
+int!(u64);
/// A helper trait to avoid duplicating basically all the conversion code for IEEE floats.
#[doc(hidden)]
+// Formatting is outside every scoped public and trace observation. `Add`,
+// equality, ordering, default construction, and cloning are also unused by all
+// retained generic bodies; only `Copy`, `Mul`, `Div`, and `Neg` are required.
+// Removing those unused requirements admits the same f64 implementation and
+// changes no f64 body, native decision, checked arithmetic, debug assertion,
+// return value, or trace observation, independently of any GOAL's truth.
pub trait Float:
Sized
+ ops::Div<Output = Self>
+ ops::Neg<Output = Self>
+ ops::Mul<Output = Self>
- + ops::Add<Output = Self>
- + fmt::Debug
- + PartialEq
- + PartialOrd
- + Default
- + Clone
+ Copy
{
/// The unsigned integer with the same size as the float
@@ -131,10 +143,7 @@
///
/// This is the max exponent in binary converted to the max exponent in decimal. Allows fast
/// pathing anything larger than `10^LARGEST_POWER_OF_TEN`, which will round to infinity.
- const LARGEST_POWER_OF_TEN: i32 = {
- let largest_pow2 = Self::EXP_BIAS + 1;
- pow2_to_pow10(largest_pow2 as i64) as i32
- };
+ const LARGEST_POWER_OF_TEN: i32;
/// Smallest decimal exponent for a non-zero value. This allows for fast pathing anything
/// smaller than `10^SMALLEST_POWER_OF_TEN`, which will round to zero.
@@ -172,35 +181,24 @@
/// with the explicit bit set but otherwise unshifted
///
/// `s` is only ever +/-1.
- fn integer_decode(self) -> (u64, i16, i8) {
- let bits = self.to_bits();
- let sign: i8 = if bits >> (Self::BITS - 1) == Self::Int::ZERO { 1 } else { -1 };
- let mut exponent: i16 = ((bits & Self::EXP_MASK) >> Self::SIG_BITS).cast();
- let mantissa = if exponent == 0 {
- (bits & Self::SIG_MASK) << 1
- } else {
- (bits & Self::SIG_MASK) | (Self::Int::ONE << Self::SIG_BITS)
- };
- // Exponent bias + mantissa shift
- exponent -= (Self::EXP_BIAS + Self::SIG_BITS) as i16;
- (mantissa.into(), exponent, sign)
- }
-}
-
-/// Solve for `b` in `10^b = 2^a`
-const fn pow2_to_pow10(a: i64) -> i64 {
- let res = (a as f64) / f64::consts::LOG2_10;
- res as i64
+ fn integer_decode(self) -> (u64, i16, i8);
}
#[cfg(target_has_reliable_f16)]
+// The f16 implementation is outside the exclusively f64 scope. Disabling it
+// leaves every retained f64 public/helper/trace body and all of its decisions,
+// checked operations, assertions, return values, and observations unchanged.
+#[cfg(any())]
impl Float for f16 {
type Int = u16;
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
- const NEG_NAN: Self = -Self::NAN;
+ // `from_bits` produces exactly the bit pattern obtained by negating the
+ // upstream canonical NaN. This avoids Aeneas's unsupported float unop
+ // while preserving the constant, including its sign and payload bits.
+ const NEG_NAN: Self = f16::from_bits(0xFE00);
const BITS: u32 = 16;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
@@ -209,6 +207,8 @@
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -22;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 5;
+ // Exact value of trunc(16 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 4;
const SMALLEST_POWER_OF_TEN: i32 = -27;
fn to_bits(self) -> Self::Int {
@@ -221,20 +221,44 @@
}
#[cfg(target_has_reliable_f16)]
+// `FloatExt for f16` is used only by the excluded f16 specialization; it is
+// irrelevant to all retained f64 computation and observations listed above.
+#[cfg(any())]
impl FloatExt for f16 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
Self::from_bits((v & 0xFFFF) as u16)
}
-}
-
+
+ // Specializing the upstream default removes only unsupported associated-
+ // integer operator resolution; these are the same bit operations with
+ // `Self::Int = u16` and the same exponent-bias subtraction.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 15 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 10) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u16 << 10)
+ };
+ exponent -= 15 + 10;
+ (mantissa as u64, exponent, sign)
+ }
+}
+
+// The f32 implementation is outside the exclusively f64 scope. Disabling it
+// does not alter any retained f64 computation, assertion, result, or trace.
+#[cfg(any())]
impl Float for f32 {
type Int = u32;
const INFINITY: Self = f32::INFINITY;
const NEG_INFINITY: Self = f32::NEG_INFINITY;
const NAN: Self = f32::NAN;
- const NEG_NAN: Self = -f32::NAN;
+ // Bit-identical to the upstream `-f32::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f32::from_bits(0xFFC0_0000);
const BITS: u32 = 32;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
@@ -243,6 +267,8 @@
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -17;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 10;
+ // Exact value of trunc(128 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 38;
const SMALLEST_POWER_OF_TEN: i32 = -65;
fn to_bits(self) -> Self::Int {
@@ -254,11 +280,30 @@
}
}
+// `FloatExt for f32` likewise has no use in any retained f64 body or scoped
+// observation and is disabled without changing f64 execution.
+#[cfg(any())]
impl FloatExt for f32 {
#[inline]
fn from_u64_bits(v: u64) -> Self {
f32::from_bits((v & 0xFFFFFFFF) as u32)
}
+
+ // This is the upstream default after substituting `Self::Int = u32`;
+ // concreteness is needed only because Charon cannot resolve the generic
+ // associated-integer shifts and bit operators for Aeneas.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 31 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 23) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u32 << 23)
+ };
+ exponent -= 127 + 23;
+ (mantissa as u64, exponent, sign)
+ }
}
impl Float for f64 {
@@ -267,7 +312,9 @@
const INFINITY: Self = Self::INFINITY;
const NEG_INFINITY: Self = Self::NEG_INFINITY;
const NAN: Self = Self::NAN;
- const NEG_NAN: Self = -Self::NAN;
+ // Bit-identical to the upstream `-f64::NAN`, without the unsupported
+ // compile-time float negation.
+ const NEG_NAN: Self = f64::from_bits(0xFFF8_0000_0000_0000);
const BITS: u32 = 64;
const SIG_TOTAL_BITS: u32 = Self::MANTISSA_DIGITS;
@@ -276,6 +323,8 @@
const MIN_EXPONENT_ROUND_TO_EVEN: i32 = -4;
const MAX_EXPONENT_ROUND_TO_EVEN: i32 = 23;
+ // Exact value of trunc(1024 / log2(10)) from the upstream default.
+ const LARGEST_POWER_OF_TEN: i32 = 308;
const SMALLEST_POWER_OF_TEN: i32 = -342;
fn to_bits(self) -> Self::Int {
@@ -292,4 +341,20 @@
fn from_u64_bits(v: u64) -> Self {
f64::from_bits(v)
}
-}
+
+ // This is the upstream default after substituting `Self::Int = u64`;
+ // it preserves every decoded field while avoiding unsupported generic
+ // associated-integer operator resolution.
+ fn integer_decode(self) -> (u64, i16, i8) {
+ let bits = self.to_bits();
+ let sign = if bits >> 63 == 0 { 1 } else { -1 };
+ let mut exponent = ((bits & Self::EXPONENT_MASK) >> 52) as i16;
+ let mantissa = if exponent == 0 {
+ (bits & Self::MANTISSA_MASK) << 1
+ } else {
+ (bits & Self::MANTISSA_MASK) | (1_u64 << 52)
+ };
+ exponent -= 1023 + 52;
+ (mantissa, exponent, sign)
+ }
+}
Record details
| Kind | source adaptation site (file-level diff) |
|---|
Captured evidence identities
[
{
"path": "extraction-evidence/COMMAND.json",
"sha256": "ee492ee6e7be6389e4fe2c1cdd705a03e186c3466229f012bcaa72fe1d44c443",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/DETERMINISM.json",
"sha256": "38c9b4157d80073a4f2602f64870c2092981d98b1b0f70c541dc21396fb2f465",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/RESULT.json",
"sha256": "2105f8fffaecedede0579d7e4e3db8379b02bb961096381556973ce9c76a386d",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDERR.bin",
"sha256": "b63a4608f41112cc9ec1ce9ee9d2446397d5d73a279414719d383322a42e2ea1",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "extraction-evidence/STDOUT.bin",
"sha256": "35e34a7267eb3802f3c4ddf7c48b2eafd929d6bbeb22980658fff8be3fcb93d5",
"cited_by": [
"shared mechanical extraction record"
]
},
{
"path": "reference/model-evidence/adaptation-constants-probe.rs",
"sha256": "b5a4a2cba0c08053cb9a816adb1ba5dbd160bf3928bdf5ccf56b7ae83aaa2aa5",
"cited_by": [
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-boundary.txt",
"sha256": "749a255e60aa8e6f5d16c0b55665e2fb1bb15d53559171cf87711068f232372e",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/binary64-probe.rs",
"sha256": "68e70be70faa44c2781990457f09ef5fc7815e120fda0a468eaa85f9b634ad7e",
"cited_by": [
"reference/model-evidence/binary64-boundary.txt"
]
},
{
"path": "reference/model-evidence/goal-vocabulary.txt",
"sha256": "8882e0815b961e8e3de64c531937920b64e4776db4bd4a2eaf2d5bea0c581a4c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/setup-reproduction.txt",
"sha256": "6f48b7c679dd33dafc9fcb8ea437017cc6f172e475a51c48f66c0c28d1d43435",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.diff",
"sha256": "1c0081e1e32d015be3c7e54e12e897c27d3588ad105e6f614782450f383590e6",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex",
"reference/model-evidence/source-adaptation-delta.txt"
]
},
{
"path": "reference/model-evidence/source-adaptation-delta.txt",
"sha256": "bb00c54d58d43c30874b5ef7cbebc735bf3371cf9933f725827f5a9031279be4",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"shared extraction boundary: Tablet/Preamble.tex"
]
}
]Platform and environment premises (1)
Dec2Flt.P340_T1_selected_target_numBits
Definition
x86_64-unknown-linux-gnu extraction environment, the platform
parameter used by the installed Aeneas model satisfies
\mathtt{System.Platform.numBits}=64.Preservation argument
Claim
Usize and
Isize therefore represent, respectively, the unsigned and signed
64-bit Rust pointer-sized integers. Every configured source-valid byte
slice's contents and length remain representable, and Rust strings retain
their separate UTF-8 requirement. No source domain, A/B bound, source
operation, extracted declaration, or GOAL proposition is changed. The
binding is independent of whether a GOAL is proved or disproved.Proof
effective_tools,
resource_environment, and accepted setup audit select the pinned
nightly-2026-06-01 compiler and the x86_64 environment. The current
SETUP.md, under ``Package and extraction,'' explains that the
compiler host is the extraction target: extraction.json has empty
Cargo, Charon, and Aeneas argument lists, with no target override.
crate/rust-toolchain.toml records that channel and
x86_64-unknown-linux-gnu. The manifest also identifies the
installed Lean executable and the Aeneas library path. The current file
identities, exact record locators, and relevant excerpts are retained in the
``CURRENT selected-target width binding'' appendix of
reference/model-evidence/source-valid-byte-slice.txt.
This argument uses the current accepted environment, not a predecessor's
assumption or approval.usize
and isize have the platform pointer width; isize has signed
two's-complement interpretation. The pinned core documentation and Rust
Reference locators are in
reference/model-evidence/source-valid-byte-slice.txt.
Fresh managed invocations of the pinned compiler report host
x86_64-unknown-linux-gnu; both its default --print cfg
and explicit-target invocation report target_pointer_width="64".
Their complete raw outputs agree. The unchanged retained probe, freshly
compiled for that target with overflow checks and debug assertions enabled,
reports usize_bits=64,
isize_max=9223372036854775807, and u8_size=1; its raw
output agrees byte-for-byte with the retained output. These probes
corroborate the selected compiler environment; they neither sample parser
correctness nor establish a universal claim by testing.Scalar/Core.lean defines
UScalarTy.numBits .Usize and
IScalarTy.numBits .Isize to be exactly
System.Platform.numBits. It defines the carriers as bitvectors of
these widths, their observations as toNat and toInt, and
Usize and Isize as the corresponding scalar kinds. Thus
this primitive, rather than an independently authored parser predicate, is
the missing width parameter. Lean's installed Init/Prelude.lean
describes getNumBits as the current platform's word size, deliberately
opaque to kernel reduction, and defines numBits as its value.
Its type guarantees only the disjunction 32 or 64; the displayed default
inhabitant is not a proof of the selected equality. The manifest-selected
Lean executable is independently identified as ELF64 x86-64, consistent with
the selected Rust target. The exact installed sources, hashes, and executable
identity are in
reference/model-evidence/source-valid-byte-slice.txt.
Consequently binding this platform parameter to the already-selected
pointer width 64 is a source-environment correspondence premise, not a new
Rust language claim that every target has width 64 and not a kernel proof
obtained by native evaluation.usize/isize. Fixed-width scalar kinds have
literal widths in the same definitions, so none is changed by this binding.
The installed casts continue to truncate or extend bitvectors, and the
installed checked constructors continue to return integer-overflow failure
outside their scalar bounds. No cast is replaced by a rejecting operation
and no failure branch is removed. The appendix in
reference/model-evidence/source-valid-byte-slice.txt retains
these definitions as well as the source and pinned extraction of
ByteSlice.offset_from. For example, two source-valid byte-slice
lengths are in [0,2^{63}-1]; their unsigned-to-signed 64-bit casts preserve
the lengths, and their difference lies in
[-(2^{63}-1),2^{63}-1], within the signed range. This explains the
relevant source/model width agreement; it assumes no scan invariant or
parser return property.Slice is a list with length at most Usize.max, now
2^{64}-1. For any represented source-valid contents, the same list of
bytes supplies a model slice because
2^{63}-1\leq 2^{64}-1; its length and every element are unchanged.
Conversely the source-validity predicate still excludes lengths above
2^{63}-1 even though the model carrier permits them. This is coverage of
the abstract contents of valid references, not an assertion that every
such size can be physically allocated. Substrings and sign-stripped bodies
retain the same length bound; UTF-8 is neither added to arbitrary helper
byte slices nor removed from strings.Requirement: assembly correspondence
Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
Requirement: native correct or defer
Requirement: number helper acceptance
Requirement: number helper accumulated value
Requirement: number helper record bounds
Requirement: number helper rejection
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64Why this model is faithful
Evidence and probes
These programs and outputs were produced during modeling to examine specific behavior and support the modeling arguments.
reference/model-evidence/source-valid-byte-slice-probe.out
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
reference/model-evidence/source-valid-byte-slice-probe.rs
fn main() {
println!("arch={}", std::env::consts::ARCH);
println!("usize_bits={}", usize::BITS);
println!("isize_max={}", isize::MAX);
println!("u8_size={}", std::mem::size_of::<u8>());
}
reference/model-evidence/source-valid-byte-slice.txt
Source-valid byte-slice and string domain evidence
==================================================
Scope and pinned identities
---------------------------
All commands below were run from the repository root. The configured compiler
is:
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
Its SHA-256 is:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b
The exact identity commands were:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
sha256sum "$R"
"$R" --version --verbose
"$R" --target x86_64-unknown-linux-gnu --print cfg | LC_ALL=C sort | \
rg 'target_(arch|pointer_width)'
Their relevant raw output was:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
target_arch="x86_64"
target_pointer_width="64"
Retained configured-target probe
--------------------------------
The retained probe source is
reference/model-evidence/source-valid-byte-slice-probe.rs. It was compiled
for the configured target and executed with this exact command, which depends
only on the retained source and the pinned compiler:
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
P=reference/model-evidence/source-valid-byte-slice-probe.rs
B=/tmp/dec2flt-source-valid-byte-slice-probe
O=reference/model-evidence/source-valid-byte-slice-probe.out
"$R" --edition 2024 --target x86_64-unknown-linux-gnu -C opt-level=0 \
-C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
sha256sum "$R" "$P" "$B"
"$B" > "$O"
sha256sum "$O"
cat "$O"
The actual hashes were:
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd reference/model-evidence/source-valid-byte-slice-probe.rs
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 /tmp/dec2flt-source-valid-byte-slice-probe
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 reference/model-evidence/source-valid-byte-slice-probe.out
The retained raw output file contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Pinned core-library source
--------------------------
Let:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
The exact commands used to identify and inspect the relevant core sources were:
sha256sum "$S/slice/mod.rs" "$S/num/int_macros.rs" "$S/str/mod.rs"
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
The file identities are:
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 core/src/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 core/src/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 core/src/str/mod.rs
The relevant exact excerpt of slice/mod.rs, line 801, is:
// - The size of the slice is never larger than `isize::MAX` bytes, as
The relevant exact declaration in num/int_macros.rs, line 47, is:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
The relevant exact excerpts of str/mod.rs are its same-layout byte-slice
conversion at lines 498-500:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
and its UTF-8 invariant at lines 507-510:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
Conclusion
----------
The configured target has 64-bit usize/isize and one-byte u8 elements.
The pinned signed-MAX definition therefore gives
isize::MAX = 2^63 - 1 = 9223372036854775807, and the pinned slice rule bounds a
slice by that many bytes. For &[u8], this is exactly an element-count bound;
the rule adds no UTF-8 condition or other restriction on the byte contents.
The pinned str source exposes the identical-layout &[u8] bytes and separately
requires them to be valid UTF-8. Consequently the exact configured domains
are arbitrary &[u8] bytes of length at most isize::MAX, and Rust str bytes of
length at most isize::MAX that are valid UTF-8. No smaller convenience bound
is introduced.
CURRENT reproduction: request 272, managed task 12, 2026-10-10 UTC
================================================================
This append-only record identifies a fresh managed reproduction, not canonical
publication or preservation approval. The retained probe source and output
were restored byte-exactly from the read-only predecessor's directory:
/home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0002/dec2flt-r0002/reference/model-evidence
The hashes of both predecessor and restored artifacts are:
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd source-valid-byte-slice-probe.rs
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 source-valid-byte-slice-probe.out
Managed commands and settings
-----------------------------
The following shell notation gives the exact managed invocations with the
absolute variables expanded. They were issued from ROOT and executed with
cwd ROOT/.trellis/scratch. Logs/build storage were confined to W. No compiler
command bypassed the supplied managed wrapper.
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/12/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-12-evidence"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
O="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.out"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --edition 2024 --target x86_64-unknown-linux-gnu \
-C opt-level=0 -C debuginfo=0 -C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$B"
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --version --verbose
python3 "$ROOT/.trellis/scripts/pv_modeling.py" exec "$ROOT" \
--cwd "$ROOT/.trellis/scratch" --output "$W" --timeout 600 \
--command "$R" --target x86_64-unknown-linux-gnu --print cfg
The complete domain-probe flag set reproduces the historical edition, target,
opt-level, debuginfo, overflow/debug checks and crate name. It sets no feature
cfg and uses the pinned std/core directly, with no Cargo profile. The wrapper
pins RUSTC/RUSTDOC to this toolchain, RUSTUP_TOOLCHAIN to
nightly-2026-06-01-x86_64-unknown-linux-gnu, and per-execution CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR under W. The manifest's LD_LIBRARY_PATH is
/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib.
modeling-input/manifest.json is unchanged, SHA-256:
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32
Records (relative to W), with complete argv, environment and raw streams:
exec-1791599091559654118/execution.json compile: exit_code=0, timeout=false
exec-1791599101697515551/execution.json run: exit_code=0, timeout=false
exec-1791599121355087776/execution.json version: exit_code=0, timeout=false
exec-1791599126547341832/execution.json target cfg: exit_code=0, timeout=false
Compile stdout and stderr were empty; run, version and cfg stderr were empty.
Raw version stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete raw default target cfg stdout:
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete raw probe stdout and identities
----------------------------------------
W/exec-1791599101697515551/stdout contains exactly:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
The commands sha256sum "$R" "$P" "$B" "$O" and sha256sum on the fresh
stdout gave (paths abbreviated by the variables above):
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 CURRENT executable B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 restored O
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 CURRENT raw stdout
cmp "$O" "$W/exec-1791599101697515551/stdout" exited 0 with empty stdout.
Thus fresh stdout is byte-exactly the restored historical output; this does
not overwrite either the historical output or its provenance.
CURRENT pinned core-source argument for the whole domain
--------------------------------------------------------
Let T=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu
and S="$T/lib/rustlib/src/rust/library/core/src". sha256sum on the following
exact paths gave:
ac95ece05f436bbdc71cc1e8dcf0e99db24ea1c08b17cbfbc111e0631148e8d9 T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-58aeee91aeb71c13.rlib
6a40f794a28cdd69182753e14782bd46f65cb446210fe8b0c251b6efdc5d4ffd T/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ebc3593764c44f83.rlib
354992a6a3d69a0185eef9044a07ea5180e767bdb467aef55e69ee3d44317840 S/slice/mod.rs
3896304e7cb14628e293134ac41fd18be2b5369bedc02d1c6a7408bd8c755a31 S/num/int_macros.rs
284b4c147b5d0497ce9146f6b96e564f196aed10411a62cdccf5fc5243d40f78 S/str/mod.rs
0914968067f7e2bc798680c1edd72bcb032a9fd44ebb2b6fbc082a3a2b16941f S/slice/raw.rs
The first three source identities match the historical record above. Exact
current inspection commands were:
sed -n '798,808p' "$S/slice/mod.rs"
sed -n '43,51p' "$S/num/int_macros.rs"
sed -n '495,510p' "$S/str/mod.rs"
sed -n '12,34p' "$S/slice/raw.rs"
slice/mod.rs:801-807 retains its size assumption and its qualification:
// - The size of the slice is never larger than `isize::MAX` bytes, as
// noted here:
// - https://github.com/rust-lang/unsafe-code-guidelines/issues/102#issuecomment-473340447
// - https://doc.rust-lang.org/reference/behavior-considered-undefined.html
// - https://doc.rust-lang.org/core/slice/fn.from_raw_parts.html#safety
// (This doesn't seem normative yet, but the very same assumption is
// made in many places, including the Index implementation of slices.)
The additional pinned primary safety text in slice/raw.rs:12,26,31-33 states:
/// Behavior is undefined if any of the following conditions are violated:
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
/// * The total size `len * size_of::<T>()` of the slice must be no larger than `isize::MAX`,
/// and adding that size to `data` must not "wrap around" the address space.
/// See the safety documentation of [`pointer::offset`].
num/int_macros.rs:47 fixes signed MAX, independently of allocation tests:
pub const MAX: Self = (<$UnsignedT>::MAX >> 1) as Self;
str/mod.rs:498-501 exposes the identical-layout bytes:
pub const fn as_bytes(&self) -> &[u8] {
// SAFETY: const sound because we transmute two types with the same layout
unsafe { mem::transmute(self) }
}
str/mod.rs:507-510 separately imposes the string invariant:
/// The caller must ensure that the content of the slice is valid UTF-8
/// before the borrow ends and the underlying `str` is used.
///
/// Use of a `str` whose contents are not valid UTF-8 is undefined behavior.
The probe confirms target constants only. The general size condition follows
from these pinned slice and integer sources: usize/isize have width 64, signed
MAX is 2^63-1, and u8 occupies one byte, so the byte count and element count of
&[u8] have exactly the full bound 9223372036854775807. Initialized u8 values
may have arbitrary byte contents; the slice condition introduces no UTF-8
premise. A Rust str contributes the separate UTF-8 invariant and exposes the
same bytes through as_bytes. This concerns the modeled content/length of a
valid reference, not a claim that a given machine can allocate every such
length; pointer validity, alignment and lifetime obligations of real references
are not inferred from the probe or replaced by a sampled allocation test.
No smaller bound or physical-constructibility premise is introduced. The
mathematical classification of every finite byte string remains independent
of the Rust slice domain. All Tablet pairs, preservation claims and separate
GOAL applications are byte-unchanged; this record restores their primary
evidence without proving or changing any supplied GOAL.
CURRENT selected-target width binding: request 341, managed task 22
==================================================================
This appendix was recorded on 2026-10-10 UTC in the current private checkout.
It preserves all evidence above and stages only the missing environment
binding System.Platform.numBits = 64. Staging is not assumption approval,
human ratification, or closure of any dependent GOAL. No predecessor axiom
or predecessor preservation approval is used as current authority.
Current accepted scope and extraction provenance
------------------------------------------------
These commands inspect the CURRENT records, not predecessor extraction:
jq '.effective_tools, .resource_environment, .audits.setup.decision, \
.audits.setup.reason, .audits.adaptation.decision, \
.generated_modules' modeling-input/manifest.json
sed -n '13,33p' modeling-input/SETUP.md
cat modeling-input/extraction.json crate/rust-toolchain.toml
sha256sum modeling-input/manifest.json modeling-input/SETUP.md \
modeling-input/extraction.json crate/rust-toolchain.toml generated.lean
Relevant manifest JSON locators and exact values:
/effective_tools/cargo = /home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/cargo
/effective_tools/env/RUSTUP_TOOLCHAIN = nightly-2026-06-01
/effective_tools/lean = /home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean
/effective_tools/lean_paths/0 = /home/leanagent/pv_spike/tools/aeneas/backends/lean/.lake/build/lib/lean
/resource_environment/ELAN_TOOLCHAIN = leanprover/lean4:v4.30.0-rc2
/audits/setup/decision = accept
/audits/adaptation/decision = accept
/generated_modules/M = /home/leanagent/math/.trellis-viewer/create-jobs/dec2flt/native/generations/0003/dec2flt-r0003-preparation/observations/check-1791487636453795674/Generated/M.lean
The accepted /audits/setup/reason specifically records the pinned
nightly-2026-06-01 x86_64 configuration, development debug assertions, and
explicit overflow checks. SETUP.md, "Package and extraction", explains that
the configured rustc host is x86_64-unknown-linux-gnu and, with no target
override in extraction.json, is the extraction target. This is the accepted
setup selection. The toolchain's targets list alone would not prove what
target an extraction used.
Exact current extraction.json:
{
"crate": "crate",
"cargo_args": [],
"charon_args": [],
"aeneas_args": []
}
Exact current crate/rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-06-01"
profile = "minimal"
targets = ["x86_64-unknown-linux-gnu"]
Current SHA-256 identities (unchanged by this appendix):
4b71c7166d09bafef194283156edd10e58f25ffd1a498d785e0af04a600c5b32 modeling-input/manifest.json
76541e251dd08753ec262a142b47e411e2fe70056bf5230b4a4ef79083c8ea92 modeling-input/SETUP.md
a45e9bc0c57213e415eb8fa5cec983c44259d336522e6eec8760e7237b7779d7 modeling-input/extraction.json
a8a913abf2e9b3508218d8f83aec85bda8b0364eaee331ad394144cbec9b2c9b crate/rust-toolchain.toml
438af8398703b81aa311d7885dfb34f1909125bee48b096dacc93baefcc4bcf9 generated.lean
The GOAL.md source domain distinctions remain the ones documented in
SETUP.md, "Domains and goal observations": complete-string A/B versus
unsigned-body A/B, full-domain record/slow/special and successful-result
obligations, and unrestricted mathematical list/real goals. All 32 goals
remain pursued. This binding changes none of their statements or bounds.
Fresh managed compiler and domain probes
----------------------------------------
The commands below ran from ROOT, with command cwd ROOT/.trellis/scratch.
Each used the supplied pv_modeling.py exec wrapper; no compiler guard was
bypassed. Let:
ROOT=/home/leanagent/math/dec2flt-r0003-runtime/dispatch/22/repo
R=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/bin/rustc
W="$ROOT/.trellis/scratch/task-22-width"
P="$ROOT/reference/model-evidence/source-valid-byte-slice-probe.rs"
B="$W/source-valid-byte-slice-probe"
Exact invocations, with these variable expansions:
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --version --verbose
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --target x86_64-unknown-linux-gnu --print cfg
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$R" --edition 2024 \
--target x86_64-unknown-linux-gnu -C opt-level=0 -C debuginfo=0 \
-C overflow-checks=on -C debug-assertions=on \
--crate-name source_valid_byte_slice_probe "$P" -o "$B"
python3 .trellis/scripts/pv_modeling.py exec . \
--cwd .trellis/scratch --output .trellis/scratch/task-22-width \
--timeout 600 --command "$B"
Per-execution records, relative to W, contain complete argv, environment,
stdout/stderr paths and settings. All have exit_code=0, timeout=false:
exec-1791631852821355416/execution.json version
exec-1791631853161432714/execution.json default target cfg
exec-1791631853463233065/execution.json explicit x86_64 target cfg
exec-1791631853750677890/execution.json compile retained domain probe
exec-1791631854318725335/execution.json run fresh domain probe
The wrapper pins RUSTC and RUSTDOC to the selected toolchain, sets
RUSTUP_TOOLCHAIN to its absolute directory, and confines CARGO_HOME,
CARGO_TARGET_DIR and TMPDIR to the per-execution directory under W.
The manifest supplies LD_LIBRARY_PATH for that toolchain. No additional
feature cfg, Cargo profile, or source modification was used.
All stderr streams are empty; compile stdout is empty. Complete version
stdout:
rustc 1.98.0-nightly (14210df0e 2026-05-31)
binary: rustc
commit-hash: 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65
commit-date: 2026-05-31
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Complete default target cfg stdout (explicit-target stdout is byte-identical):
debug_assertions
emscripten_wasm_eh
fmt_debug="full"
overflow_checks
panic="unwind"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="x87"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_has_atomic_primitive_alignment="16"
target_has_atomic_primitive_alignment="32"
target_has_atomic_primitive_alignment="64"
target_has_atomic_primitive_alignment="8"
target_has_atomic_primitive_alignment="ptr"
target_has_reliable_f128
target_has_reliable_f16
target_has_reliable_f16_math
target_object_format="elf"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
ub_checks
unix
Complete freshly executed domain-probe stdout:
arch=x86_64
usize_bits=64
isize_max=9223372036854775807
u8_size=1
Identity command and raw SHA-256 results (paths abbreviated above):
sha256sum "$R" "$P" "$B" \
"$W/exec-1791631854318725335/stdout" \
"$W/exec-1791631853161432714/stdout" \
"$W/exec-1791631853463233065/stdout"
162c2a2d2d89b94e5bc2ec6b179a49d12a7ea1527db9ff1df20b5d09c432924b R
b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd P
87dc3b9b7a46506d2205503d8aa007b451c452968af48d1ba5961a821934ee55 B
01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4 fresh probe stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 default cfg stdout
e4a6bae58d5e64db9a5f988ca37cee93ed3334a7926238050809bd2d0c4112f0 explicit cfg stdout
cmp of the two cfg stdout files returned 0 with empty output. cmp of
reference/model-evidence/source-valid-byte-slice-probe.out against fresh
probe stdout also returned 0 with empty output. The retained source and
retained output were not edited. These executions corroborate target
constants, not parser behavior or physical realizability of enormous inputs.
Primary Rust documentation
--------------------------
Current pinned documentation source:
S=/home/leanagent/.rustup/toolchains/nightly-2026-06-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src
sha256sum "$S/primitive_docs.rs"
sed -n '1480,1498p' "$S/primitive_docs.rs"
Raw SHA-256:
c4b8627dd67d5dac8f383f383a9e7ff1229ea43e7599610fc61988694cf0f3e5 core/src/primitive_docs.rs
primitive_docs.rs:1480-1488 documents isize as pointer-sized signed;
1490-1498 documents usize as pointer-sized unsigned. Both document 4 bytes
on a 32-bit target and 8 bytes on a 64-bit target. The pinned signed MAX,
slice safety and string UTF-8 sources are retained earlier in this file.
Primary public Rust-docs locators, consulted 2026-10-10 UTC:
https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types
[type.numeric.int.size.usize] and [type.numeric.int.size.isize]:
usize/isize widths match the platform pointer width; isize uses signed
two's-complement representation.
https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width
[cfg.target_pointer_width]: compiler target pointer-width configuration.
These docs explain what the configured width means; the CURRENT accepted
selection and pinned compiler results establish which target was selected.
They do not state that System.Platform.numBits is 64 on every Rust target.
Installed Aeneas and Lean correspondence
---------------------------------------
Let:
A=/home/leanagent/pv_spike/tools/aeneas/backends/lean/Aeneas/Std
L=/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2
Commands used to inspect these CURRENT installed primary sources:
sha256sum "$A/Scalar/Core.lean" "$A/Slice.lean" \
"$A/Scalar/Casts.lean" "$A/Scalar/Ops/Sub.lean" \
"$L/src/lean/Init/Prelude.lean" "$L/bin/lean"
sed -n '46,78p;90,95p;103,110p;118,133p;649,661p' "$A/Scalar/Core.lean"
sed -n '20,22p' "$A/Slice.lean"
sed -n '16,42p' "$A/Scalar/Casts.lean"
sed -n '15,21p' "$A/Scalar/Ops/Sub.lean"
sed -n '587,602p' "$A/Scalar/Core.lean"
sed -n '2275,2297p' "$L/src/lean/Init/Prelude.lean"
file "$L/bin/lean"
Raw SHA-256 identities:
a1c26c125a59bba635a2b2c170186ce07168c43308bcf386d508ebd77f01520e A/Scalar/Core.lean
c941826e8da78e1c517cae719b9f58e64671331957cce0b3c22c321a6c62c328 A/Slice.lean
7ace724788adcdfa7f3ed285f736cb56f48ddb8681d2c8025f7b346ca3e0f15a A/Scalar/Casts.lean
bd6716dad017ce0c0e9cf9084f9223eb5407ece920853ae7675cbe2362dd5e37 A/Scalar/Ops/Sub.lean
8f7cb4fa6dd34299944ad2b083b8a4b205e69c50893df3b199d130a2fbf0280b L/src/lean/Init/Prelude.lean
3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf L/bin/lean
Relevant Scalar/Core.lean definitions (attributes/comments omitted):
def UScalarTy.numBits (ty : UScalarTy) : Nat :=
match ty with
| Usize => System.Platform.numBits
| U8 => 8
| U16 => 16
| U32 => 32
| U64 => 64
| U128 => 128
def IScalarTy.numBits (ty : IScalarTy) : Nat :=
match ty with
| Isize => System.Platform.numBits
| I8 => 8
| I16 => 16
| I32 => 32
| I64 => 64
| I128 => 128
structure UScalar (ty : UScalarTy) where
bv : BitVec ty.numBits
def UScalar.val {ty} (x : UScalar ty) : Nat := x.bv.toNat
structure IScalar (ty : IScalarTy) where
bv : BitVec ty.numBits
def IScalar.val {ty} (x : IScalar ty) : Int := x.bv.toInt
irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1
irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1)
irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1
irreducible_def Usize.numBits : Nat := UScalarTy.Usize.numBits
irreducible_def Isize.numBits : Nat := IScalarTy.Isize.numBits
irreducible_def Usize.max : Nat := 2^Usize.numBits - 1
irreducible_def Isize.min : Int := -2^(Isize.numBits - 1)
irreducible_def Isize.max : Int := 2^(Isize.numBits - 1) - 1
abbrev Usize := UScalar .Usize
abbrev Isize := IScalar .Isize
The val codomains above use ASCII Nat/Int for the source's equivalent
mathematical notation; the rest of the displayed declaration bodies is exact.
Slice.lean:22 has:
def Slice (alpha : Type u) := { l : List alpha // l.length <= Usize.max }
Here alpha and <= are ASCII renderings of the source's binder and inequality.
The slice carrier is larger than the source-valid domain; the existing hook
SourceValidByteSlice continues to impose length <= 2^63-1. The axiom does
not assert a property about arbitrary over-approximating Slice values.
Casts.lean:18-42 defines the four cast bodies by, respectively,
x.bv.zeroExtend tgt_ty.numBits, x.bv.zeroExtend tgt_ty.numBits,
x.bv.signExtend tgt_ty.numBits, and x.bv.signExtend tgt_ty.numBits.
These are total bitvector casts, not rejecting casts. Core.lean:587-602
defines checked constructors through check_bounds, returning integerOverflow
on failure. Ops/Sub.lean:20-21 has the exact signed subtraction body:
def IScalar.sub {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) :=
IScalar.tryMk ty (x.val - y.val)
For a source-grounded example of why the width matters, the unchanged
crate/dec2flt/common.rs:34-36 has:
fn offset_from(&self, other: &Self) -> isize {
other.len() as isize - self.len() as isize
}
Its pinned declaration in
Tablet/SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from.lean
uses Slice.len other, UScalar.hcast .Isize, Slice.len self,
UScalar.hcast .Isize, and then checked signed subtraction, in that order.
At width 64, each source-valid length is <= 2^63-1, so these casts preserve
its nonnegative integer value; any difference of two such lengths is within
[-(2^63-1),2^63-1]. This width correspondence does not prove a parser loop
invariant, record property, or full parser execution.
Prelude.lean:2275-2297 documents the word-size primitive as intentionally
opaque, to avoid requiring host and target word sizes to coincide at kernel
type checking. An ASCII transcription of its central declarations is:
@[extern "lean_system_platform_nbits"] opaque System.Platform.getNumBits : Unit -> Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=
fun _ => <64, Or.inr rfl> -- inhabitant
def System.Platform.numBits : Nat :=
(getNumBits ()).val
theorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=
(getNumBits ()).property
The arrow and tuple above are ASCII renderings of the source's Lean symbols.
The opaque body's inhabitant does not establish numBits = 64 by kernel
reduction. The new axiom supplies only the already-selected environment
binding. No native_decide, native proof, or reduction of this opaque
declaration was used to claim that equality.
Raw file output for the manifest-selected Lean executable:
/home/leanagent/.elan/toolchains/leanprover--lean4---v4.30.0-rc2/bin/lean: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped
This executable identity is corroborating environment evidence, not a
kernel proof of an opaque constant. Current Rust and Lean execution
environments are consistent with the selected width, and the installed
Aeneas API explicitly uses that primitive for the two pointer-sized types.
Preservation boundary
---------------------
Only the paired assumption block and this append-only evidence are authored.
The new axiom is precisely:
axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64
It has no quantified containers and no parser correctness conclusion. It
does not narrow the source-valid domain or either A/B bound. Under the
binding, Usize.max is 2^64-1 and Isize.max is 2^63-1. Every abstract byte list
of a valid selected-target slice fits the carrier unchanged; the existing
source hook still rules out the extra carrier lengths. String UTF-8 and
arbitrary-byte helper domains remain separate. No physical-allocation
existence premise is asserted. This same source-environment binding applies
to positive and exact-negation arguments. The required verification lanes
and human gate must approve it before dependent registered proof work.
Assumptions / kernel axioms
- Dec2Flt.P340_T1_selected_target_numBits
Explicit premise record
Requirements depending on this item (1)
- P9_T1_DispatchComponentCompliance
These requirements are linked to this item through the declared dependencies of their proofs.
Record details
| Record source | tcb_manifest.json |
|---|---|
| Kind | environment premise |
Exact source record
{
"adversarial_hunt_result": "Environment consistency checks found no conflicting pinned commitment. I read the entire cited reference/model-evidence/source-valid-byte-slice.txt, including its CURRENT selected-target appendix, and checked the current manifest, SETUP.md, extraction.json, rust-toolchain.toml, paired assumption, source-validity hook, original/adapted ByteSlice.offset_from, and pinned extracted offset_from. Independent SHA-256 checks matched every appendix identity for the current manifest, SETUP, extraction settings, toolchain file, generated.lean, rustc executable, pinned primitive_docs.rs, installed Aeneas scalar/slice/cast/subtraction sources, and installed Lean Prelude/executable. Read-only invocations of the exact pinned rustc executable with --version --verbose, --print cfg, and --target x86_64-unknown-linux-gnu --print cfg all completed successfully. They reproduced rustc 1.98.0-nightly commit 14210df0e27ccd7d9e6a05b8085cbd438e4bbc65, host x86_64-unknown-linux-gnu, and matching default/explicit cfg output with target_pointer_width set to 64. The manifest-selected Lean executable is ELF64 x86-64. Direct inspection of the installed sources confirmed the bitvector carriers, literal widths of fixed-size types, unchanged truncating/extending casts, checked constructors/subtraction, and Slice's Usize.max length bound. At width 64, every abstract source-valid byte list of length at most 2^63-1 fits the 2^64-1 model carrier unchanged; two such lengths also cast exactly to isize and their difference lies in [-(2^63-1),2^63-1]. Pinned core slice safety, signed MAX, and string sources agree with these content-length and UTF-8 distinctions. I also opened both cited primary Rust Reference pages: https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types and https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width; they support target-dependent pointer widths, not universal width 64. Limits: the appendix retains the probe source, settings, raw results, and per-execution locators, but the task-22 per-execution JSON/stream files are absent from this audit checkout and the cited dispatch/22 path. I therefore did not independently inspect those auxiliary records or recompile/run that probe, and do not claim to have done so. Its reported usize_bits=64 and isize_max=9223372036854775807 are corroborative only; eligibility rests on the accepted provenance and independently checked primary definitions/configuration. Neither compiler queries, executable identity, nor a successful probe establish the opaque Lean equality by kernel reduction, universal parser correctness, physical allocatability of enormous inputs, pointer/lifetime validity, or correctness on other Rust targets. No in-model refutation or proof of C was attempted, and no source-bug or GOAL-polarity conclusion is drawn. Human ratification remains required.",
"citation_locator": "reference/model-evidence/source-valid-byte-slice.txt, CURRENT selected-target width binding appendix (line 341 onward): current modeling-input/manifest.json /effective_tools, /resource_environment, /audits/setup and /generated_modules/M; modeling-input/SETUP.md Package and extraction; modeling-input/extraction.json; crate/rust-toolchain.toml; five fresh managed compiler/probe records and raw outputs. Primary Rust-docs: pinned core/src/primitive_docs.rs:1480-1498; https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types and https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width. Model correspondence: installed Aeneas/Std/Scalar/Core.lean:46-78,90-133,649-661; installed Lean Init/Prelude.lean:2275-2297; current source hashes and manifest-selected ELF64 Lean executable identity retained in the same appendix.",
"claim_class": "environment",
"classification": "rust-undermodel-assumption",
"id": "dec2flt-r0003-selected-x86_64-width-64",
"lean_statement": "axiom Dec2Flt.P340_T1_selected_target_numBits : System.Platform.numBits = 64",
"name": "Dec2Flt.P340_T1_selected_target_numBits",
"needed_by": [
"P9_T1_DispatchComponentCompliance"
],
"nl_statement": "\\begin{definition}\nFor the already-selected nightly-2026-06-01\n\\texttt{x86\\_64-unknown-linux-gnu} extraction environment, the platform\nparameter used by the installed Aeneas model satisfies\n$\\mathtt{System.Platform.numBits}=64$.\n\\end{definition}\n\\begin{preservation}\n\\begin{claim}\nThis equation binds Aeneas's pointer-sized scalar parameter to the source\nenvironment already selected for this extraction. Its \\texttt{Usize} and\n\\texttt{Isize} therefore represent, respectively, the unsigned and signed\n64-bit Rust pointer-sized integers. Every configured source-valid byte\nslice's contents and length remain representable, and Rust strings retain\ntheir separate UTF-8 requirement. No source domain, A/B bound, source\noperation, extracted declaration, or GOAL proposition is changed. The\nbinding is independent of whether a GOAL is proved or disproved.\n\\end{claim}\n\\begin{proof}\nThe current manifest's \\texttt{effective\\_tools},\n\\texttt{resource\\_environment}, and accepted setup audit select the pinned\nnightly-2026-06-01 compiler and the x86\\_64 environment. The current\n\\texttt{SETUP.md}, under ``Package and extraction,'' explains that the\ncompiler host is the extraction target: \\texttt{extraction.json} has empty\nCargo, Charon, and Aeneas argument lists, with no target override.\n\\texttt{crate/rust-toolchain.toml} records that channel and\n\\texttt{x86\\_64-unknown-linux-gnu}. The manifest also identifies the\ninstalled Lean executable and the Aeneas library path. The current file\nidentities, exact record locators, and relevant excerpts are retained in the\n``CURRENT selected-target width binding'' appendix of\n\\evidenceref{reference/model-evidence/source-valid-byte-slice.txt}.\nThis argument uses the current accepted environment, not a predecessor's\nassumption or approval.\n\nRust's pointer-sized integer documentation says that both \\texttt{usize}\nand \\texttt{isize} have the platform pointer width; \\texttt{isize} has signed\ntwo's-complement interpretation. The pinned core documentation and Rust\nReference locators are in\n\\evidenceref{reference/model-evidence/source-valid-byte-slice.txt}.\nFresh managed invocations of the pinned compiler report host\n\\texttt{x86\\_64-unknown-linux-gnu}; both its default \\texttt{--print cfg}\nand explicit-target invocation report \\texttt{target\\_pointer\\_width=\"64\"}.\nTheir complete raw outputs agree. The unchanged retained probe, freshly\ncompiled for that target with overflow checks and debug assertions enabled,\nreports \\texttt{usize\\_bits=64},\n\\texttt{isize\\_max=9223372036854775807}, and \\texttt{u8\\_size=1}; its raw\noutput agrees byte-for-byte with the retained output. These probes\ncorroborate the selected compiler environment; they neither sample parser\ncorrectness nor establish a universal claim by testing.\n\nThe installed Aeneas \\texttt{Scalar/Core.lean} defines\n\\texttt{UScalarTy.numBits .Usize} and\n\\texttt{IScalarTy.numBits .Isize} to be exactly\n\\texttt{System.Platform.numBits}. It defines the carriers as bitvectors of\nthese widths, their observations as \\texttt{toNat} and \\texttt{toInt}, and\n\\texttt{Usize} and \\texttt{Isize} as the corresponding scalar kinds. Thus\nthis primitive, rather than an independently authored parser predicate, is\nthe missing width parameter. Lean's installed \\texttt{Init/Prelude.lean}\ndescribes \\texttt{getNumBits} as the current platform's word size, deliberately\nopaque to kernel reduction, and defines \\texttt{numBits} as its value.\nIts type guarantees only the disjunction 32 or 64; the displayed default\ninhabitant is not a proof of the selected equality. The manifest-selected\nLean executable is independently identified as ELF64 x86-64, consistent with\nthe selected Rust target. The exact installed sources, hashes, and executable\nidentity are in\n\\evidenceref{reference/model-evidence/source-valid-byte-slice.txt}.\nConsequently binding this platform parameter to the already-selected\npointer width 64 is a source-environment correspondence premise, not a new\nRust language claim that every target has width 64 and not a kernel proof\nobtained by native evaluation.\n\nSubstituting 64 in the installed scalar definitions gives unsigned range\n$0\\leq n\\leq 2^{64}-1$ and signed range\n$-2^{63}\\leq z\\leq 2^{63}-1$, with the same bitvector interpretations as\nRust's selected \\texttt{usize}/\\texttt{isize}. Fixed-width scalar kinds have\nliteral widths in the same definitions, so none is changed by this binding.\nThe installed casts continue to truncate or extend bitvectors, and the\ninstalled checked constructors continue to return integer-overflow failure\noutside their scalar bounds. No cast is replaced by a rejecting operation\nand no failure branch is removed. The appendix in\n\\evidenceref{reference/model-evidence/source-valid-byte-slice.txt} retains\nthese definitions as well as the source and pinned extraction of\n\\texttt{ByteSlice.offset\\_from}. For example, two source-valid byte-slice\nlengths are in $[0,2^{63}-1]$; their unsigned-to-signed 64-bit casts preserve\nthe lengths, and their difference lies in\n$[-(2^{63}-1),2^{63}-1]$, within the signed range. This explains the\nrelevant source/model width agreement; it assumes no scan invariant or\nparser return property.\n\nThe existing definition \\noderef{SourceValidByteSlice} states exactly the\nlength condition $\\ell\\leq 9223372036854775807$, with no byte-value or UTF-8\nrestriction. The pinned Rust slice and string evidence in\n\\evidenceref{reference/model-evidence/source-valid-byte-slice.txt} gives that\nbyte-size limit and the separate string UTF-8 invariant. Aeneas's installed\n\\texttt{Slice} is a list with length at most \\texttt{Usize.max}, now\n$2^{64}-1$. For any represented source-valid contents, the same list of\nbytes supplies a model slice because\n$2^{63}-1\\leq 2^{64}-1$; its length and every element are unchanged.\nConversely the source-validity predicate still excludes lengths above\n$2^{63}-1$ even though the model carrier permits them. This is coverage of\nthe abstract contents of valid references, not an assertion that every\nsuch size can be physically allocated. Substrings and sign-stripped bodies\nretain the same length bound; UTF-8 is neither added to arbitrary helper\nbyte slices nor removed from strings.\n\nThe binding therefore preserves the selected source observations while\nretaining the exact configured domain. In particular it does not add a\ngrammar condition to full-domain helper goals, change\n$A=3458764513820540928$ or $B=576460752303421440$, identify complete strings\nwith their unsigned bodies, or assume normal return, rounding, record bounds,\ncomponent inhabitability, or dispatcher compliance. The equation describes\nthe same environment for both polarities. It is staged for correspondence,\nenvironment-preservation soundness, assumptions eligibility, and human\nratification; no dependent GOAL proof is claimed here.\n\\end{proof}\n\\begin{goalproof}{assembly_correspondence}\nThe input pair and cast/shift/OR assembly use fixed-width fields and binary64\nwords. Their widths and unrestricted domain are unchanged by the shared\nenvironment argument above.\n\\end{goalproof}\n\\begin{goalproof}{classification_determinism}\nThe mathematical classification and numeric content range over every finite\nbyte list, independently of Rust pointer width; this domain remains unbounded.\n\\end{goalproof}\n\\begin{goalproof}{classification_significand_digit}\nThe grammar and its digit positions are unchanged for every finite byte list;\nno source-representability condition is introduced into this mathematical goal.\n\\end{goalproof}\n\\begin{goalproof}{classification_totality}\nEvery finite byte list remains in the mathematical classification domain,\nincluding lists beyond the Rust slice bound. The binding is noninterfering.\n\\end{goalproof}\n\\begin{goalproof}{dispatch_abstract_composition}\nThe shared argument preserves complete-string A/B bounds and unsigned-body\nhelper domains. Special, native, integer, assembly, and unrestricted slow\ncontracts retain their original domains; contract inhabitability and abstract\nnormal-output existence remain conclusions to prove, not supplied premises.\n\\end{goalproof}\n\\begin{goalproof}{dispatch_component_compliance}\nConcrete string bytes and sign-stripped helper bodies retain the selected\n64-bit length/offset interpretation. The A/B preconditions, actual call\nagreement, full-domain slow obligation, and inhabited compatible package\nrequirements are unchanged and are not asserted by the width equation.\n\\end{goalproof}\n\\begin{goalproof}{exponent_value_agreement}\nExact and accumulated exponents and their rounding targets are mathematical\nobservations of the same finite byte lists. Neither the pre-update $2^{59}$\nfold nor ordinary mathematical exponent meaning is changed.\n\\end{goalproof}\n\\begin{goalproof}{integer_correct_or_defer}\nAll i64 exponents, u64 mantissas, raw pairs, and the on-normal-return conclusion\nremain fixed-width and unrestricted. The environment binding assumes no\nnormal return or rounding fact.\n\\end{goalproof}\n\\begin{goalproof}{native_correct_or_defer}\nEvery Decimal record and its fixed-width binary64 operations remain in scope.\nThe ordinary/disguised paths and their on-normal correctness-or-defer\nrequirements, including the many-digits conclusion, are unchanged.\n\\end{goalproof}\n\\begin{goalproof}{number_helper_acceptance}\nEvery nonempty source-valid unsigned numeric body of length at most A remains\nrepresentable with identical bytes and 64-bit lengths. No exponent-digit\nlimit or normal-Some premise is added.\n\\end{goalproof}\n\\begin{goalproof}{number_helper_accumulated_value}\nThe unsigned numeric slice A-domain, full-significand accumulated value,\nreturned fields, and exact/half-open representation conclusions are unchanged.\nThe shared width argument fixes only lengths and indices, not representation.\n\\end{goalproof}\n\\begin{goalproof}{number_helper_record_bounds}\nEvery nonempty source-valid slice remains in the full domain, without an A/B\nor grammar restriction. The on-return negative/mantissa conclusion is\nunchanged and is not a consequence assumed in this binding.\n\\end{goalproof}\n\\begin{goalproof}{number_helper_rejection}\nAll nonempty source-valid nonnumeric bodies of length at most A retain their\nbytes, including malformed tails after exponent updates stop. The binding\nadds neither a grammar restriction nor a normal-None premise.\n\\end{goalproof}\n\\begin{goalproof}{parser_accumulated_rounding}\nThe complete numeric-string A-domain and actual full-significand accumulated\nvalue retain their meanings. Acceptance, rounding, and lexical signed\nzero/infinity observations are not supplied by the environment premise.\n\\end{goalproof}\n\\begin{goalproof}{parser_equal_target_rounding}\nThe complete-string A-bound and equality of ordinary/accumulated rounding\ntargets are unchanged. Both targets and the lexical sign use the same bytes.\n\\end{goalproof}\n\\begin{goalproof}{parser_exact_rounding}\nThe complete numeric-string B-bound is preserved, not replaced by a body\nbound. The ordinary unbounded explicit-exponent meaning and binary64 rounding\nobservation are unchanged, including signed zero and infinity.\n\\end{goalproof}\n\\begin{goalproof}{parser_infinity}\nEvery source-valid infinity literal and optional sign retains the same bytes\nand full source domain. Fixed-width infinity words and lexical sign are\nunaffected; acceptance is not assumed.\n\\end{goalproof}\n\\begin{goalproof}{parser_invalid_rejection}\nEvery invalid complete Rust string of length at most A remains representable.\nWhole-string grammar, UTF-8, normal Err, and checked-panic distinctions are\nunchanged, including tails after exponent accumulation stops.\n\\end{goalproof}\n\\begin{goalproof}{parser_nan_acceptance}\nAll source-valid NaN spellings and signs retain their bytes and full domain;\nthe fixed-width NaN classification observation is unchanged.\n\\end{goalproof}\n\\begin{goalproof}{parser_non_nan_results}\nEvery successful non-NaN-literal source string remains in the unrestricted\nsource domain. The binding changes neither its classification nor the\nfixed-width returned-word observation.\n\\end{goalproof}\n\\begin{goalproof}{parser_numeric_acceptance}\nEvery numeric complete Rust string within A retains its original optional\nsign and arbitrary exponent suffix. Its body remains no longer than that\ncomplete string; no extra length or exponent restriction is introduced.\n\\end{goalproof}\n\\begin{goalproof}{parser_numeric_sign}\nThe full on-success numeric-string domain, lexical sign, and returned\nbinary64 sign observation are unchanged, including zero and infinity.\n\\end{goalproof}\n\\begin{goalproof}{parser_selected_exponent}\nThe full on-success numeric-string domain and actual selected final raw-pair\nobservations are unchanged. The binding asserts no biased-exponent bound\nand invents no pair for a direct-return path.\n\\end{goalproof}\n\\begin{goalproof}{parser_selected_magnitude_sign}\nActual selected pairs and pre-sign assembly words are the same fixed-width\nobservations. The unrestricted on-success domain and clear-sign-bit\nrequirement are unchanged, not asserted by the width premise.\n\\end{goalproof}\n\\begin{goalproof}{parser_signed_zero}\nEvery accepted exact-zero source-valid numeric string remains in the full\ndomain, without A/B. Exact zero, lexical sign, and the two binary64 zero\nwords retain their meanings.\n\\end{goalproof}\n\\begin{goalproof}{parser_totality}\nEvery complete Rust string within A, including empty, sign-only, and invalid\nstrings, retains its bytes and UTF-8 condition. The binding asserts neither\ntermination nor absence of checked panic nor normal float/error output.\n\\end{goalproof}\n\\begin{goalproof}{rounding_determinism}\nThe domain remains every nonnegative real, with the same binary64 magnitude\nrounding relation; no pointer-sized carrier is involved.\n\\end{goalproof}\n\\begin{goalproof}{rounding_totality}\nEvery nonnegative real and the finite/infinite rounding targets remain in\nthe unchanged mathematical domain, independently of platform width.\n\\end{goalproof}\n\\begin{goalproof}{slow_accumulated_rounding}\nEvery source-valid unsigned numeric slice remains in the full unrestricted\nsource domain, without A/B. Saved counts, cancellation-aware i64 subtraction,\nsaturating addition, and final point clamp retain their source operations;\nthe binding assumes no normal return or diagnostic rounding result.\n\\end{goalproof}\n\\begin{goalproof}{special_helper_infinity}\nEvery source-valid byte slice and either separate sign retain their full\ndomain; identical keyword bytes and signed infinity observations are used.\n\\end{goalproof}\n\\begin{goalproof}{special_helper_nan}\nEvery source-valid byte slice and either separate sign retain their full\ndomain; unsigned NaN keyword recognition and NaN classification are unchanged.\n\\end{goalproof}\n\\begin{goalproof}{special_helper_rejection}\nAll source-valid non-special byte slices and either sign remain in scope,\nwithout UTF-8 or A/B conditions. Rejection and normal-return behavior remain\nrequirements to establish, not assumptions.\n\\end{goalproof}\n\\end{preservation}",
"provenance": "worker-authored, assumptions-lane gated, human-ratified (PV under-model assumptions Slice 2)",
"relativization_probe": "",
"rust_justification": "The current accepted setup selects nightly-2026-06-01 x86_64-unknown-linux-gnu; extraction.json has no target override, so the pinned compiler host is the extraction target. Fresh managed default and explicit-target cfg outputs agree and report pointer width 64; the unchanged domain probe reproduces usize_bits=64 and isize_max=9223372036854775807. Rust pointer-sized integer documentation ties usize/isize to that target width. The installed Aeneas scalar API uses exactly System.Platform.numBits for both Usize and Isize, while installed Lean documents that primitive as the platform word size but deliberately leaves it opaque to kernel reduction. The selected Lean executable is ELF64 x86-64. C supplies this missing environment correspondence, not a universal Rust width assertion, parser correctness invariant, or native-evaluation proof. Substitution gives the selected unsigned/signed 64-bit ranges and carrier capacity for all unchanged source-valid contents; the original length hook and separate string UTF-8 condition still exclude extra carrier values. No source, extraction, A/B bound, goal proposition, or polarity changes. Probes corroborate the source-grounded argument rather than proving parser properties."
}Captured evidence identities
[
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.out",
"sha256": "01a71f1529010d8652ee73ee42a63dfcd93a4019d9739732d33f69d14ab588b4",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice-probe.rs",
"sha256": "b75928df9e68445ef508e70db9b4d11ec4411a2210cd057e1ef0f2ebe06f8bcd",
"cited_by": [
"reference/model-evidence/source-valid-byte-slice.txt"
]
},
{
"path": "reference/model-evidence/source-valid-byte-slice.txt",
"sha256": "48684c78987a8020ffc28a19c192ab361fa9c214388546046242a4507f0d493c",
"cited_by": [
"tcb_manifest.json"
]
}
]