ParserExactRoundingExecution

Lean checked

Statement

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

Helper · Exact execution of the long decimal witness

Let s contain the ASCII bytes 0., followed by exactly 65{,}535 zero bytes, and then 1e655360. The extracted public binary64 parser returns success with the binary64 word 0x3ff0000000000000, namely 1.0.

Lean statement

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

import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000

namespace dec2flt_model

-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
    (hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
      [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
    num.imp.dec2flt.dec2flt
      F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
      F64.Insts.CoreOpsArithDivF64F64
      F64.Insts.CoreOpsArithMulF64F64
      F64.Insts.CoreOpsArithNegF64 s =
        ok (core.result.Result.Ok
          (⟨BitVec.ofNat 64 4607182418800017408⟩ : 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

By ParserExactRoundingDigitScans, the initial digit scan consumes the integer zero and leaves the point with accumulator zero. Splitting the point and applying the second scan consumes the 65{,}535 fractional zeros and terminal one, leaves e655360, and produces mantissa one.
The exact suffix-length equations supplied by ParserExactRoundingOffsets are as follows. The initial digit count is 65{,}545-65{,}544=1; the after-point count is 65{,}543-7=65{,}536; and the complete consumed length is 65{,}545. Negating and casting the after-point count therefore gives fractional exponent -65{,}536, while the total digit count is 1+65{,}536=65{,}537. Every value lies in both the 32-bit and 64-bit signed or unsigned pointer bounds admitted by the model.
Splitting the exponent marker leaves the six digits 655360. ParserExactRoundingScientific gives their exact parsed value 65{,}536 and an empty remainder, so checked exponent addition gives zero. Since 65{,}537>19, the extracted parser subtracts nineteen and obtains 65{,}518. By ParserExactRoundingAdjustment, the many-digit adjustment is -18, which is not positive. Consequently the parser keeps the already accumulated mantissa one and sets many_digits to false. The exact record is therefore exponent zero, mantissa one, negative false, and many-digits false, and the consumed length equals the input length.
The first input byte is 0, so the dispatcher takes neither sign branch. It receives the exact decimal record above and, by ParserExactRoundingFastPath, the ordinary fast path returns binary64 1.0. The dispatcher propagates that successful value, and the public dec2flt wrapper discards only the trace and returns the same result.

Lean proof


  have parse_number_exact (body : Slice Std.U8)
      (hbody : body.val = [48#u8, 46#u8] ++
        List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
      num.imp.dec2flt.parse.parse_number body = ok (some {
        exponent := 0#i64,
        mantissa := 1#u64,
        negative := false,
        many_digits := false }) := by
    have hbodyLen : body.val.length = 65545 := by
      simp only [hbody, List.length_append, List.length_replicate,
        List.length_cons, List.length_nil]
    obtain ⟨point, hscan0, hpoint⟩ :=
      ParserExactRoundingDigitScans.2 body hbody
    have hpointLen : point.val.length = 65544 := by
      simp only [hpoint, List.length_cons, List.length_append,
        List.length_replicate, List.length_nil]
    obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
      ParserExactRoundingOffsets body point (by omega) (by omega)
    have hnDigitsEq : nDigits = 1#isize := by
      apply IScalar.eq_of_val_eq
      rw [hnDigitsVal, hbodyLen, hpointLen]
      norm_num
    subst nDigits
    let fraction : Slice Std.U8 :=
      ⟨List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
        simp only [List.length_append, List.length_replicate,
          List.length_cons, List.length_nil]
        rcases Usize.bounds_eq with q | q <;>
          norm_num [q, U32.max_eq, U64.max_eq]⟩
    have hfraction : fraction.val = List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
      rfl
    have hsplitPoint : core.slice.Slice.split_first point =
        ok (some (46#u8, fraction)) := by
      let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
        rw [hfraction]
        simp only [List.length_cons, List.length_append,
          List.length_replicate, List.length_nil]
        rcases Usize.bounds_eq with q | q <;>
          norm_num [q, U32.max_eq, U64.max_eq]⟩
      have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
        rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
          hfraction]
        rfl)
      rw [hpointEq]
      simp [core.slice.Slice.split_first,
        dec2flt_model.ModelSliceSplitFirst, point']
    obtain ⟨expRest, hscan1, hexpRest⟩ :=
      ParserExactRoundingDigitScans.1 fraction hfraction
    have hfractionLen : fraction.val.length = 65543 := by
      simp only [hfraction, List.length_append, List.length_replicate,
        List.length_cons, List.length_nil]
    have hexpRestLen : expRest.val.length = 7 := by
      simp [hexpRest]
    obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
      ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
    have hnAfterEq : nAfter = 65536#isize := by
      apply IScalar.eq_of_val_eq
      rw [hnAfterVal, hfractionLen, hexpRestLen]
      norm_num
    subst nAfter
    have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
      rw [IScalar.min]
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [IScalarTy.numBits, hbits]
    obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (HNeg.hNeg.step (65536#isize) hnAfterNotMin)
    have hnegAfterEq : negAfter = (-65536)#isize := by
      apply IScalar.eq_of_val_eq
      simpa using hnegAfterVal
    subst negAfter
    have hcastFractionExponent :
        lift (IScalar.cast .I64 ((-65536)#isize)) =
          ok (-65536)#i64 := by
      have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
        constructor
        · rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
          norm_num
        · rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
          norm_num)
      obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
      rw [hz]
      congr 2
      apply IScalar.eq_of_val_eq
      simpa using hzval
    have haddBounds : IScalar.min .Isize <=
          (1#isize).val + (65536#isize).val /\
        (1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
    obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (IScalar.add_spec haddBounds.1 haddBounds.2)
    have htotalDigitsEq : totalDigits = 65537#isize := by
      apply IScalar.eq_of_val_eq
      norm_num at htotalDigitsVal
      simpa using htotalDigitsVal
    subst totalDigits
    let exponentDigits : Slice Std.U8 :=
      ⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
        rcases Usize.bounds_eq with q | q <;>
          norm_num [q, U32.max_eq, U64.max_eq]⟩
    have hsplitExponent : core.slice.Slice.split_first expRest =
        ok (some (101#u8, exponentDigits)) := by
      let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
        rw [← hexpRest]
        exact expRest.property⟩
      have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
        rw [hexpRest])
      rw [hexpRestEq]
      simp [core.slice.Slice.split_first,
        dec2flt_model.ModelSliceSplitFirst, expRest']
    have hexponentDigits : exponentDigits.val =
        [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
    obtain ⟨empty, hscientific, hempty⟩ :=
      ParserExactRoundingScientific exponentDigits hexponentDigits
    have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
      have hb : IScalar.min .I64 <=
            ((-65536)#i64).val + (65536#i64).val /\
          ((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
        rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
          IScalar.max_IScalarTy_I64_eq, I64.max_eq]
        norm_num
      obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
        (IScalar.add_spec hb.1 hb.2)
      rw [hz]
      congr 1
      apply IScalar.eq_of_val_eq
      simpa using hzval
    obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
      ParserExactRoundingOffsets body empty (by omega) (by
        rw [hempty]
        simp)
    have hfullOffsetValExact : fullOffset.val = 65545 := by
      rw [hfullOffsetVal, hbodyLen, hempty]
      rfl
    have hfullCastBounds : 0 <= fullOffset.val /\
        fullOffset.val <= UScalar.max .Usize := by
      rw [hfullOffsetValExact]
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [UScalar.max, hbits]
    obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
    have hfullLenEq : fullLen = Slice.len body := by
      apply UScalar.eq_of_val_eq
      rw [hfullOffsetVal] at hfullLenVal
      simpa [hempty, Slice.len_val] using hfullLenVal
    subst fullLen
    have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
        ok (Slice.len body) := by
      simpa [Aeneas.Std.lift] using hcastLen0
    have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
    have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
    have hsubBounds : IScalar.min .Isize <=
          (65537#isize).val - (19#isize).val /\
        (65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
    obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (IScalar.sub_spec hsubBounds.1 hsubBounds.2)
    have hmoreDigitsEq : moreDigits = 65518#isize := by
      apply IScalar.eq_of_val_eq
      norm_num at hmoreDigitsVal
      simpa using hmoreDigitsVal
    subst moreDigits
    have hadjust := ParserExactRoundingAdjustment body hbody
    let pointPhase :=
        (match (46#u8 : Std.U8) with
        | 46#uscalar =>
          ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
        | _ => ok (point, 0#u64, 0#isize, 0#i64))
    have hpointMatch : pointPhase =
        ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
    have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
      unfold core.slice.Slice.is_empty
      rw [show body.length = 65545 by
        simpa [Slice.length] using hbodyLen]
      rfl
    have hnonemptyVal : body.val ≠ [] := by
      intro h
      rw [h] at hbodyLen
      norm_num at hbodyLen
    have hmassert : massert (¬ body.val = []) = ok () := by
      simp [hnonemptyVal]
    have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
        ok (some ({
          exponent := 0#i64,
          mantissa := 1#u64,
          negative := false,
          many_digits := false }, Slice.len body)) := by
      unfold num.imp.dec2flt.parse.parse_partial_number
      simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
        hnAfter, hnegAfter, hcastFractionExponent]
      change (do let x ← pointPhase; _) = _
      rw [hpointMatch]
      simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
        hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
        hadjust]
      rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
        (some 65536#i64) = ok
          (core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
      change (do
        let exponent ← (-65536)#i64 + 65536#i64
        ok (some (({
          exponent,
          mantissa := 1#u64,
          negative := false,
          many_digits := false } : num.imp.dec2flt.decimal.Decimal),
          Slice.len body))) = _
      rw [hexponentAdd]
      rfl
    unfold num.imp.dec2flt.parse.parse_number
    simp [hpartial]
  have hcompact : s.val = 48#u8 :: 46#u8 ::
      (List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
    rw [hs]
    rfl
  have hslen : s.val.length = 65545 := by
    simp only [hs, List.length_append, List.length_replicate,
      List.length_cons, List.length_nil]
  have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
    unfold core.slice.Slice.first ModelSliceFirst
    rw [hcompact]
    rfl
  have hnonempty : s.val ≠ [] := by
    intro h
    rw [h] at hslen
    norm_num at hslen
  have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
    unfold core.slice.Slice.is_empty
    rw [show s.length = 65545 by simpa [Slice.length] using hslen]
    rfl
  have hparse := parse_number_exact s hs
  simp [num.imp.dec2flt.dec2flt,
    num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
    ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
    ParserExactRoundingFastPath]

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.ParserExactRoundingDigitScans
import Tablet.ParserExactRoundingAdjustment
import Tablet.ParserExactRoundingFastPath
import Tablet.ParserExactRoundingOffsets
import Tablet.ParserExactRoundingScientific
import Tablet.ModelSliceSplitFirst
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_dec2flt

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
set_option maxRecDepth 1000000

namespace dec2flt_model

-- [TABLET NODE: ParserExactRoundingExecution]
theorem ParserExactRoundingExecution (s : Str)
    (hs : s.val = [48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
      [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
    num.imp.dec2flt.dec2flt
      F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
      F64.Insts.CoreOpsArithDivF64F64
      F64.Insts.CoreOpsArithMulF64F64
      F64.Insts.CoreOpsArithNegF64 s =
        ok (core.result.Result.Ok
          (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by
-- BODY
  have parse_number_exact (body : Slice Std.U8)
      (hbody : body.val = [48#u8, 46#u8] ++
        List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) :
      num.imp.dec2flt.parse.parse_number body = ok (some {
        exponent := 0#i64,
        mantissa := 1#u64,
        negative := false,
        many_digits := false }) := by
    have hbodyLen : body.val.length = 65545 := by
      simp only [hbody, List.length_append, List.length_replicate,
        List.length_cons, List.length_nil]
    obtain ⟨point, hscan0, hpoint⟩ :=
      ParserExactRoundingDigitScans.2 body hbody
    have hpointLen : point.val.length = 65544 := by
      simp only [hpoint, List.length_cons, List.length_append,
        List.length_replicate, List.length_nil]
    obtain ⟨nDigits, hnDigits, hnDigitsVal⟩ :=
      ParserExactRoundingOffsets body point (by omega) (by omega)
    have hnDigitsEq : nDigits = 1#isize := by
      apply IScalar.eq_of_val_eq
      rw [hnDigitsVal, hbodyLen, hpointLen]
      norm_num
    subst nDigits
    let fraction : Slice Std.U8 :=
      ⟨List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
        simp only [List.length_append, List.length_replicate,
          List.length_cons, List.length_nil]
        rcases Usize.bounds_eq with q | q <;>
          norm_num [q, U32.max_eq, U64.max_eq]⟩
    have hfraction : fraction.val = List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by
      rfl
    have hsplitPoint : core.slice.Slice.split_first point =
        ok (some (46#u8, fraction)) := by
      let point' : Slice Std.U8 := ⟨46#u8 :: fraction.val, by
        rw [hfraction]
        simp only [List.length_cons, List.length_append,
          List.length_replicate, List.length_nil]
        rcases Usize.bounds_eq with q | q <;>
          norm_num [q, U32.max_eq, U64.max_eq]⟩
      have hpointEq : point = point' := (Slice.eq_iff _ _).2 (by
        rw [hpoint, show point'.val = 46#u8 :: fraction.val by rfl,
          hfraction]
        rfl)
      rw [hpointEq]
      simp [core.slice.Slice.split_first,
        dec2flt_model.ModelSliceSplitFirst, point']
    obtain ⟨expRest, hscan1, hexpRest⟩ :=
      ParserExactRoundingDigitScans.1 fraction hfraction
    have hfractionLen : fraction.val.length = 65543 := by
      simp only [hfraction, List.length_append, List.length_replicate,
        List.length_cons, List.length_nil]
    have hexpRestLen : expRest.val.length = 7 := by
      simp [hexpRest]
    obtain ⟨nAfter, hnAfter, hnAfterVal⟩ :=
      ParserExactRoundingOffsets fraction expRest (by omega) (by omega)
    have hnAfterEq : nAfter = 65536#isize := by
      apply IScalar.eq_of_val_eq
      rw [hnAfterVal, hfractionLen, hexpRestLen]
      norm_num
    subst nAfter
    have hnAfterNotMin : (65536#isize) ≠ IScalar.min .Isize := by
      rw [IScalar.min]
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [IScalarTy.numBits, hbits]
    obtain ⟨negAfter, hnegAfter, hnegAfterVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (HNeg.hNeg.step (65536#isize) hnAfterNotMin)
    have hnegAfterEq : negAfter = (-65536)#isize := by
      apply IScalar.eq_of_val_eq
      simpa using hnegAfterVal
    subst negAfter
    have hcastFractionExponent :
        lift (IScalar.cast .I64 ((-65536)#isize)) =
          ok (-65536)#i64 := by
      have hc := IScalar.cast_inBounds_spec .I64 ((-65536)#isize) (by
        constructor
        · rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq]
          norm_num
        · rw [IScalar.max_IScalarTy_I64_eq, I64.max_eq]
          norm_num)
      obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists hc
      rw [hz]
      congr 2
      apply IScalar.eq_of_val_eq
      simpa using hzval
    have haddBounds : IScalar.min .Isize <=
          (1#isize).val + (65536#isize).val /\
        (1#isize).val + (65536#isize).val <= IScalar.max .Isize := by
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
    obtain ⟨totalDigits, haddDigits, htotalDigitsVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (IScalar.add_spec haddBounds.1 haddBounds.2)
    have htotalDigitsEq : totalDigits = 65537#isize := by
      apply IScalar.eq_of_val_eq
      norm_num at htotalDigitsVal
      simpa using htotalDigitsVal
    subst totalDigits
    let exponentDigits : Slice Std.U8 :=
      ⟨[54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8], by
        rcases Usize.bounds_eq with q | q <;>
          norm_num [q, U32.max_eq, U64.max_eq]⟩
    have hsplitExponent : core.slice.Slice.split_first expRest =
        ok (some (101#u8, exponentDigits)) := by
      let expRest' : Slice Std.U8 := ⟨101#u8 :: exponentDigits.val, by
        rw [← hexpRest]
        exact expRest.property⟩
      have hexpRestEq : expRest = expRest' := (Slice.eq_iff _ _).2 (by
        rw [hexpRest])
      rw [hexpRestEq]
      simp [core.slice.Slice.split_first,
        dec2flt_model.ModelSliceSplitFirst, expRest']
    have hexponentDigits : exponentDigits.val =
        [54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8] := by rfl
    obtain ⟨empty, hscientific, hempty⟩ :=
      ParserExactRoundingScientific exponentDigits hexponentDigits
    have hexponentAdd : ((-65536)#i64 + 65536#i64) = ok 0#i64 := by
      have hb : IScalar.min .I64 <=
            ((-65536)#i64).val + (65536#i64).val /\
          ((-65536)#i64).val + (65536#i64).val <= IScalar.max .I64 := by
        rw [IScalar.min_IScalarTy_I64_eq, I64.min_eq,
          IScalar.max_IScalarTy_I64_eq, I64.max_eq]
        norm_num
      obtain ⟨z, hz, hzval⟩ := Aeneas.Std.WP.spec_imp_exists
        (IScalar.add_spec hb.1 hb.2)
      rw [hz]
      congr 1
      apply IScalar.eq_of_val_eq
      simpa using hzval
    obtain ⟨fullOffset, hfullOffset, hfullOffsetVal⟩ :=
      ParserExactRoundingOffsets body empty (by omega) (by
        rw [hempty]
        simp)
    have hfullOffsetValExact : fullOffset.val = 65545 := by
      rw [hfullOffsetVal, hbodyLen, hempty]
      rfl
    have hfullCastBounds : 0 <= fullOffset.val /\
        fullOffset.val <= UScalar.max .Usize := by
      rw [hfullOffsetValExact]
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [UScalar.max, hbits]
    obtain ⟨fullLen, hcastLen0, hfullLenVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (IScalar.hcast_inBounds_spec .Usize fullOffset hfullCastBounds)
    have hfullLenEq : fullLen = Slice.len body := by
      apply UScalar.eq_of_val_eq
      rw [hfullOffsetVal] at hfullLenVal
      simpa [hempty, Slice.len_val] using hfullLenVal
    subst fullLen
    have hcastLen : lift (IScalar.hcast .Usize fullOffset) =
        ok (Slice.len body) := by
      simpa [Aeneas.Std.lift] using hcastLen0
    have htotalNonzero : ¬ (65537#isize).val = 0 := by norm_num
    have htotalLarge : ¬ (65537#isize).val <= (19#isize).val := by norm_num
    have hsubBounds : IScalar.min .Isize <=
          (65537#isize).val - (19#isize).val /\
        (65537#isize).val - (19#isize).val <= IScalar.max .Isize := by
      rcases System.Platform.numBits_eq with hbits | hbits <;>
        simp [IScalar.min, IScalar.max, IScalarTy.numBits, hbits]
    obtain ⟨moreDigits, hsubDigits0, hmoreDigitsVal⟩ :=
      Aeneas.Std.WP.spec_imp_exists
        (IScalar.sub_spec hsubBounds.1 hsubBounds.2)
    have hmoreDigitsEq : moreDigits = 65518#isize := by
      apply IScalar.eq_of_val_eq
      norm_num at hmoreDigitsVal
      simpa using hmoreDigitsVal
    subst moreDigits
    have hadjust := ParserExactRoundingAdjustment body hbody
    let pointPhase :=
        (match (46#u8 : Std.U8) with
        | 46#uscalar =>
          ok (expRest, 1#u64, 65536#isize, (-65536)#i64)
        | _ => ok (point, 0#u64, 0#isize, 0#i64))
    have hpointMatch : pointPhase =
        ok (expRest, 1#u64, 65536#isize, (-65536)#i64) := by rfl
    have hnotEmpty : core.slice.Slice.is_empty body = ok false := by
      unfold core.slice.Slice.is_empty
      rw [show body.length = 65545 by
        simpa [Slice.length] using hbodyLen]
      rfl
    have hnonemptyVal : body.val ≠ [] := by
      intro h
      rw [h] at hbodyLen
      norm_num at hbodyLen
    have hmassert : massert (¬ body.val = []) = ok () := by
      simp [hnonemptyVal]
    have hpartial : num.imp.dec2flt.parse.parse_partial_number body =
        ok (some ({
          exponent := 0#i64,
          mantissa := 1#u64,
          negative := false,
          many_digits := false }, Slice.len body)) := by
      unfold num.imp.dec2flt.parse.parse_partial_number
      simp [hnotEmpty, hmassert, hscan0, hnDigits, hsplitPoint, hscan1,
        hnAfter, hnegAfter, hcastFractionExponent]
      change (do let x ← pointPhase; _) = _
      rw [hpointMatch]
      simp [haddDigits, hsplitExponent, hscientific, hexponentAdd,
        hfullOffset, hcastLen, htotalNonzero, htotalLarge, hsubDigits0,
        hadjust]
      rw [show core.option.Option.Insts.CoreOpsTry_traitTry.branch
        (some 65536#i64) = ok
          (core.ops.control_flow.ControlFlow.Continue 65536#i64) by rfl]
      change (do
        let exponent ← (-65536)#i64 + 65536#i64
        ok (some (({
          exponent,
          mantissa := 1#u64,
          negative := false,
          many_digits := false } : num.imp.dec2flt.decimal.Decimal),
          Slice.len body))) = _
      rw [hexponentAdd]
      rfl
    unfold num.imp.dec2flt.parse.parse_number
    simp [hpartial]
  have hcompact : s.val = 48#u8 :: 46#u8 ::
      (List.replicate 65535 48#u8 ++
        [49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]) := by
    rw [hs]
    rfl
  have hslen : s.val.length = 65545 := by
    simp only [hs, List.length_append, List.length_replicate,
      List.length_cons, List.length_nil]
  have hfirst : core.slice.Slice.first s = ok (some 48#u8) := by
    unfold core.slice.Slice.first ModelSliceFirst
    rw [hcompact]
    rfl
  have hnonempty : s.val ≠ [] := by
    intro h
    rw [h] at hslen
    norm_num at hslen
  have hnotEmpty : core.slice.Slice.is_empty s = ok false := by
    unfold core.slice.Slice.is_empty
    rw [show s.length = 65545 by simpa [Slice.length] using hslen]
    rfl
  have hparse := parse_number_exact s hs
  simp [num.imp.dec2flt.dec2flt,
    num.imp.dec2flt.dec2flt_with_trace, core.str.Str.as_bytes,
    ModelStrAsBytes, hfirst, hnotEmpty, hnonempty, hparse,
    ParserExactRoundingFastPath]

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 155 entries
Technical checking records
Local closure summary
{
  "node": "ParserExactRoundingExecution",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "c16193d7487450e06b9ed04f467665461a5b154c647e03bda0c79ce6556f8386",
  "active_statement_hash": "8675d62b80641decd8db5bd5cff9890390e01e0578bb77b092bb0249cef5cd5a",
  "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-128",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "ModelSliceSplitFirst": "f617ee05dd2925a9",
    "ParserExactRoundingAdjustment": "8a438dcb25e6fd4f",
    "ParserExactRoundingDigitScans": "46bd2e392b835ee8",
    "ParserExactRoundingFastPath": "81ba41edcef28819",
    "ParserExactRoundingOffsets": "a6776433789c2055",
    "ParserExactRoundingScientific": "74ef2c607da17b40",
    "num_imp_dec2flt_dec2flt_with_trace": "8f54814ba9c190ea",
    "num_imp_dec2flt_parse_parse_partial_number": "854af4cc12136a58",
    "num_imp_traits_Float_SIG_BITS_default": "9ab622d85ef04d94"
  },
  "strict_definition_deps": {
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
    "F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
    "F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64": "60afe26c6a80cf0f",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS": "887b52d84a3fc9c4",
    "ModelSliceFirst": "a31394b3c1080f71",
    "ModelStrAsBytes": "024fe35b4dbfa9a3",
    "Preamble": "965f15fc36f80938",
    "SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from": "7e7284dc9bc88830",
    "core_ops_arith_Div": "6e5df64b87169aa0",
    "core_ops_arith_Mul": "6e5df64b87169aa0",
    "core_ops_arith_Neg": "94ab5f784cdf5db8",
    "num_float_parse_ParseFloatError": "c43614ff2149ecf2",
    "num_imp_dec2flt_Dec2FltAssemblyTrace": "7bda5de02611ad76",
    "num_imp_dec2flt_Dec2FltTrace": "ef050fc88fd50bb9",
    "num_imp_dec2flt_Lemire": "1923f90c53d323e6",
    "num_imp_dec2flt_biased_fp_to_float": "acdde060e8d35ca7",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq": "fbbf553e3c502a05",
    "num_imp_dec2flt_dec2flt": "f9f7d93449a25efa",
    "num_imp_dec2flt_dec2flt_with_trace": "8bc9229f6c14573d",
    "num_imp_dec2flt_decimal_Decimal": "b702e549017701b8",
    "num_imp_dec2flt_decimal_Decimal_try_fast_path": "2e4888f65a06b49f",
    "num_imp_dec2flt_lemire_compute_float": "39d89e3f0a8a9d4c",
    "num_imp_dec2flt_parse_adjust_many_digit_count": "4e59e3776b6cfdaa",
    "num_imp_dec2flt_parse_parse_inf_nan": "85655c19a8791b54",
    "num_imp_dec2flt_parse_parse_many_digits": "50c9ef13b3ed7fe8",
    "num_imp_dec2flt_parse_parse_number": "b8693ec58f01c43c",
    "num_imp_dec2flt_parse_parse_partial_number": "359d30eefc709c2a",
    "num_imp_dec2flt_parse_parse_scientific": "447f722d5841d2c5",
    "num_imp_dec2flt_parse_try_parse_digits": "238b4a73cd46fc56",
    "num_imp_dec2flt_pfe_empty": "89046d1da5ac1ce2",
    "num_imp_dec2flt_pfe_invalid": "21db875427d92c6d",
    "num_imp_dec2flt_slow_parse_long_mantissa": "cd8af64c3688b60f",
    "num_imp_traits_Float": "02acccb9db3e30f2",
    "num_imp_traits_FloatExt": "f996e5400649797d"
  }
}
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:2890e07c5bcba43c1186d6f1239b8d8822fbd9751e9ea29874386ef35485f786",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}