import Tablet.AssemblyCorrespondence import Tablet.DecimalGoalVocabularyDefault import Tablet.F64_Insts_CoreOpsArithDivF64F64 import Tablet.F64_Insts_CoreOpsArithMulF64F64 import Tablet.F64_Insts_CoreOpsArithNegF64 import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64 import Tablet.num_imp_dec2flt_Dec2FltAssemblyTrace import Tablet.num_imp_dec2flt_dec2flt_with_trace open Aeneas Aeneas.Std Result ControlFlow Error set_option autoImplicit false namespace dec2flt_model -- [TABLET NODE: ParserAssemblyResidue] theorem ParserAssemblyResidue : forall (s : Str) (f : F64) (tr : num.imp.dec2flt.Dec2FltAssemblyTrace F64), DecimalGoalVocabularyDefault.sourceString s -> num.imp.dec2flt.dec2flt_with_trace F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64 F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f, num.imp.dec2flt.Dec2FltTrace.Assembled tr) -> DecimalGoalVocabularyDefault.assembledWord tr.selected_pair tr.assembly_result := by -- BODY intro s f tr hsource htrace have bind_ok_inv : forall {alpha beta : Type} (x : Result alpha) (g : alpha -> Result beta) y, Bind.bind x g = ok y -> exists z, x = ok z /\ g z = ok y := by intro alpha beta x g y hx cases x with | fail err => simp [Bind.bind, Aeneas.Std.bind] at hx | div => simp [Bind.bind, Aeneas.Std.bind] at hx | ok z => exact ⟨z, rfl, hx⟩ unfold num.imp.dec2flt.dec2flt_with_trace at htrace obtain ⟨body, hbody, htrace⟩ := bind_ok_inv _ _ _ htrace obtain ⟨first, hfirst, htrace⟩ := bind_ok_inv _ _ _ htrace cases first with | none => obtain ⟨pfe, hpfe, htrace⟩ := bind_ok_inv _ _ _ htrace cases htrace | some c => obtain ⟨body1, hbody1, htrace⟩ := bind_ok_inv _ _ _ htrace obtain ⟨empty, hempty, htrace⟩ := bind_ok_inv _ _ _ htrace by_cases he : empty = true · simp only [he, if_true] at htrace obtain ⟨pfe, hpfe, htrace⟩ := bind_ok_inv _ _ _ htrace cases htrace · have hef : empty = false := Bool.eq_false_of_not_eq_true he simp only [hef] at htrace obtain ⟨parsed, hparsed, htrace⟩ := bind_ok_inv _ _ _ htrace cases parsed with | none => obtain ⟨special, hspecial, htrace⟩ := bind_ok_inv _ _ _ htrace cases special with | none => obtain ⟨pfe, hpfe, htrace⟩ := bind_ok_inv _ _ _ htrace cases htrace | some value => cases htrace | some parsedRecord => obtain ⟨fast, hfast, htrace⟩ := bind_ok_inv _ _ _ htrace cases fast with | some value => cases htrace | none => obtain ⟨firstPair, hfirstPair, htrace⟩ := bind_ok_inv _ _ _ htrace obtain ⟨phase1, hphase1, htrace⟩ := bind_ok_inv _ _ _ htrace rcases phase1 with ⟨many1, many2, firstPair1, fp, secondGuard⟩ obtain ⟨phase2, hphase2, htrace⟩ := bind_ok_inv _ _ _ htrace rcases phase2 with ⟨post, secondExp, secondMant, secondResult, secondEqual, forced⟩ obtain ⟨phase3, hphase3, htrace⟩ := bind_ok_inv _ _ _ htrace rcases phase3 with ⟨selected, slowGuard, slowResult⟩ obtain ⟨i, hi, htrace⟩ := bind_ok_inv _ _ _ htrace obtain ⟨i1, hi1, htrace⟩ := bind_ok_inv _ _ _ htrace obtain ⟨i2, hi2, htrace⟩ := bind_ok_inv _ _ _ htrace obtain ⟨word, hwordValue, htrace⟩ := bind_ok_inv _ _ _ htrace obtain ⟨assembled, hassembled, htrace⟩ := bind_ok_inv _ _ _ htrace rcases AssemblyCorrespondence selected with ⟨expected, hexpected, hword⟩ rw [hassembled] at hexpected cases hexpected by_cases hnegative : c = 45#u8 · simp only [hnegative, if_true] at htrace obtain ⟨result, hresult, htrace⟩ := bind_ok_inv _ _ _ htrace cases htrace exact hword · simp only [hnegative, if_false] at htrace cases htrace exact hword end dec2flt_model