ParserReachableSlowMagnitudeRounding

Lean checked

Statement

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

Lemma

Let s be source-valid and render a valid numeric lexeme x. Suppose a successful dec2flt_with_trace result is an assembled trace t and t.\mathit{slow\_path\_guard} is true. Then the trace's assembly_result is a binary64 magnitude-rounding target of the accumulated-exponent value of x.

Lean statement

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

import Tablet.Assumptions
import Tablet.SourceValidByteSlice
import Tablet.ParserNumericTraceShape
import Tablet.NumberHelperAccumulatedValue
import Tablet.AssemblyCorrespondence
import Tablet.ParserExponentConstants
import Tablet.DecimalLeftShiftTableCertificate
import Tablet.ModelU64BitAnd
import Tablet.ModelU64BitOr
import Tablet.ModelU64Shl
import Tablet.ModelU64Shr
import Tablet.U64_Insts_CoreOpsBitBitAndU64U64
import Tablet.U64_Insts_CoreOpsBitBitOrU64U64
import Tablet.U64_Insts_CoreOpsBitShlU32U64
import Tablet.U64_Insts_CoreOpsBitShrU32U64
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_parse_MIN_19DIGIT_INT
import Tablet.num_imp_dec2flt_parse_adjust_many_digit_count
import Tablet.num_imp_dec2flt_parse_parse_many_digits
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_partial_number
import Tablet.num_imp_dec2flt_parse_parse_scientific
import Tablet.num_imp_dec2flt_parse_try_parse_19digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_round
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_trim
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit
import Tablet.num_imp_dec2flt_decimal_seq_count_trailing_zeros
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_exponent
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
import Tablet.num_imp_dec2flt_decimal_seq_parse_digits_into_seq
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN
import Tablet.ParserSlowReachableDecimalSeq
import Tablet.ParserSlowNormalizationCertificate
import Tablet.Binary64NearestEvenAssembly

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserReachableSlowMagnitudeRounding]
theorem ParserReachableSlowMagnitudeRounding :
    ∀ (s : Str) (x : DecimalLexeme) (f : F64)
      (tr : num.imp.dec2flt.Dec2FltAssemblyTrace F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.bytes s =
        DecimalGoalVocabularyDefault.renderNumeric x ->
      num.imp.dec2flt.dec2flt_with_trace
        F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
        F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
        F64.Insts.CoreOpsArithNegF64 s =
          ok (core.result.Result.Ok f,
            num.imp.dec2flt.Dec2FltTrace.Assembled tr) ->
      tr.slow_path_guard = true ->
      DecimalGoalVocabularyDefault.roundsMagnitude
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x)
        tr.assembly_result := 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

Apply ParserSlowReachableDecimalSeq to the five displayed hypotheses. It supplies a parsed decimal sequence, the successful slow call, and, crucially for this wrapper, the equation
\operatorname{assembledWord} (t.\mathit{selected\_pair},t.\mathit{assembly\_result}).
The same hypotheses satisfy ParserSlowNormalizationCertificate, which gives nonnegativity of A=\operatorname{accumulatedMagnitude}(x) and one of its exhaustive overflow, lowest-grid, or normal-binade nearest-even certificates for the raw word of t.\mathit{selected\_pair}. Invoke Binary64NearestEvenAssembly with that certificate and the assembled word equation. Its conclusion is exactly roundsMagnitude(A,t.assembly\_result), as required.

