import Tablet.ModelSliceSplitFirst import Tablet.NumberHelperLeadingPointDigitScan import Tablet.NumberHelperLeadingPointSplit import Tablet.NumberHelperSelfOffset import Tablet.NumberHelperSharpTrailingPartialExecution import Tablet.NumberHelperScientificTrailingByte import Tablet.num_imp_dec2flt_parse_parse_number open Aeneas Aeneas.Std Result ControlFlow Error set_option autoImplicit false namespace dec2flt_model -- [TABLET NODE: NumberHelperSharpTrailingParseFailure] theorem NumberHelperSharpTrailingParseFailure (fractionBytes : List Std.U8) (hfractionValue : fractionBytes = List.replicate 9223372036854120450 49#u8 ++ [101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8]) (hfractionLength : fractionBytes.length = 9223372036854120458) (s : Slice Std.U8) (hs : s.val = 46#u8 :: fractionBytes ++ [120#u8]) : num.imp.dec2flt.parse.parse_number s = fail integerOverflow := by -- BODY have hfracBound : (fractionBytes ++ [120#u8]).length <= Usize.max := by simp only [List.length_append, List.length_cons, List.length_nil, hfractionLength] 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 ++ [120#u8], hfracBound⟩ have hmarkerBound : [101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8, 120#u8].length <= Usize.max := by have h := Usize.max_succ_eq_pow rw [Dec2Flt.configured_x86_64_numBits] at h norm_num at h ⊢ omega let markerTail : Slice Std.U8 := ⟨[101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8, 120#u8], hmarkerBound⟩ have hsuffixBound : [45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8, 120#u8].length <= Usize.max := by have h := Usize.max_succ_eq_pow rw [Dec2Flt.configured_x86_64_numBits] at h norm_num at h ⊢ omega let suffix : Slice Std.U8 := ⟨[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8, 120#u8], hsuffixBound⟩ have hresidualBound : [120#u8].length <= Usize.max := by have h := Usize.max_succ_eq_pow rw [Dec2Flt.configured_x86_64_numBits] at h norm_num at h ⊢ omega let residual : Slice Std.U8 := ⟨[120#u8], hresidualBound⟩ 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, 120#u8] := by as_aux_lemma => simp only [fracSlice] rw [hfractionValue, List.append_assoc] rfl have hsTail : s.val = 46#u8 :: fracSlice.val := by simpa only [fracSlice] using hs have hsLen : s.val.length = 9223372036854120460 := by rw [hs] simp only [List.length_cons, List.length_append, List.length_nil, hfractionLength] have hscanInt : num.imp.dec2flt.parse.try_parse_digits s 0#u64 = ok (s, 0#u64) := by apply NumberHelperLeadingPointDigitScan s 0#u64 fracSlice.val 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)) := NumberHelperLeadingPointSplit s fracSlice hsTail have hfracLen : fracSlice.val.length <= 9223372036854775807 := by simp only [fracSlice, List.length_append, List.length_cons, List.length_nil, hfractionLength] norm_num have hmarker : markerTail.val = [101#u8, 45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8, 120#u8] := by rfl 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] have hscientific : num.imp.dec2flt.parse.parse_scientific suffix = ok (some ((-655359)#i64), residual) := NumberHelperScientificTrailingByte suffix residual (by rfl) (by rfl) have hpartial : num.imp.dec2flt.parse.parse_partial_number s = fail integerOverflow := NumberHelperSharpTrailingPartialExecution s fracSlice markerTail suffix residual hlead.1 hscanInt hoffInt hlead.2 hfrac hmarker hfracLen hsplitMarker hscientific have hparse : num.imp.dec2flt.parse.parse_number s = fail integerOverflow := by as_aux_lemma => unfold num.imp.dec2flt.parse.parse_number rw [hpartial] simp only [bind_tc_fail] exact hparse end dec2flt_model