P401_T1_ZeroRounding

Lean checked

Statement

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

Lemma · Zero is a magnitude rounding target

The unsigned binary64 word of raw value zero satisfies DecimalGoalVocabularyDefault's roundsMagnitude relation for the real number zero.

Lean statement

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

import Tablet.DecimalGoalVocabularyDefault

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P401_T1_ZeroRounding]
theorem P401_T1_ZeroRounding :
    DecimalGoalVocabularyDefault.roundsMagnitude 0
      (⟨BitVec.ofNat 64 0⟩ : F64) := 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 DecimalGoalVocabularyDefault. Zero is nonnegative and its raw word is at most I=2047\,2^{52} and different from I. The overflow threshold T=2^{1024}-2^{970} is positive because powers of 2 strictly increase with their natural exponent. The zero word has exponent quotient and fraction remainder both zero, so its finite value is 0/2^{1074}=0. For any finite competing word, its absolute distance from zero is nonnegative; therefore the distance zero of the proposed word is no greater. In a distance tie the proposed word has even raw value, since 0\bmod2=0. These are every clause of the finite-target branch of the rounding predicate.

Lean proof


  have hthreshold : (0 : Real) < (2 : Real) ^ (1024 : Nat) -
      (2 : Real) ^ (970 : Nat) := by
    exact sub_pos.mpr (pow_lt_pow_right₀ (by norm_num) (by norm_num))
  dsimp [DecimalGoalVocabularyDefault]
  refine ⟨le_refl 0, Nat.zero_le _, ?_⟩
  change if (0 : Nat) = 2047 * 2 ^ 52 then _ else _
  rw [if_neg (by norm_num)]
  refine ⟨hthreshold, ?_⟩
  intro v hv hne
  change abs ((0 : Real) - ((0 : Nat) : Real) / (2 : Real) ^ (1074 : Nat)) ≤ _ ∧
    (abs ((0 : Real) - ((0 : Nat) : Real) / (2 : Real) ^ (1074 : Nat)) = _ →
      (0 : Nat) % 2 = 0)
  simp only [Nat.cast_zero, zero_div, sub_zero, abs_zero]
  exact ⟨abs_nonneg _, fun _ => True.intro⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P401_T1_ZeroRounding]
theorem P401_T1_ZeroRounding :
    DecimalGoalVocabularyDefault.roundsMagnitude 0
      (⟨BitVec.ofNat 64 0⟩ : F64) := by
-- BODY
  have hthreshold : (0 : Real) < (2 : Real) ^ (1024 : Nat) -
      (2 : Real) ^ (970 : Nat) := by
    exact sub_pos.mpr (pow_lt_pow_right₀ (by norm_num) (by norm_num))
  dsimp [DecimalGoalVocabularyDefault]
  refine ⟨le_refl 0, Nat.zero_le _, ?_⟩
  change if (0 : Nat) = 2047 * 2 ^ 52 then _ else _
  rw [if_neg (by norm_num)]
  refine ⟨hthreshold, ?_⟩
  intro v hv hne
  change abs ((0 : Real) - ((0 : Nat) : Real) / (2 : Real) ^ (1074 : Nat)) ≤ _ ∧
    (abs ((0 : Real) - ((0 : Nat) : Real) / (2 : Real) ^ (1074 : Nat)) = _ →
      (0 : Nat) % 2 = 0)
  simp only [Nat.cast_zero, zero_div, sub_zero, abs_zero]
  exact ⟨abs_nonneg _, fun _ => True.intro⟩

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
All 7 entries
Technical checking records
Local closure summary
{
  "node": "P401_T1_ZeroRounding",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "901f0476daeac0138b014848666987073aab2a130b35ea3c07ec6b7f3191cc10",
  "active_statement_hash": "7ca0e907545dfd5e07a4fdd3c85b66376e2ae630a96f193a1416b1c64c2bdb0c",
  "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-85",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "DecimalGoalVocabularyDefault": "2bbf2be48b5a4a4b"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "f76c8174a4d58eb5",
    "DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
    "F64": "ec4e25fbaf4e11d4"
  }
}
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:449d567e6c5b11e9cfa4831e1f18e142f7d4a139aa0a5d1ba4b0cb62564d6140",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}