ExponentValueAgreement

Lean checked

Statement

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

Theorem

For every valid numeric literal whose source-accumulated explicit exponent equals its unbounded mathematical explicit exponent, the exact value and accumulated-exponent value have exactly the same binary64 magnitude rounding targets.

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
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ExponentValueAgreement]
theorem ExponentValueAgreement :
    ∀ x : DecimalLexeme, DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.accumulatedExplicitExponent x = DecimalGoalVocabularyDefault.mathExplicitExponent x ->
      ∀ target : F64,
        DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.exactMagnitude x) target ↔
        DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.accumulatedMagnitude x) target := 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.

Earlier prose review

An earlier review questioned the prose argument. Lean subsequently checked the formal proof. Review of the statement’s intended meaning is a separate judgment.

Proof

Fix a numeric lexeme x satisfying the stated hypotheses and fix a binary64 target t. By DecimalGoalVocabularyDefault, both exactMagnitude and accumulatedMagnitude apply the same magnitudeWithExponent expression to x. In particular, they use the identical list of all significand digits and the identical count of fractional digits. Their only difference is the explicit-exponent argument: exactMagnitude uses mathExplicitExponent, whereas accumulatedMagnitude uses accumulatedExplicitExponent. The assumed equality of those two explicit exponents may therefore be substituted into that common expression, giving
\texttt{exactMagnitude}(x) = \texttt{accumulatedMagnitude}(x).
The two propositions in the desired equivalence apply the same roundsMagnitude predicate to these equal real magnitudes and to the same target t. Thus, from a proof that t rounds the exact magnitude, substitution by the displayed equality gives a proof that t rounds the accumulated magnitude. Substitution by the equality in the opposite direction gives the converse implication. Since t was arbitrary, the equivalence holds for every target. The validNumeric hypothesis is not needed: the conclusion is this purely algebraic consequence of equality of the two explicit exponents.

Lean proof


  intro x _ h target
  have h' := h
  simp only [DecimalGoalVocabularyDefault] at h'
  have hMagnitude :
      DecimalGoalVocabularyDefault.exactMagnitude x =
        DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
    simp only [DecimalGoalVocabularyDefault]
    rw [h']
  rw [hMagnitude]

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ExponentValueAgreement]
theorem ExponentValueAgreement :
    ∀ x : DecimalLexeme, DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.accumulatedExplicitExponent x = DecimalGoalVocabularyDefault.mathExplicitExponent x ->
      ∀ target : F64,
        DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.exactMagnitude x) target ↔
        DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.accumulatedMagnitude x) target := by
-- BODY
  intro x _ h target
  have h' := h
  simp only [DecimalGoalVocabularyDefault] at h'
  have hMagnitude :
      DecimalGoalVocabularyDefault.exactMagnitude x =
        DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
    simp only [DecimalGoalVocabularyDefault]
    rw [h']
  rw [hMagnitude]

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (201)
More program dependencies (159)
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 7 entries
Technical checking records
Local closure summary
{
  "node": "ExponentValueAgreement",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "003a8484d90a3bb5c45f79a25db8daec8d29477e77d4b9a68736629279ae3c0a",
  "active_statement_hash": "97c291b7689ad47b2d9cd43ad01065ca8c95a5d357408d9e89fc8e0b8026a76f",
  "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-88",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "DecimalGoalVocabularyDefault": "94cb4c406f8efb78"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "c08dd4b4aea4abb4",
    "DecimalGoalVocabularyDefault": "b9386c8d0fd53e6e",
    "DecimalLexeme": "8127b3eaeae00dd2",
    "F64": "ec4e25fbaf4e11d4",
    "num_imp_dec2flt_common_BiasedFp": "31d81cf1cf22709f",
    "num_imp_dec2flt_decimal_Decimal": "4c41a56bf44cb31e"
  }
}
Prose assessment
{
  "label": "Sound flag superseded by recorded Lean closure",
  "assessment_status": "ReviewerPinnedFail",
  "fingerprint_relation": "differs from current fingerprint",
  "assessment_fingerprint": "sound-v2:19e0dc84c00aedf01af2bc40fae3f261ff7a6fbae040818cdd116f6f39b22f8c",
  "current_fingerprint": "sound-v2:cbcb29b4ceed2270cd1530b648a800fe911f883d8777e91d4a0fa6e68a6b8a09",
  "superseded_for_theorem_closure": true
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Fail",
  "substantiveness_status": "Pass"
}