num_imp_dec2flt_lemire_compute_product_approx

Lean checked

Definition and explanation

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

No paired prose available.

Lean definition

This module includes declarations linked to the Aeneas extraction. The source view pairs each matched declaration with its Rust input.

import Tablet.Assumptions
import Tablet.Preamble
import Tablet.num_imp_dec2flt_lemire_full_multiplication
import Tablet.num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE
import Tablet.num_imp_dec2flt_table_POWER_OF_FIVE_128
import Tablet.num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
noncomputable section
namespace dec2flt_model

-- [TABLET NODE: num_imp_dec2flt_lemire_compute_product_approx]
/-- [dec2flt_model::num::imp::dec2flt::lemire::compute_product_approx]:
    Source: 'num/imp/../../dec2flt/lemire.rs', lines 134:0-167:1 -/
def num.imp.dec2flt.lemire.compute_product_approx
  (q : Std.I64) (w : Std.U64) (precision : Std.Usize) :
  Result (Std.U64 × Std.U64)
  :=
-- BODY
do
  let i ←
    lift (IScalar.cast .I64 num.imp.dec2flt.table.SMALLEST_POWER_OF_FIVE)
  massert (q >= i)
  let i1 ←
    lift (IScalar.cast .I64 num.imp.dec2flt.table.LARGEST_POWER_OF_FIVE)
  massert (q <= i1)
  massert (precision <= 64#usize)
  let mask ←
    if precision < 64#usize
    then 18446744073709551615#u64 >>> precision
    else ok 18446744073709551615#u64
  let i2 ←
    lift (IScalar.cast .I64 num.imp.dec2flt.table.SMALLEST_POWER_OF_FIVE)
  let i3 ← q - i2
  let index ← lift (IScalar.hcast .Usize i3)
  let p ← Array.index_usize num.imp.dec2flt.table.POWER_OF_FIVE_128 index
  let (lo5, _) := p
  let (_, hi5) := p
  let (first_lo, first_hi) ← num.imp.dec2flt.lemire.full_multiplication w lo5
  let i4 ← lift (first_hi &&& mask)
  if i4 = mask
  then
    let (_, second_hi) ← num.imp.dec2flt.lemire.full_multiplication w hi5
    let first_lo1 ← lift (core.num.U64.wrapping_add first_lo second_hi)
    if second_hi > first_lo1
    then let first_hi1 ← first_hi + 1#u64
         ok (first_lo1, first_hi1)
    else ok (first_lo1, first_hi)
  else ok (first_lo, first_hi)
Preservation and explanation

Natural-language argument

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.

The authored explanation is included with the statement above.

Download Lean source · Download TeX source

Proof structure

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

Explore this dependency tree

Inspect related source (26)
More program dependencies (15)
Standard-library dependencies (8)

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": "num_imp_dec2flt_lemire_compute_product_approx",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "175eb91bd0c81d7710b4cce5758e9e8546f419822437aa90534c5b4354ba7276",
  "active_statement_hash": "",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "b3d2e5a7a57ad9d2abdfb1c60bd76050a5cafa6a2be969c219d3ae71b2a8ade5",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-1",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {
    "num_imp_dec2flt_lemire_full_multiplication": "46682dcb8efbf576",
    "num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE": "133d9b18714defd6",
    "num_imp_dec2flt_table_POWER_OF_FIVE_128": "bdd28e83b60fa362",
    "num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE": "5394ae3df8a14bc9"
  }
}
Prose assessment
{
  "label": "Prose review has no verdict in this snapshot",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": null,
  "superseded_for_theorem_closure": false
}
Review verdicts
{}