P401_T1_ComputeZeroPair

Lean checked

Statement

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

Lemma · Successful zero-mantissa conversion selects zero

For any signed 64-bit exponent q and pair fp, if the integer operation of ActualDispatchOperations on (q,0) returns normally with fp, then fp has mantissa zero and biased exponent zero. There is no restriction on q.

Lean statement

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

import Tablet.P9_T1_ActualDispatchOperations
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P401_T1_ComputeZeroPair]
theorem P401_T1_ComputeZeroPair (q : Std.I64)
    (fp : num.imp.dec2flt.common.BiasedFp)
    (hresult : P9_T1_ActualDispatchOperations.integer q 0#u64 = ok fp) :
    fp = { m := 0#u64, p_biased := 0#i32 } := 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

Unfold the integer field of ActualDispatchOperations and num imp dec2flt lemire compute float. Its first call to num imp dec2flt common BiasedFp zero pow2 at signed exponent zero returns the pair (0,0) normally. The next bind reads the concrete INFINITE_POWER field. The assumed complete normal return forces this bind to return normally: outer failure or divergence propagates through a Result bind and cannot become ok. For whatever signed word this field returns, the next two zero_pow2 calls return pairs normally. The following test is w=0, which is true for the given input, so the function returns its first pair (0,0). Injectivity of Result.ok identifies this pair with fp. Neither exponent thresholds nor products, shifts, tables, or later arithmetic are reached.

Lean proof


  change num.imp.dec2flt.lemire.compute_float
    F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst
    q 0#u64 = ok fp at hresult
  unfold num.imp.dec2flt.lemire.compute_float at hresult
  simp only [num.imp.dec2flt.common.BiasedFp.zero_pow2, bind_tc_ok,
    if_true] at hresult
  change (do
    let _ ← F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst.INFINITE_POWER
    ok { m := 0#u64, p_biased := 0#i32 }) = ok fp at hresult
  have bind_ok_inv : ∀ {α β : Type} (r : Result α) (g : α → Result β) y,
      Bind.bind r g = ok y → ∃ z, r = ok z ∧ g z = ok y := by
    intro α β r g y hr
    cases r with
    | fail err => simp [Bind.bind, Aeneas.Std.bind] at hr
    | div => simp [Bind.bind, Aeneas.Std.bind] at hr
    | ok z => exact ⟨z, rfl, hr⟩
  obtain ⟨power, hpower, hresult⟩ := bind_ok_inv _ _ _ hresult
  exact (Result.ok.inj hresult).symm

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.P9_T1_ActualDispatchOperations
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P401_T1_ComputeZeroPair]
theorem P401_T1_ComputeZeroPair (q : Std.I64)
    (fp : num.imp.dec2flt.common.BiasedFp)
    (hresult : P9_T1_ActualDispatchOperations.integer q 0#u64 = ok fp) :
    fp = { m := 0#u64, p_biased := 0#i32 } := by
-- BODY
  change num.imp.dec2flt.lemire.compute_float
    F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst
    q 0#u64 = ok fp at hresult
  unfold num.imp.dec2flt.lemire.compute_float at hresult
  simp only [num.imp.dec2flt.common.BiasedFp.zero_pow2, bind_tc_ok,
    if_true] at hresult
  change (do
    let _ ← F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.traitsFloatExtInst.FloatInst.INFINITE_POWER
    ok { m := 0#u64, p_biased := 0#i32 }) = ok fp at hresult
  have bind_ok_inv : ∀ {α β : Type} (r : Result α) (g : α → Result β) y,
      Bind.bind r g = ok y → ∃ z, r = ok z ∧ g z = ok y := by
    intro α β r g y hr
    cases r with
    | fail err => simp [Bind.bind, Aeneas.Std.bind] at hr
    | div => simp [Bind.bind, Aeneas.Std.bind] at hr
    | ok z => exact ⟨z, rfl, hr⟩
  obtain ⟨power, hpower, hresult⟩ := bind_ok_inv _ _ _ hresult
  exact (Result.ok.inj hresult).symm

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (198)
More program dependencies (156)
Standard-library dependencies (39)

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
All 140 entries
Technical checking records
Local closure summary
{
  "node": "P401_T1_ComputeZeroPair",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "d98850d2c6adc6bdc12b4d06279a679b0a9b458fa66be30395ccb69482ce201e",
  "active_statement_hash": "497f121c17345d28d7be0a09ab2f04153f1873bc412997df5e79b77d92617d62",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-181",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "num_imp_dec2flt_common_BiasedFp_zero_pow2": "0f3e5cc6a65d812e",
    "num_imp_dec2flt_lemire_compute_float": "afb759d38fe55586",
    "num_imp_traits_Float_EXP_BIAS_default": "39417be39e20ce5d",
    "num_imp_traits_Float_EXP_BITS_default": "9ab622d85ef04d94",
    "num_imp_traits_Float_EXP_MIN_default": "39417be39e20ce5d",
    "num_imp_traits_Float_EXP_SAT_default": "9ab622d85ef04d94",
    "num_imp_traits_Float_SIG_BITS_default": "9ab622d85ef04d94"
  },
  "strict_definition_deps": {
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS": "d9fd91641cb78c5e",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN": "e23324c94fa5d1b5",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN": "3dbd3f15a918cb2c",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN": "e508b987ade7bf71",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS": "887b52d84a3fc9c4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN": "0c461c0c4f5aa880",
    "P9_T1_ActualDispatchOperations": "d8bf51ebbbf153ac",
    "P9_T1_DispatchOperations": "c21271de368c461b",
    "num_imp_dec2flt_Lemire": "1923f90c53d323e6",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "num_imp_dec2flt_common_BiasedFp_zero_pow2": "0f99ae12c6707137",
    "num_imp_dec2flt_lemire_compute_float": "39d89e3f0a8a9d4c",
    "num_imp_dec2flt_lemire_compute_product_approx": "af91b9cbef7779f3",
    "num_imp_dec2flt_lemire_power": "56b7c3bd69ca3c6a",
    "num_imp_traits_Float": "02acccb9db3e30f2",
    "num_imp_traits_FloatExt": "f996e5400649797d"
  }
}
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:ee4c3efd1dd49812c2e64a3c4089de97d227e6f0e61b6e822be7dabd96b63d74",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}