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 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 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}::shr] Visibility: public -/ @[rust_fun "core::ops::bit::{core::ops::bit::Shr}::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 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.