ParserNumericSlowPropagationCertificate

Lean checked

Statement

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

Helper · Slow-parser overflow propagation

For any byte slice body, if the extracted decimal-sequence parser fails on body with integerOverflow, then the extracted binary64 long-mantissa parser fails on the same slice with integerOverflow.

Lean statement

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

import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 262144

namespace dec2flt_model

-- [TABLET NODE: ParserNumericSlowPropagationCertificate]
theorem ParserNumericSlowPropagationCertificate (body : Slice Std.U8)
    (hdecimal : num.imp.dec2flt.decimal_seq.parse_decimal_seq body =
      fail integerOverflow) :
    num.imp.dec2flt.slow.parse_long_mantissa
        F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.FloatInst body =
      fail integerOverflow := 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

The binary64 model supplied by F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG TOTAL BITS and ModelF64MantissaDigits has 53 total significand bits and 64 carrier bits. Substitution into the checked exponent-width operations of num imp traits Float INFINITE POWER default gives infinite power 2047: the successive unsigned values are 52, 12, 11, 2048, and 2047, all within 32-bit bounds, and casting 2047 to signed 32-bit is in bounds. The two calls to num imp dec2flt common BiasedFp zero pow2 at powers 0 and 2047 therefore return the zero biased pairs with those respective powers.
Now unfold num imp dec2flt slow parse long mantissa. Its initial zero-pair computation succeeds, its infinite-power computation succeeds with 2047, and its corresponding infinity pair computation succeeds. The next monadic operation is exactly the call to the decimal-sequence parser from num imp dec2flt decimal seq parse decimal seq. By the hypothesis that call is fail integerOverflow; the result bind consequently executes no later comparison, rounding, or float-construction branch and propagates the identical failure. This is the asserted result.

Lean proof


  have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
      ok 53#u32 := by
    simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
      core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
      Binary64ModelDefault]
  have hinf :
      F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.FloatInst.INFINITE_POWER =
        ok 2047#i32 := by
    simp [num.imp.traits.Float.EXP_SAT.default.eq_def,
      F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
    have h : (do
        let x ← 53#u32 - 1#u32
        let x ← 64#u32 - x
        let x ← x - 1#u32
        let x ← 1#u32 <<< x
        let i ← x - 1#u32
        ok (UScalar.hcast .I32 i))
        ⦃ x => x = 2047#i32 ⦄ := by
      step
      step
      step
      step
      step
      apply IScalar.eq_of_val_eq
      have hi : i.val = 2047 := by scalar_tac
      have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
      rw [hi] at hs
      simpa [Aeneas.Std.lift, WP.spec_ok] using hs
    obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
    simpa [hxt] using hx
  have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
      ok { m := 0#u64, p_biased := 0#i32 } := by rfl
  have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
      ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
  let infPower :=
    F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.FloatInst.INFINITE_POWER
  have hinf' : infPower = ok 2047#i32 := hinf
  unfold num.imp.dec2flt.slow.parse_long_mantissa
  rw [hzero]
  simp only [bind_tc_ok]
  change (do let i ← infPower; _) = _
  rw [hinf']
  simp only [bind_tc_ok]
  rw [hinfFp]
  simp only [bind_tc_ok]
  rw [hdecimal]
  rfl

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_traits_Float_EXP_BITS_default
import Tablet.num_imp_traits_Float_EXP_SAT_default
import Tablet.num_imp_traits_Float_INFINITE_POWER_default
import Tablet.num_imp_traits_Float_SIG_BITS_default

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 262144

namespace dec2flt_model

-- [TABLET NODE: ParserNumericSlowPropagationCertificate]
theorem ParserNumericSlowPropagationCertificate (body : Slice Std.U8)
    (hdecimal : num.imp.dec2flt.decimal_seq.parse_decimal_seq body =
      fail integerOverflow) :
    num.imp.dec2flt.slow.parse_long_mantissa
        F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.FloatInst body =
      fail integerOverflow := by
-- BODY
  have hsig53 : F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS =
      ok 53#u32 := by
    simp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def,
      core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
      Binary64ModelDefault]
  have hinf :
      F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.FloatInst.INFINITE_POWER =
        ok 2047#i32 := by
    simp [num.imp.traits.Float.EXP_SAT.default.eq_def,
      F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def, hsig53]
    have h : (do
        let x ← 53#u32 - 1#u32
        let x ← 64#u32 - x
        let x ← x - 1#u32
        let x ← 1#u32 <<< x
        let i ← x - 1#u32
        ok (UScalar.hcast .I32 i))
        ⦃ x => x = 2047#i32 ⦄ := by
      step
      step
      step
      step
      step
      apply IScalar.eq_of_val_eq
      have hi : i.val = 2047 := by scalar_tac
      have hs := UScalar.hcast_inBounds_spec .I32 i (by scalar_tac)
      rw [hi] at hs
      simpa [Aeneas.Std.lift, WP.spec_ok] using hs
    obtain ⟨x, hx, hxt⟩ := Aeneas.Std.WP.spec_imp_exists h
    simpa [hxt] using hx
  have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
      ok { m := 0#u64, p_biased := 0#i32 } := by rfl
  have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
      ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
  let infPower :=
    F64.Insts.Dec2flt_modelNumImpTraitsFloatExtU64.FloatInst.INFINITE_POWER
  have hinf' : infPower = ok 2047#i32 := hinf
  unfold num.imp.dec2flt.slow.parse_long_mantissa
  rw [hzero]
  simp only [bind_tc_ok]
  change (do let i ← infPower; _) = _
  rw [hinf']
  simp only [bind_tc_ok]
  rw [hinfFp]
  simp only [bind_tc_ok]
  rw [hdecimal]
  rfl

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (154)
More program dependencies (112)
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 105 entries
Technical checking records
Local closure summary
{
  "node": "ParserNumericSlowPropagationCertificate",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "d409d35fa77bde3ce78ce7242fd0e3b99771933c5d2b64db2d56d41d4365587a",
  "active_statement_hash": "7478de45f91da38e733ee5cae17ac0a61f7bf50fc5603b7a655f04f9ddb5e2d0",
  "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-126",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "Binary64ModelDefault": "c722a2c00805b545",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS": "cfedcf26d6dae341",
    "num_imp_dec2flt_slow_parse_long_mantissa": "0eb6fb2627d0ff5c",
    "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": {
    "Binary64Model": "c43614ff2149ecf2",
    "Binary64ModelDefault": "dc548d1e27696ba4",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64": "60afe26c6a80cf0f",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS": "d9fd91641cb78c5e",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS": "887b52d84a3fc9c4",
    "ModelF64MantissaDigits": "9ceb415358831f73",
    "Preamble": "1f712bede6a5dae6",
    "core_num_FpCategory": "c43614ff2149ecf2",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "num_imp_dec2flt_common_BiasedFp_zero_pow2": "0f99ae12c6707137",
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "b0286c42454b158d",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "fd298e37d5ae4f86",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "1aaf1bb11c0b6a49",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_round": "8ea3c058fea09978",
    "num_imp_dec2flt_decimal_seq_parse_decimal_seq": "244cf8318357caab",
    "num_imp_dec2flt_slow_parse_long_mantissa": "f4b1825aa46c08b9",
    "num_imp_traits_Float": "e6fdcaf2f38244d3",
    "num_imp_traits_FloatExt": "f996e5400649797d",
    "num_imp_traits_Float_EXP_SAT_default": "18173bfd92d636d4"
  }
}
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:0903013492f2e2879a5f04058a4ede0febe444432139162f6a7e6f211807bab8",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}