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.
