ParserComputeFloatExponentRange

Lean checked

Statement

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

Helper

For every signed decimal exponent q, unsigned significand w, and biased pair b, if the extracted binary64 call compute_float(q,w) returns b normally, then b's signed biased-exponent field is either -1 or lies in the inclusive interval [0,2047].

Lean statement

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

import Tablet.ParserExponentConstants
import Tablet.num_imp_dec2flt_lemire_compute_float

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option pp.universes false

namespace dec2flt_model

-- [TABLET NODE: ParserComputeFloatExponentRange]
theorem ParserComputeFloatExponentRange (q : Std.I64) (w : Std.U64)
    (b : num.imp.dec2flt.common.BiasedFp)
    (h : num.imp.dec2flt.lemire.compute_float
      F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 q w = ok b) :
    b.p_biased.val = -1 ∨
      (0 ≤ b.p_biased.val ∧ b.p_biased.val ≤ 2047) := 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

Use the binary64 evaluations in ParserExponentConstants. In particular, the decimal cutoffs are -342 and 308, the significand width is 52, and the saturated exponent is 2047. Unfold num imp dec2flt lemire compute float. Its three eager zero-pair constructions give exponents 0, 2047, and -1. Thus the zero-significand return and the two decimal-cutoff returns are in [0,2047], while either approximation-defer return has exponent -1.
On every remaining normally returning path, normalization, the precision calculation, the product approximation, and each subsequent arithmetic operation returned normally: a failure or divergence at any monadic predecessor cannot yield the assumed ok result. Peel those predecessors in result-monad order. After the product, the extracted definition contains two copies of the same exponent block: one when the low limb is maximal and -27\le q\le55, and one when the low limb is not maximal. The proof performs the following case analysis separately in both copies, so it does not identify the copies propositionally.
Let power2 be the successful signed result immediately before its comparison with zero. If power2\le0, the next negation and addition must succeed. When the resulting shift count is at least 64, the function returns the zero sentinel, whose exponent is 0. Otherwise the mantissa shifts, increment, and 1\mathbin{\mathtt{<<}}52 must all succeed, and the returned exponent is IScalar.cast_fromBool of the final mantissa comparison. That cast has integer value 0 or 1, hence lies in [0,2047].
If power2>0, all conditional round-to-even work changes only the mantissa. Peel its successful result, the low-bit increment, the shift by one, and the successful threshold computation 2\mathbin{\mathtt{<<}}52. In the no-carry case the candidate exponent is power2, so it is positive. In the carry case the extracted checked addition returns the candidate exponent \texttt{power2}+1, which is also positive. The final guard is applied to that exact candidate. If it is at least 2047, the returned infinity sentinel has exponent 2047. Otherwise the constructed record retains the candidate itself, and the failed guard gives an upper bound below 2047. Thus every ordinary return has exponent in [0,2047]. Together with the zero, infinity, and defer sentinels, these cases exhaust every successful return of both duplicated blocks and establish the claim.

