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: 49949682d8e6c7a75a58e7f2535322d51f0af7513b8dad0f865ff3fa4387b692 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 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 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}::shl] Visibility: public -/ @[rust_fun "core::ops::bit::{core::ops::bit::Shl}::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 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 2fc182c0c7acccad30c449ca349b999759b84e8ed4ec9d590e8295e43eeec077 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.