DecimalSeqLittleEndianLane

Lean checked

Statement

This explanation was written alongside the formalization to describe the statement and its reasoning.

Helper · Little-endian U64 lane

For a modeled U64 value x and every k<8, byte k of x.toLEBytes has natural value (x/256^k)\bmod256.

Lean statement

Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.

import Tablet.Preamble

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: DecimalSeqLittleEndianLane]
theorem DecimalSeqLittleEndianLane (x : Std.U64) (k : Nat) (hk : k < 8) :
    (x.bv.toLEBytes[k]'(by simp [BitVec.toLEBytes_length]; omega)).toNat =
      (x.val / 256^k) % 256 := by
Proof

Natural-language proof

The status above describes the Lean proof. Its explanatory prose may remain a sketch after that proof closes.

Explanatory prose status

Prose retained as authored. The explanatory prose is preserved as it stood when captured.

Proof

The U64 bound gives x<2^{64}. There are exactly eight cases for k. In each case expand the model's little-endian byte conversion: its kth byte is the width-eight truncation of the right shift by 8k. Bit-vector toNat of that truncation is remainder modulo 256, and natural right shift by 8k is division by 2^{8k}=256^k. Kernel numeral normalization in the eight cases gives the displayed equality.

Lean proof


  have hx : x.val < 18446744073709551616 := by scalar_tac
  have hkcases : k = 0 \/ k = 1 \/ k = 2 \/ k = 3 \/ k = 4 \/
      k = 5 \/ k = 6 \/ k = 7 := by omega
  rcases hkcases with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl
  all_goals simp [BitVec.toLEBytes, BitVec.toNat_setWidth,
    Nat.shiftRight_eq_div_pow]
  all_goals omega

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.Preamble

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: DecimalSeqLittleEndianLane]
theorem DecimalSeqLittleEndianLane (x : Std.U64) (k : Nat) (hk : k < 8) :
    (x.bv.toLEBytes[k]'(by simp [BitVec.toLEBytes_length]; omega)).toNat =
      (x.val / 256^k) % 256 := by
-- BODY
  have hx : x.val < 18446744073709551616 := by scalar_tac
  have hkcases : k = 0 \/ k = 1 \/ k = 2 \/ k = 3 \/ k = 4 \/
      k = 5 \/ k = 6 \/ k = 7 := by omega
  rcases hkcases with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl
  all_goals simp [BitVec.toLEBytes, BitVec.toNat_setWidth,
    Nat.shiftRight_eq_div_pow]
  all_goals omega

end dec2flt_model

Proof structure

Follow the declared dependencies to read the supporting statements and proofs.

Explore this dependency tree

Inspect related source (44)
More program dependencies (11)
Standard-library dependencies (30)

Related source and models come from the extraction records and declared dependencies.

Proof assumptions and review

Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.

Transitive assumptions

This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.

Helper theorems included
Technical checking records
Local closure summary
{
  "node": "DecimalSeqLittleEndianLane",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "a534dff2f9f30e32b28ade00127cee6f612f5c3ca1a48313fd972aac010bd659",
  "active_statement_hash": "3f2cc55d0d18ffbce125f0553d9ab9660d0464ca9ea1083f823132e8fe4a59ea",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "ab64d13f256386ee0e494a5abcc6a5db49512cf3d90bbdfcabd6327793a31f95",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-167",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {}
}
Prose assessment
{
  "label": "Lean proof closed; predictive prose review no longer required",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": "sound-v2:3a3bdaea07fc1333478aff0c2b0c1da03a9d6cb65dc76952ba8ba6eb5c351440",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}