Lean proof


  have bind_ok_inv : ∀ {α β : Type} (r : Result α) (f : α → Result β) y,
      Bind.bind r f = ok y → ∃ x, r = ok x ∧ f x = ok y := by
    intro α β r f y hr
    cases r <;> simp_all [Bind.bind, Aeneas.Std.bind]
  rcases ParserExponentConstants with
    ⟨hbits, htotal, hsig, hexpbits, hexpsat, hinf, hbias, hmin,
      hsmall, hlarge, hroundmin, hroundmax⟩
  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
  have herr : num.imp.dec2flt.common.BiasedFp.zero_pow2 (-1)#i32 =
      ok { m := 0#u64, p_biased := (-1)#i32 } := by rfl
  have hcastSmall : lift (IScalar.cast .I64 (-342)#i32) =
      ok (-342)#i64 := by rfl
  have hcastLarge : lift (IScalar.cast .I64 308#i32) =
      ok 308#i64 := by rfl
  have hsigop : (53#u32 - 1#u32) = ok 52#u32 := by rfl
  unfold num.imp.dec2flt.lemire.compute_float at h
  rw [hzero, hinf] at h
  simp only [bind_tc_ok] at h
  rw [hinfFp, herr] at h
  simp only [bind_tc_ok] at h
  by_cases hw : w = 0#u64
  · simp only [hw, if_true] at h
    cases h
    right
    norm_num
  simp only [hw, if_false] at h
  rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SMALLEST_POWER_OF_TEN.eq_def] at h
  rw [hcastSmall] at h
  simp only [bind_tc_ok] at h
  by_cases hqsmall : q < (-342)#i64
  · simp only [hqsmall, if_true] at h
    cases h
    right
    norm_num
  simp only [hqsmall, if_false] at h
  rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.LARGEST_POWER_OF_TEN.eq_def] at h
  rw [hcastLarge] at h
  simp only [bind_tc_ok] at h
  by_cases hqlarge : q > 308#i64
  · simp only [hqlarge, if_true] at h
    cases h
    right
    norm_num
  simp only [hqlarge, if_false] at h
  simp only [lift, bind_tc_ok] at h
  cases hwshift : (w <<< core.num.U64.leading_zeros w) with
  | fail e => simp only [hwshift, bind_tc_fail] at h; contradiction
  | div => simp only [hwshift, bind_tc_div] at h; contradiction
  | ok w1 =>
    simp only [hwshift, bind_tc_ok] at h
    rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] at h
    simp only [core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
      Binary64ModelDefault] at h
    rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def] at h
    simp only [bind_tc_ok] at h
    rw [hsigop] at h
    simp only [bind_tc_ok] at h
    obtain ⟨i7, hi7, h⟩ := bind_ok_inv _ _ _ h
    obtain ⟨pair, hpair, h⟩ := bind_ok_inv _ _ _ h
    rcases pair with ⟨lo, hi⟩
    simp only [Aeneas.Std.uncurry_apply_pair] at h
    by_cases hlo : lo = 18446744073709551615#u64
    · simp only [hlo, if_true] at h
      by_cases hqneg : q ≥ (-27)#i64
      · simp only [hqneg, if_true, bind_tc_ok] at h
        by_cases hq55 : q ≤ 55#i64
        · have hbtrue : decide (q ≤ 55#i64) = true := by simpa using hq55
          simp only [hbtrue, if_true, bind_tc_ok] at h
          obtain ⟨i8, hi8, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i9, hi9, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i11, hi11, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i12, hi12, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa, hmantissa, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i14, hi14, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i15, hi15, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i17, hi17, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i18, hi18, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i19, hi19, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨power2, hpower2, h⟩ := bind_ok_inv _ _ _ h
          by_cases hp2 : power2 ≤ 0#i32
          · simp only [hp2, if_true] at h
            obtain ⟨i20, hi20, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
            by_cases hz : i21 ≥ 64#i32
            · simp only [hz, if_true] at h
              cases h
              right
              norm_num
            · simp only [hz, if_false] at h
              obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨i24, hi24, h⟩ := bind_ok_inv _ _ _ h
              cases h
              right
              have hc := IScalar.cast_fromBool_bound_eq .I32
                (decide (mantissa3 ≥ i24))
              exact ⟨hc.1, hc.2.trans (by norm_num)⟩
          · simp only [hp2, if_false] at h
            obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
            by_cases hcarry : mantissa3 ≥ i21
            · simp only [hcarry, if_true] at h
              obtain ⟨pair2, hpair2, h⟩ := bind_ok_inv _ _ _ h
              rcases pair2 with ⟨mantissa4, power21⟩
              obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa5, hm5, hpair2⟩ :=
                bind_ok_inv _ _ _ hpair2
              obtain ⟨power22, hp22, hpair2⟩ :=
                bind_ok_inv _ _ _ hpair2
              cases hpair2
              by_cases hsat : power21 ≥ 2047#i32
              · simp only [hsat, if_true] at h
                cases h
                right
                norm_num
              · simp only [hsat, if_false] at h
                cases h
                right
                change 0 ≤ power21.val ∧ power21.val ≤ 2047
                have hp22v : power21.val = power2.val + 1 := by
                  have he := IScalar.add_equiv power2 (1#i32)
                  rw [hp22] at he
                  exact he.2.1
                change ¬ power2.val ≤ 0 at hp2
                change ¬ 2047 ≤ power21.val at hsat
                constructor <;> omega
            · simp only [hcarry, if_false, bind_tc_ok,
                Aeneas.Std.uncurry_apply_pair] at h
              obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
              by_cases hsat : power2 ≥ 2047#i32
              · simp only [hsat, if_true] at h
                cases h
                right
                norm_num
              · simp only [hsat, if_false] at h
                cases h
                right
                change 0 ≤ power2.val ∧ power2.val ≤ 2047
                change ¬ power2.val ≤ 0 at hp2
                change ¬ 2047 ≤ power2.val at hsat
                constructor <;> omega
        · have hbfalse : decide (q ≤ 55#i64) = false := by simpa using hq55
          simp only [hbfalse, if_false, bind_tc_ok] at h
          cases h
          left
          norm_num
      · simp only [hqneg, if_false, bind_tc_ok] at h
        cases h
        left
        norm_num
    · simp only [hlo, if_false] at h
      obtain ⟨i8, hi8, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i9, hi9, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i11, hi11, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i12, hi12, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨mantissa, hmantissa, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i14, hi14, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i15, hi15, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i17, hi17, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i18, hi18, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i19, hi19, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨power2, hpower2, h⟩ := bind_ok_inv _ _ _ h
      by_cases hp2 : power2 ≤ 0#i32
      · simp only [hp2, if_true] at h
        obtain ⟨i20, hi20, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
        by_cases hz : i21 ≥ 64#i32
        · simp only [hz, if_true] at h
          cases h
          right
          norm_num
        · simp only [hz, if_false] at h
          obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i24, hi24, h⟩ := bind_ok_inv _ _ _ h
          cases h
          right
          have hc := IScalar.cast_fromBool_bound_eq .I32
            (decide (mantissa3 ≥ i24))
          exact ⟨hc.1, hc.2.trans (by norm_num)⟩
      · simp only [hp2, if_false] at h
        obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
        by_cases hcarry : mantissa3 ≥ i21
        · simp only [hcarry, if_true] at h
          obtain ⟨pair2, hpair2, h⟩ := bind_ok_inv _ _ _ h
          rcases pair2 with ⟨mantissa4, power21⟩
          obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa5, hm5, hpair2⟩ :=
            bind_ok_inv _ _ _ hpair2
          obtain ⟨power22, hp22, hpair2⟩ :=
            bind_ok_inv _ _ _ hpair2
          cases hpair2
          by_cases hsat : power21 ≥ 2047#i32
          · simp only [hsat, if_true] at h
            cases h
            right
            norm_num
          · simp only [hsat, if_false] at h
            cases h
            right
            change 0 ≤ power21.val ∧ power21.val ≤ 2047
            have hp22v : power21.val = power2.val + 1 := by
              have he := IScalar.add_equiv power2 (1#i32)
              rw [hp22] at he
              exact he.2.1
            change ¬ power2.val ≤ 0 at hp2
            change ¬ 2047 ≤ power21.val at hsat
            constructor <;> omega
        · simp only [hcarry, if_false, bind_tc_ok,
            Aeneas.Std.uncurry_apply_pair] at h
          obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
          by_cases hsat : power2 ≥ 2047#i32
          · simp only [hsat, if_true] at h
            cases h
            right
            norm_num
          · simp only [hsat, if_false] at h
            cases h
            right
            change 0 ≤ power2.val ∧ power2.val ≤ 2047
            change ¬ power2.val ≤ 0 at hp2
            change ¬ 2047 ≤ power2.val at hsat
            constructor <;> omega

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.ParserExponentConstants
import Tablet.num_imp_dec2flt_lemire_compute_float

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option pp.universes false

namespace dec2flt_model

-- [TABLET NODE: ParserComputeFloatExponentRange]
theorem ParserComputeFloatExponentRange (q : Std.I64) (w : Std.U64)
    (b : num.imp.dec2flt.common.BiasedFp)
    (h : num.imp.dec2flt.lemire.compute_float
      F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 q w = ok b) :
    b.p_biased.val = -1 ∨
      (0 ≤ b.p_biased.val ∧ b.p_biased.val ≤ 2047) := by
-- BODY
  have bind_ok_inv : ∀ {α β : Type} (r : Result α) (f : α → Result β) y,
      Bind.bind r f = ok y → ∃ x, r = ok x ∧ f x = ok y := by
    intro α β r f y hr
    cases r <;> simp_all [Bind.bind, Aeneas.Std.bind]
  rcases ParserExponentConstants with
    ⟨hbits, htotal, hsig, hexpbits, hexpsat, hinf, hbias, hmin,
      hsmall, hlarge, hroundmin, hroundmax⟩
  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
  have herr : num.imp.dec2flt.common.BiasedFp.zero_pow2 (-1)#i32 =
      ok { m := 0#u64, p_biased := (-1)#i32 } := by rfl
  have hcastSmall : lift (IScalar.cast .I64 (-342)#i32) =
      ok (-342)#i64 := by rfl
  have hcastLarge : lift (IScalar.cast .I64 308#i32) =
      ok 308#i64 := by rfl
  have hsigop : (53#u32 - 1#u32) = ok 52#u32 := by rfl
  unfold num.imp.dec2flt.lemire.compute_float at h
  rw [hzero, hinf] at h
  simp only [bind_tc_ok] at h
  rw [hinfFp, herr] at h
  simp only [bind_tc_ok] at h
  by_cases hw : w = 0#u64
  · simp only [hw, if_true] at h
    cases h
    right
    norm_num
  simp only [hw, if_false] at h
  rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SMALLEST_POWER_OF_TEN.eq_def] at h
  rw [hcastSmall] at h
  simp only [bind_tc_ok] at h
  by_cases hqsmall : q < (-342)#i64
  · simp only [hqsmall, if_true] at h
    cases h
    right
    norm_num
  simp only [hqsmall, if_false] at h
  rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.LARGEST_POWER_OF_TEN.eq_def] at h
  rw [hcastLarge] at h
  simp only [bind_tc_ok] at h
  by_cases hqlarge : q > 308#i64
  · simp only [hqlarge, if_true] at h
    cases h
    right
    norm_num
  simp only [hqlarge, if_false] at h
  simp only [lift, bind_tc_ok] at h
  cases hwshift : (w <<< core.num.U64.leading_zeros w) with
  | fail e => simp only [hwshift, bind_tc_fail] at h; contradiction
  | div => simp only [hwshift, bind_tc_div] at h; contradiction
  | ok w1 =>
    simp only [hwshift, bind_tc_ok] at h
    rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] at h
    simp only [core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
      Binary64ModelDefault] at h
    rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def] at h
    simp only [bind_tc_ok] at h
    rw [hsigop] at h
    simp only [bind_tc_ok] at h
    obtain ⟨i7, hi7, h⟩ := bind_ok_inv _ _ _ h
    obtain ⟨pair, hpair, h⟩ := bind_ok_inv _ _ _ h
    rcases pair with ⟨lo, hi⟩
    simp only [Aeneas.Std.uncurry_apply_pair] at h
    by_cases hlo : lo = 18446744073709551615#u64
    · simp only [hlo, if_true] at h
      by_cases hqneg : q ≥ (-27)#i64
      · simp only [hqneg, if_true, bind_tc_ok] at h
        by_cases hq55 : q ≤ 55#i64
        · have hbtrue : decide (q ≤ 55#i64) = true := by simpa using hq55
          simp only [hbtrue, if_true, bind_tc_ok] at h
          obtain ⟨i8, hi8, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i9, hi9, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i11, hi11, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i12, hi12, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa, hmantissa, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i14, hi14, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i15, hi15, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i17, hi17, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i18, hi18, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i19, hi19, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨power2, hpower2, h⟩ := bind_ok_inv _ _ _ h
          by_cases hp2 : power2 ≤ 0#i32
          · simp only [hp2, if_true] at h
            obtain ⟨i20, hi20, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
            by_cases hz : i21 ≥ 64#i32
            · simp only [hz, if_true] at h
              cases h
              right
              norm_num
            · simp only [hz, if_false] at h
              obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨i24, hi24, h⟩ := bind_ok_inv _ _ _ h
              cases h
              right
              have hc := IScalar.cast_fromBool_bound_eq .I32
                (decide (mantissa3 ≥ i24))
              exact ⟨hc.1, hc.2.trans (by norm_num)⟩
          · simp only [hp2, if_false] at h
            obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
            obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
            by_cases hcarry : mantissa3 ≥ i21
            · simp only [hcarry, if_true] at h
              obtain ⟨pair2, hpair2, h⟩ := bind_ok_inv _ _ _ h
              rcases pair2 with ⟨mantissa4, power21⟩
              obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
              obtain ⟨mantissa5, hm5, hpair2⟩ :=
                bind_ok_inv _ _ _ hpair2
              obtain ⟨power22, hp22, hpair2⟩ :=
                bind_ok_inv _ _ _ hpair2
              cases hpair2
              by_cases hsat : power21 ≥ 2047#i32
              · simp only [hsat, if_true] at h
                cases h
                right
                norm_num
              · simp only [hsat, if_false] at h
                cases h
                right
                change 0 ≤ power21.val ∧ power21.val ≤ 2047
                have hp22v : power21.val = power2.val + 1 := by
                  have he := IScalar.add_equiv power2 (1#i32)
                  rw [hp22] at he
                  exact he.2.1
                change ¬ power2.val ≤ 0 at hp2
                change ¬ 2047 ≤ power21.val at hsat
                constructor <;> omega
            · simp only [hcarry, if_false, bind_tc_ok,
                Aeneas.Std.uncurry_apply_pair] at h
              obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
              by_cases hsat : power2 ≥ 2047#i32
              · simp only [hsat, if_true] at h
                cases h
                right
                norm_num
              · simp only [hsat, if_false] at h
                cases h
                right
                change 0 ≤ power2.val ∧ power2.val ≤ 2047
                change ¬ power2.val ≤ 0 at hp2
                change ¬ 2047 ≤ power2.val at hsat
                constructor <;> omega
        · have hbfalse : decide (q ≤ 55#i64) = false := by simpa using hq55
          simp only [hbfalse, if_false, bind_tc_ok] at h
          cases h
          left
          norm_num
      · simp only [hqneg, if_false, bind_tc_ok] at h
        cases h
        left
        norm_num
    · simp only [hlo, if_false] at h
      obtain ⟨i8, hi8, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i9, hi9, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i11, hi11, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i12, hi12, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨mantissa, hmantissa, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i14, hi14, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i15, hi15, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i17, hi17, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i18, hi18, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨i19, hi19, h⟩ := bind_ok_inv _ _ _ h
      obtain ⟨power2, hpower2, h⟩ := bind_ok_inv _ _ _ h
      by_cases hp2 : power2 ≤ 0#i32
      · simp only [hp2, if_true] at h
        obtain ⟨i20, hi20, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
        by_cases hz : i21 ≥ 64#i32
        · simp only [hz, if_true] at h
          cases h
          right
          norm_num
        · simp only [hz, if_false] at h
          obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨i24, hi24, h⟩ := bind_ok_inv _ _ _ h
          cases h
          right
          have hc := IScalar.cast_fromBool_bound_eq .I32
            (decide (mantissa3 ≥ i24))
          exact ⟨hc.1, hc.2.trans (by norm_num)⟩
      · simp only [hp2, if_false] at h
        obtain ⟨mantissa1, hm1, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨mantissa2, hm2, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨mantissa3, hm3, h⟩ := bind_ok_inv _ _ _ h
        obtain ⟨i21, hi21, h⟩ := bind_ok_inv _ _ _ h
        by_cases hcarry : mantissa3 ≥ i21
        · simp only [hcarry, if_true] at h
          obtain ⟨pair2, hpair2, h⟩ := bind_ok_inv _ _ _ h
          rcases pair2 with ⟨mantissa4, power21⟩
          obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
          obtain ⟨mantissa5, hm5, hpair2⟩ :=
            bind_ok_inv _ _ _ hpair2
          obtain ⟨power22, hp22, hpair2⟩ :=
            bind_ok_inv _ _ _ hpair2
          cases hpair2
          by_cases hsat : power21 ≥ 2047#i32
          · simp only [hsat, if_true] at h
            cases h
            right
            norm_num
          · simp only [hsat, if_false] at h
            cases h
            right
            change 0 ≤ power21.val ∧ power21.val ≤ 2047
            have hp22v : power21.val = power2.val + 1 := by
              have he := IScalar.add_equiv power2 (1#i32)
              rw [hp22] at he
              exact he.2.1
            change ¬ power2.val ≤ 0 at hp2
            change ¬ 2047 ≤ power21.val at hsat
            constructor <;> omega
        · simp only [hcarry, if_false, bind_tc_ok,
            Aeneas.Std.uncurry_apply_pair] at h
          obtain ⟨i22, hi22, h⟩ := bind_ok_inv _ _ _ h
          by_cases hsat : power2 ≥ 2047#i32
          · simp only [hsat, if_true] at h
            cases h
            right
            norm_num
          · simp only [hsat, if_false] at h
            cases h
            right
            change 0 ≤ power2.val ∧ power2.val ≤ 2047
            change ¬ power2.val ≤ 0 at hp2
            change ¬ 2047 ≤ power2.val at hsat
            constructor <;> omega

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (87)
More program dependencies (45)
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 83 entries
Technical checking records
Local closure summary
{
  "node": "ParserComputeFloatExponentRange",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "7dde5f58697ede5310ec549a3c69463d2083e7681e05cfb8ad1310fc7384a713",
  "active_statement_hash": "c670958764c08514d41ef0a12885b50fb0999ae1dcfaaea407831267ccd1c888",
  "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": {
    "Binary64ModelDefault": "c722a2c00805b545",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS": "cfedcf26d6dae341",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN": "2532cbe447dc07c7",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN": "8a9e3dfa7e9aa5ec",
    "ParserExponentConstants": "c1391b605f3cfebb",
    "num_imp_dec2flt_lemire_compute_float": "7539bc2a998f5c1c",
    "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": "c98c2c511cf0ced6",
    "Binary64ModelDefault": "dc548d1e27696ba4",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "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",
    "Preamble": "1f712bede6a5dae6",
    "core_num_FpCategory": "c43614ff2149ecf2",
    "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": "a6aab0871ca17958"
  }
}
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:df9445132290a336fb5039832451742c614c090ff0725b202f13086530f3f3af",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}