import Tablet.NumberHelperTryParse19SafeLength open Aeneas Aeneas.Std Result ControlFlow Error set_option autoImplicit false namespace dec2flt_model -- [TABLET NODE: ParserNumericLeadingTry19Certificate] theorem ParserNumericLeadingTry19Certificate (body point : Slice Std.U8) (tail : List Std.U8) (hpoint : point.val = 46#u8 :: tail) (hbody : body.val = 48#u8 :: point.val) : num.imp.dec2flt.parse.try_parse_19digits body 0#u64 = ok (point, 0#u64) := by -- BODY have hdigit : forall b, List.Mem b ([48#u8] : List Std.U8) -> 48 <= b.val /\ b.val <= 57 := by intro b hb cases hb with | head => norm_num | tail _ hb => cases hb have htail : forall b rest, point.val = b :: rest -> Not (48 <= b.val /\ b.val <= 57) := by intro b rest h rw [hpoint] at h simp only [List.cons.injEq] at h rcases h with ⟨rfl, _⟩ norm_num obtain ⟨rest0, mantissa0, remaining0, consumed0, hparse0, hpartition0, hrest0, hvalue0, hremaining0, hremainingLen0, hmantissa0, hlow0, hsharp0⟩ := NumberHelperTryParse19SafeLength body 0#u64 [48#u8] point.val (by simpa [hbody]) hdigit htail (by norm_num) have hmantissa0Eq : mantissa0 = 0#u64 := by apply UScalar.eq_of_val_eq cases consumed0 with | nil => simpa using hvalue0 | cons b bs => have hp := hpartition0 simp only [List.cons_append, List.cons.injEq] at hp rcases hp with ⟨rfl, hp⟩ have hbs : bs = [] := by cases bs with | nil => rfl | cons c cs => simp at hp subst bs simpa using hvalue0 have hremaining0Eq : remaining0 = [] := by apply hlow0 rw [hmantissa0Eq] norm_num have hrest0Val : rest0.val = point.val := by simpa [hremaining0Eq] using hrest0 have hrest0Eq : rest0 = point := (Slice.eq_iff _ _).2 hrest0Val subst rest0 simpa [hmantissa0Eq] using hparse0 end dec2flt_model