Lean proof


  intro s x f tr hsource hvalid hrender htrace hguard
  obtain ⟨d, hparse, hslow, hassembled, hdcount, hdigit, hinitial⟩ :=
    ParserSlowReachableDecimalSeq s x f tr hsource hvalid hrender htrace hguard
  exact Binary64NearestEvenAssembly
    (DecimalGoalVocabularyDefault.accumulatedMagnitude x)
    tr.selected_pair tr.assembly_result
    (ParserSlowNormalizationCertificate s x f tr hsource hvalid hrender
      htrace hguard)
    hassembled

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.Assumptions
import Tablet.SourceValidByteSlice
import Tablet.ParserNumericTraceShape
import Tablet.NumberHelperAccumulatedValue
import Tablet.AssemblyCorrespondence
import Tablet.ParserExponentConstants
import Tablet.DecimalLeftShiftTableCertificate
import Tablet.ModelU64BitAnd
import Tablet.ModelU64BitOr
import Tablet.ModelU64Shl
import Tablet.ModelU64Shr
import Tablet.U64_Insts_CoreOpsBitBitAndU64U64
import Tablet.U64_Insts_CoreOpsBitBitOrU64U64
import Tablet.U64_Insts_CoreOpsBitShlU32U64
import Tablet.U64_Insts_CoreOpsBitShrU32U64
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_parse_MIN_19DIGIT_INT
import Tablet.num_imp_dec2flt_parse_adjust_many_digit_count
import Tablet.num_imp_dec2flt_parse_parse_many_digits
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_partial_number
import Tablet.num_imp_dec2flt_parse_parse_scientific
import Tablet.num_imp_dec2flt_parse_try_parse_19digits
import Tablet.num_imp_dec2flt_parse_try_parse_digits
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_round
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_trim
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit
import Tablet.num_imp_dec2flt_decimal_seq_count_trailing_zeros
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_exponent
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
import Tablet.num_imp_dec2flt_decimal_seq_parse_digits_into_seq
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64
import Tablet.SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64
import Tablet.num_imp_dec2flt_common_is_8digits
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN
import Tablet.ParserSlowReachableDecimalSeq
import Tablet.ParserSlowNormalizationCertificate
import Tablet.Binary64NearestEvenAssembly

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserReachableSlowMagnitudeRounding]
theorem ParserReachableSlowMagnitudeRounding :
    ∀ (s : Str) (x : DecimalLexeme) (f : F64)
      (tr : num.imp.dec2flt.Dec2FltAssemblyTrace F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.bytes s =
        DecimalGoalVocabularyDefault.renderNumeric x ->
      num.imp.dec2flt.dec2flt_with_trace
        F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
        F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
        F64.Insts.CoreOpsArithNegF64 s =
          ok (core.result.Result.Ok f,
            num.imp.dec2flt.Dec2FltTrace.Assembled tr) ->
      tr.slow_path_guard = true ->
      DecimalGoalVocabularyDefault.roundsMagnitude
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x)
        tr.assembly_result := by
-- BODY
  intro s x f tr hsource hvalid hrender htrace hguard
  obtain ⟨d, hparse, hslow, hassembled, hdcount, hdigit, hinitial⟩ :=
    ParserSlowReachableDecimalSeq s x f tr hsource hvalid hrender htrace hguard
  exact Binary64NearestEvenAssembly
    (DecimalGoalVocabularyDefault.accumulatedMagnitude x)
    tr.selected_pair tr.assembly_result
    (ParserSlowNormalizationCertificate s x f tr hsource hvalid hrender
      htrace hguard)
    hassembled

end dec2flt_model

Proof structure

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

Uses

All 56 entries

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 292 entries
Technical checking records
Local closure summary
{
  "node": "ParserReachableSlowMagnitudeRounding",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "6e8a73680eb956dfcc5fb6e8c12c9c012736da30c163bc58f834ad4c79ab1eb4",
  "active_statement_hash": "c647179cd8a889824ae57e2d11f7e2286e844627204cc2e2381b6720d6efd6cf",
  "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-204",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "Binary64NearestEvenAssembly": "028531442bb8a66c",
    "ParserSlowNormalizationCertificate": "b328ec2ad469b68e",
    "ParserSlowReachableDecimalSeq": "3594e3f7b19754da"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "65227461bf3cac06",
    "DecimalGoalVocabularyDefault": "512f8d0aea894250",
    "DecimalLexeme": "c43614ff2149ecf2",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
    "F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
    "F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "num_float_parse_ParseFloatError": "c43614ff2149ecf2",
    "num_imp_dec2flt_Dec2FltAssemblyTrace": "2a4d2e4074960bd4",
    "num_imp_dec2flt_Dec2FltTrace": "8fa376ebb5c489ee",
    "num_imp_dec2flt_common_BiasedFp": "c43614ff2149ecf2",
    "num_imp_dec2flt_dec2flt_with_trace": "ebe6a57c6dce0df6",
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "c43614ff2149ecf2",
    "num_imp_dec2flt_decimal_seq_parse_decimal_seq": "244cf8318357caab",
    "num_imp_dec2flt_slow_parse_long_mantissa": "cd8af64c3688b60f"
  }
}
Prose assessment
{
  "label": "Sound flag superseded by recorded Lean closure",
  "assessment_status": "ReviewerPinnedFail",
  "fingerprint_relation": "differs from current fingerprint",
  "assessment_fingerprint": "sound-v2:a8a0b67342f028bd98beb4dcc301450602124ea29339ce2e6d3d72267ce996e3",
  "current_fingerprint": "sound-v2:b931ecb9afc6d68825f856fb6f509f25d19bea4f9c9b246619b2891ee166aa53",
  "superseded_for_theorem_closure": true
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Fail",
  "substantiveness_status": "Pass"
}