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:

  49949682d8e6c7a75a58e7f2535322d51f0af7513b8dad0f865ff3fa4387b692  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.
