import Tablet.ModelSliceSplitFirst import Tablet.NumberHelperLeadingPointDigitScan import Tablet.NumberHelperLeadingPointSplit import Tablet.NumberHelperScientificExponentBounds import Tablet.NumberHelperSelfOffset import Tablet.NumberHelperSharpFractionBytes import Tablet.NumberHelperSharpPartialExecution import Tablet.num_imp_dec2flt_parse_parse_number open Aeneas Aeneas.Std Result ControlFlow Error set_option autoImplicit false namespace dec2flt_model -- [TABLET NODE: NumberHelperSharpParseFailure] theorem NumberHelperSharpParseFailure (s : Slice Std.U8) (hs : s.val = [46#u8] ++ List.replicate 9223372036854120450 49#u8 ++ [101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]) : num.imp.dec2flt.parse.parse_number s = fail integerOverflow := by -- BODY obtain ⟨fractionBytes, hfractionValue, hfractionLength⟩ := NumberHelperSharpFractionBytes have hBound : 9223372036854120459 <= Usize.max := by have h := Usize.max_succ_eq_pow rw [Dec2Flt.configured_x86_64_numBits] at h norm_num at h omega let fracSlice : Slice Std.U8 := ⟨fractionBytes, by rw [hfractionLength] omega⟩ let markerTail : Slice Std.U8 := ⟨[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8], by have hsmall : 8 <= Usize.max := by omega simpa only [List.length_cons, List.length_nil] using hsmall⟩ let suffix : Slice Std.U8 := ⟨[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8], by have hsmall : 7 <= Usize.max := by omega simpa only [List.length_cons, List.length_nil] using hsmall⟩ have hsTail : s.val = 46#u8 :: fractionBytes := by rw [hs, hfractionValue] simp only [List.cons_append, List.nil_append] have hsLen : s.val.length = 9223372036854120459 := by rw [hsTail, List.length_cons, hfractionLength] have hscanInt : num.imp.dec2flt.parse.try_parse_digits s 0#u64 = ok (s, 0#u64) := by apply NumberHelperLeadingPointDigitScan s 0#u64 fractionBytes hsTail rw [hsLen] norm_num have hoffInt : SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.offset_from s s = ok 0#isize := NumberHelperSelfOffset s have hlead : Not (s.val = []) /\ core.slice.Slice.split_first s = ok (some (46#u8, fracSlice)) := by apply NumberHelperLeadingPointSplit s fracSlice exact hsTail have hfrac : fracSlice.val = List.replicate 9223372036854120450 49#u8 ++ [101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] := by exact hfractionValue have hmarker : markerTail.val = [101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8] := by rfl have hfracBound : fracSlice.val.length <= 9223372036854120458 := by change fractionBytes.length <= _ rw [hfractionLength] have hsplitMarker : core.slice.Slice.split_first markerTail = ok (some (101#u8, suffix)) := by simp [markerTail, suffix, core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst] obtain ⟨empty, hscientific, _⟩ := NumberHelperScientificExponentBounds.2.2 suffix (by rfl) have hpartial : num.imp.dec2flt.parse.parse_partial_number s = fail integerOverflow := NumberHelperSharpPartialExecution s fracSlice markerTail suffix empty hlead.1 hscanInt hoffInt hlead.2 hfrac hmarker hfracBound hsplitMarker hscientific unfold num.imp.dec2flt.parse.parse_number rw [hpartial] simp only [bind_tc_fail] end dec2flt_model