import Tablet.P495_T1_RightShiftCanonical import Tablet.P495_T1_RightPrefixLengthBounds import Tablet.P472_T1_LoopZeroRightShiftTransport import Tablet.P472_T1_DecimalValueBounds import Tablet.SlowShiftSelectorCertificate import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64 import Tablet.num_imp_dec2flt_slow_parse_long_mantissa import Tablet.P472_T1_DecimalRightShiftPrefixLoopSemantics import Tablet.P472_T1_DecimalSeqRightShiftRecordSemantics open Aeneas Aeneas.Std Result ControlFlow Error set_option autoImplicit false namespace dec2flt_model -- [TABLET NODE: P495_T1_RightLoopStep] theorem P495_T1_RightLoopStep (X Y : Real) (d : num.imp.dec2flt.decimal_seq.DecimalSeq) (exp : Std.I32) (hpointLo : 1 <= d.decimal_point.val) (hpointHi : d.decimal_point.val < 310) (hexpLo : 0 <= exp.val) (hexpHi : exp.val <= 1260) (hinput : d.num_digits.val <= 768 /\ (forall b, b ∈ d.digits.val.take d.num_digits.val -> b.val < 10) /\ (exists h tail, (d.digits.val.take d.num_digits.val).map (fun b => b.val) = h :: tail /\ 1 <= h /\ h < 10 /\ (h :: tail).length = d.num_digits.val)) : let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq => ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) * (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int)) (exists eta u : Real, X = V d + eta /\ Y = V d + u /\ 0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta)) -> exists (d' : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize) (exp' : Std.I32), num.imp.dec2flt.slow.parse_long_mantissa_loop0.body F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 { m := 0#u64, p_biased := 0#i32 } d.num_digits d.decimal_point d.truncated d.digits exp none = ok (cont (d'.num_digits, d'.decimal_point, d'.truncated, d'.digits, exp', none)) /\ num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d' /\ shift.val <= 60 /\ exp'.val = exp.val + (shift.val : Int) /\ (19 <= d.decimal_point.val -> d'.decimal_point.val = d.decimal_point.val - 18 \/ d'.decimal_point.val = d.decimal_point.val - 19) /\ (d.decimal_point.val <= 18 -> d'.decimal_point.val = 0 \/ d'.decimal_point.val = 1) /\ d'.num_digits.val <= 768 /\ (forall b, b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10) /\ (exists h tail, (d'.digits.val.take d'.num_digits.val).map (fun b => b.val) = h :: tail /\ 1 <= h /\ h < 10 /\ (h :: tail).length = d'.num_digits.val) /\ d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 /\ (exists eta' u' : Real, X / (2 : Real) ^ shift.val = V d' + eta' /\ Y / (2 : Real) ^ shift.val = V d' + u' /\ 0 <= eta' /\ eta' < u' /\ (d'.truncated = true <-> 0 < eta')) /\ (d.decimal_point.val = 1 -> d'.decimal_point.val = 1 -> exists tail, (d'.digits.val.take d'.num_digits.val).map (fun b => b.val) = 1 :: tail) /\ (d.decimal_point.val = 1 -> (exists tail, (d.digits.val.take d.num_digits.val).map (fun b => b.val) = 1 :: tail) -> d'.decimal_point.val = 0) := by -- BODY set_option maxHeartbeats 1600000 in dsimp only intro happrox rcases happrox with ⟨eta, u, hX, hY, heta, hetau, hsticky⟩ rcases hinput with ⟨hcap, hdigit, hshape⟩ rcases hshape with ⟨head, tail, hshape, hhead, hhead10, hlen⟩ obtain ⟨n, hncast, hnval⟩ := Aeneas.Std.WP.spec_imp_exists (IScalar.hcast_inBounds_spec .Usize d.decimal_point (by scalar_tac)) let traits := F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 let shift : Std.Usize := match n.val with | 0 => 0#usize | 1 => 3#usize | 2 => 6#usize | 3 => 9#usize | 4 => 13#usize | 5 => 16#usize | 6 => 19#usize | 7 => 23#usize | 8 => 26#usize | 9 => 29#usize | 10 => 33#usize | 11 => 36#usize | 12 => 39#usize | 13 => 43#usize | 14 => 46#usize | 15 => 49#usize | 16 => 53#usize | 17 => 56#usize | 18 => 59#usize | _ => 60#usize have hselectorAll := SlowShiftSelectorCertificate traits n dsimp only at hselectorAll rcases hselectorAll with ⟨hselector, hshift, hsmallzero, hsmall, hlarge⟩ have hshiftCall : num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call traits () n = ok shift := hselector have hinputExec : d.num_digits.val <= 768 /\ (forall z, z ∈ d.digits.val.take d.num_digits.val -> z.val < 10) /\ (exists z zs, (d.digits.val.take d.num_digits.val).map (fun a => a.val) = z :: zs /\ 1 <= z /\ z < 10 /\ (z :: zs).length = d.num_digits.val) := ⟨hcap, hdigit, ⟨head, tail, hshape, hhead, hhead10, hlen⟩⟩ obtain ⟨read, acc, d', hloop0, hreadlo, hreadhi, haccLo, haccHi, hprospective⟩ := P472_T1_DecimalRightShiftLoop0Execution d shift hshift (by omega) (by omega) hinputExec rcases hprospective with ⟨hprosLo, hprosHi, hcall, hpoint', hnz⟩ have hprefixLen := P495_T1_RightPrefixLengthBounds d d shift read acc false hshift hcap hdigit head tail hshape hhead hlen hloop0 have hnpoint : n.val = d.decimal_point.val := by omega have hlargePoint : 19 <= d.decimal_point.val -> d'.decimal_point.val = d.decimal_point.val - 18 \/ d'.decimal_point.val = d.decimal_point.val - 19 := by intro hp have hb := hlarge (by omega) rcases hb with ⟨hsk, hpowlo, hpowhi⟩ have hshift60 : shift.val = 60 := by simpa using hsk have hpows : 10 ^ 18 < 2 ^ shift.val /\ 2 ^ shift.val < 10 ^ 19 := by rw [hshift60] exact ⟨hpowlo, hpowhi⟩ have hreadLo : 19 <= read.val := by by_contra hr have hr' : read.val <= 18 := by omega have hp10 : 10 ^ read.val <= 10 ^ 18 := Nat.pow_le_pow_right (by omega) hr' have haccLo' : 2 ^ shift.val <= acc.val := haccLo have haccHi' : acc.val < 10 ^ read.val := hprefixLen.2 omega have hreadHi : read.val <= 20 := by by_contra hr have hr' : 21 <= read.val := by omega have hp10 : 10 ^ 20 <= 10 ^ (read.val - 1) := Nat.pow_le_pow_right (by omega) (by omega) have hBlt : 10 * 2 ^ shift.val < 10 ^ 20 := by rw [hshift60] norm_num have haccLo' : 10 ^ (read.val - 1) <= acc.val := hprefixLen.1 have haccHi' : acc.val < 10 * 2 ^ shift.val := haccHi omega have hrCases : read.val = 19 \/ read.val = 20 := by omega rw [hpoint'] rcases hrCases with hr | hr · left rw [hr] omega · right rw [hr] omega have hsmallPoint : d.decimal_point.val <= 18 -> d'.decimal_point.val = 0 \/ d'.decimal_point.val = 1 := by intro hp have hnlo : 1 <= n.val := by omega have hnhi : n.val <= 18 := by omega rcases hsmall hnlo hnhi with ⟨hBle, hBlt⟩ have hpowlo' : 2 ^ shift.val <= 10 ^ n.val := hBle have hpowhi' : 10 ^ n.val < 2 ^ (shift.val + 1) := hBlt have hreadLo : n.val <= read.val := by by_contra hr have hr' : read.val <= n.val - 1 := by omega have hp10 : 10 ^ read.val <= 10 ^ (n.val - 1) := Nat.pow_le_pow_right (by omega) hr' have he : n.val - 1 + 1 = n.val := by omega have hpEq : 10 ^ n.val = 10 * 10 ^ (n.val - 1) := by calc 10 ^ n.val = 10 ^ (n.val - 1 + 1) := by rw [he] _ = 10 ^ (n.val - 1) * 10 := by rw [pow_succ] _ = 10 * 10 ^ (n.val - 1) := by omega have hhi : 10 * 10 ^ (n.val - 1) < 2 * 2 ^ shift.val := by calc 10 * 10 ^ (n.val - 1) = 10 ^ n.val := hpEq.symm _ < 2 ^ (shift.val + 1) := hpowhi' _ = 2 * 2 ^ shift.val := by rw [pow_succ]; ring have hBlt : 10 ^ (n.val - 1) < 2 ^ shift.val := by omega have haccBelow : acc.val < 10 ^ (n.val - 1) := by omega omega have hreadHi : read.val <= n.val + 1 := by by_contra hr have hr' : n.val + 2 <= read.val := by omega have hp10 : 10 ^ (n.val + 1) <= 10 ^ (read.val - 1) := Nat.pow_le_pow_right (by omega) (by omega) have hpEq : 10 ^ (n.val + 1) = 10 * 10 ^ n.val := by rw [show n.val + 1 = Nat.succ n.val by omega, pow_succ] omega have haccBelow : 10 ^ (read.val - 1) <= acc.val := hprefixLen.1 have haccAbove : acc.val < 10 * 2 ^ shift.val := haccHi omega have hread : read.val = n.val \/ read.val = n.val + 1 := by omega rw [hpoint'] rcases hread with hr | hr · right rw [hr] omega · left rw [hr] omega have htransport := P472_T1_LoopZeroRightShiftTransport d shift X eta u hshift (by omega) (by omega) hcap hdigit ⟨head, tail, hshape, hhead, hhead10, hlen⟩ (by dsimp only have hv := P472_T1_DecimalValueBounds ((d.digits.val.take d.num_digits.val).map (fun a => a.val)) head tail hshape hhead (by intro z hz obtain ⟨b, hb, rfl⟩ := List.mem_map.mp hz exact hdigit b hb) d.decimal_point.val have hpow : 0 < (10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) := zpow_pos (by norm_num) _ have hfoldPos (ys : List Nat) (a : Nat) (ha : 0 < a) : 0 < ys.foldl (fun n z => 10 * n + z) a := by induction ys generalizing a with | nil => simpa | cons z zs ih => simp only [List.foldl_cons] apply ih omega have hfold : 0 < ((d.digits.val.take d.num_digits.val).map (fun a => a.val)).foldl (fun n z => 10 * n + z) 0 := by rw [hshape] simp only [List.foldl_cons, Nat.mul_zero, Nat.zero_add] exact hfoldPos tail head hhead exact mul_pos (by exact_mod_cast hfold) hpow) hX heta hetau hsticky rcases htransport with ⟨d'', eta', u', hcall', hpl, hph, hnz', hX', heta', hetau', hsticky', hY', hcompare⟩ have hdEq : d' = d'' := by exact Result.ok.inj (hcall.symm.trans hcall') subst d'' have hnz'' : d'.num_digits.val ≠ 0 := by simpa using hnz have hcanonical := P495_T1_RightShiftCanonical X Y d d' shift hshift hcap hdigit ⟨head, tail, hshape, hhead, hhead10, hlen⟩ hcall hnz'' ⟨eta, u, hX, hY, heta, hetau, hsticky⟩ rcases hcanonical with ⟨hcanonLo, hcap', hdigit', hhead', htrim, hcanon⟩ rcases hcanon with ⟨eta'', u'', hX'', hY'', heta'', hetau'', hsticky''⟩ have hetaEq : eta' = eta'' := by linarith have huEq : u' = u'' := by rw [hY] at hY'' linarith subst eta'' subst u'' let val := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq => ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) * (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int)) have hvalueBounds := P472_T1_DecimalValueBounds ((d.digits.val.take d.num_digits.val).map (fun b => b.val)) head tail hshape hhead (by intro z hz obtain ⟨b, hb, rfl⟩ := List.mem_map.mp hz exact hdigit b hb) d.decimal_point.val have hinputPrefixLength : ((d.digits.val.take d.num_digits.val).map (fun b => b.val)).length = d.num_digits.val := by rw [hshape]; exact hlen have hvalueBounds' : (head : Real) * (10 : Real) ^ (d.decimal_point.val - 1) <= val d /\ val d < (10 : Real) ^ d.decimal_point.val := by have hdlen : d.digits.val.length = 768 := by simpa using d.digits.property have hh := hvalueBounds simp only [List.length_map, List.length_take, hdlen, Nat.min_eq_left hcap] at hh simpa [val, List.map_take] using hh have hstallHead : d.decimal_point.val = 1 -> d'.decimal_point.val = 1 -> exists tail, (d'.digits.val.take d'.num_digits.val).map (fun b => b.val) = 1 :: tail := by intro hp hp' have hn1 : n.val = 1 := by omega have hshift3 : shift.val = 3 := by simpa [shift, hn1] have hread1 : read.val = 1 := by rw [hpoint'] at hp'; omega rcases hhead' with ⟨outHead, outTail, houtshape, houtlo, hout10, houtlen⟩ have houtBounds := P472_T1_DecimalValueBounds ((d'.digits.val.take d'.num_digits.val).map (fun b => b.val)) outHead outTail houtshape houtlo (by intro z hz obtain ⟨b, hb, rfl⟩ := List.mem_map.mp hz exact hdigit' b hb) d'.decimal_point.val have houtPrefixLength : ((d'.digits.val.take d'.num_digits.val).map (fun b => b.val)).length = d'.num_digits.val := by rw [houtshape]; exact houtlen have houtBounds' : (outHead : Real) * (10 : Real) ^ (d'.decimal_point.val - 1) <= val d' /\ val d' < (10 : Real) ^ d'.decimal_point.val := by have hdlen' : d'.digits.val.length = 768 := by simpa using d'.digits.property have hh := houtBounds simp only [List.length_map, List.length_take, hdlen', Nat.min_eq_left hcap'] at hh simpa [val, List.map_take] using hh have hVin : 0 < val d := by have hh := hvalueBounds'.1 rw [hp] at hh norm_num at hh have hhhead : (1 : Real) <= (head : Real) := by exact_mod_cast hhead linarith have hrecord := P472_T1_DecimalSeqRightShiftRecordSemantics d d' shift (by omega) hVin hdigit hcall rcases hrecord with hreset | ⟨rho, hrho, _, hrecord, _⟩ · exact False.elim (by simp at hnz''; exact hnz'' hreset.1) have houtValLower : (outHead : Real) <= val d' := by have hh := houtBounds'.1 rw [hp'] at hh norm_num at hh exact hh have hVinUpper : val d < 10 := by have hh := hvalueBounds'.2 rw [hp] at hh norm_num at hh exact hh have hVout : val d' < 2 := by have hrecordVal : val d' = val d / (2 : Real) ^ shift.val - rho := by simpa [val, List.map_take, List.length_map, List.length_take, d.digits.property, d'.digits.property, Nat.min_eq_left hcap, Nat.min_eq_left hcap'] using hrecord rw [hrecordVal] have hpow : (2 : Real) ^ shift.val = 8 := by rw [hshift3]; norm_num rw [hpow] nlinarith have houtHeadLt : (outHead : Real) < 2 := lt_of_le_of_lt houtValLower hVout have houtHeadLtNat : outHead < 2 := by exact_mod_cast houtHeadLt have houtHeadOne : outHead = 1 := by omega exact ⟨outTail, by rw [houtshape, houtHeadOne]⟩ have hheadOneRecovery : d.decimal_point.val = 1 -> (exists tail, (d.digits.val.take d.num_digits.val).map (fun b => b.val) = 1 :: tail) -> d'.decimal_point.val = 0 := by intro hp hin have hn1 : n.val = 1 := by omega have hshift3 : shift.val = 3 := by simpa [shift, hn1] rcases hsmallPoint (by rw [hp]; norm_num) with hzero | hone · exact hzero · have hread1 : read.val = 1 := by rw [hpoint'] at hone; omega exfalso have hnumPos : 1 <= d.num_digits.val := by have hh := hlen simp at hh omega have hIpos : 0 < ((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 := by rw [hshape] simp only [List.foldl_cons, Nat.mul_zero, Nat.zero_add] have positive (ys : List Nat) (a : Nat) (ha : 0 < a) : 0 < ys.foldl (fun n z => 10 * n + z) a := by induction ys generalizing a with | nil => simpa | cons z zs ih => simp only [List.foldl_cons]; apply ih; omega exact positive tail head hhead have hpref := P472_T1_DecimalRightShiftPrefixLoopSemantics d d shift read acc false hshift hIpos hdigit hloop0 dsimp only at hpref rcases hpref with ⟨_, _, _, _, _, hphase⟩ rcases hphase with ⟨hreadCount, _, hacc⟩ | hmore · have haccOne : acc.val = 1 := by rcases hin with ⟨intail, hin⟩ have hfirst : (d.digits.val.take d.num_digits.val).map (fun b => b.val) = 1 :: intail := hin have hfirst' : List.take d.num_digits.val (d.digits.val.map (fun b => b.val)) = 1 :: intail := by simpa [List.map_take] using hfirst have htakeOne : List.take 1 (d.digits.val.map (fun b => b.val)) = [1] := by have hh := congrArg (List.take 1) hfirst' simpa [List.take_take, Nat.min_eq_left hnumPos] using hh rw [hread1] at hacc rw [htakeOne] at hacc simpa using hacc have hpow : 2 ^ shift.val = 8 := by rw [hshift3]; norm_num rw [haccOne, hpow] at haccLo omega · rcases hmore with ⟨hcountlt, _, _, _⟩ omega let shiftI : Std.I32 := UScalar.hcast .I32 shift have hshiftInt : (shift.val : Int) <= 60 := by exact_mod_cast hshift have hshiftCastBounds : (shift.val : Int) <= IScalar.max .I32 := by rw [IScalar.max_I32_eq] omega have hshiftIVal : shiftI.val = (shift.val : Int) := by have hs := UScalar.hcast_inBounds_spec .I32 shift hshiftCastBounds simp only [lift, WP.spec_ok] at hs exact hs have hcastShift : lift (UScalar.hcast .I32 shift) = ok shiftI := by obtain ⟨v, hv, hvval⟩ := Aeneas.Std.WP.spec_imp_exists (UScalar.hcast_inBounds_spec .I32 shift hshiftCastBounds) rw [hv] congr 1 apply IScalar.eq_of_val_eq have hvval' : v.val = (shift.val : Int) := by simpa [WP.spec_ok] using hvval change v.val = shiftI.val rw [hshiftIVal] exact hvval' have hsumBounds : IScalar.min .I32 <= exp.val + shiftI.val /\ exp.val + shiftI.val <= IScalar.max .I32 := by rw [IScalar.min_I32_eq, IScalar.max_I32_eq, hshiftIVal] constructor · omega · norm_num [IScalarTy.numBits, I32.numBits] omega obtain ⟨exp', hadd, haddVal⟩ := Aeneas.Std.WP.spec_imp_exists (IScalar.add_spec hsumBounds.1 hsumBounds.2) have hexpVal : exp'.val = exp.val + (shift.val : Int) := by rw [haddVal, hshiftIVal] have hnegRange : -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE = ok (-2047)#i32 := by unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE change IScalar.neg (2047#i32 : Std.I32) = _ unfold IScalar.neg IScalar.tryMk IScalar.tryMkOpt norm_num [IScalar.check_bounds, IScalarTy.numBits] have hnotReset : ¬ d'.decimal_point.val < -2047 := by rw [hpoint'] omega have hnotResetCmp : ¬ d'.decimal_point < (-2047)#i32 := by simpa only [IScalar.lt_equiv] using hnotReset have houter : 0 < d.decimal_point.val := by omega have houterCmp : d.decimal_point > 0#i32 := by simpa only [gt_iff_lt, IScalar.lt_equiv] using houter have hrecordEta : ({ num_digits := d.num_digits, decimal_point := d.decimal_point, truncated := d.truncated, digits := d.digits } : num.imp.dec2flt.decimal_seq.DecimalSeq) = d := by cases d rfl let dIn : num.imp.dec2flt.decimal_seq.DecimalSeq := { num_digits := d.num_digits, decimal_point := d.decimal_point, truncated := d.truncated, digits := d.digits } have hdIn : dIn = d := hrecordEta have hcallIn : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift dIn (match n.val with | 0 => 0#usize | 1 => 3#usize | 2 => 6#usize | 3 => 9#usize | 4 => 13#usize | 5 => 16#usize | 6 => 19#usize | 7 => 23#usize | 8 => 26#usize | 9 => 29#usize | 10 => 33#usize | 11 => 36#usize | 12 => 39#usize | 13 => 43#usize | 14 => 46#usize | 15 => 49#usize | 16 => 53#usize | 17 => 56#usize | 18 => 59#usize | _ => 60#usize) = ok d' := by rw [hdIn] change num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d' exact hcall have hcallActual : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift { num_digits := d.num_digits, decimal_point := d.decimal_point, truncated := d.truncated, digits := d.digits } (match n.val with | 0 => 0#usize | 1 => 3#usize | 2 => 6#usize | 3 => 9#usize | 4 => 13#usize | 5 => 16#usize | 6 => 19#usize | 7 => 23#usize | 8 => 26#usize | 9 => 29#usize | 10 => 33#usize | 11 => 36#usize | 12 => 39#usize | 13 => 43#usize | 14 => 46#usize | 15 => 49#usize | 16 => 53#usize | 17 => 56#usize | 18 => 59#usize | _ => 60#usize) = ok d' := by change num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d' exact hcall have hcastActual : lift (UScalar.hcast .I32 (match n.val with | 0 => 0#usize | 1 => 3#usize | 2 => 6#usize | 3 => 9#usize | 4 => 13#usize | 5 => 16#usize | 6 => 19#usize | 7 => 23#usize | 8 => 26#usize | 9 => 29#usize | 10 => 33#usize | 11 => 36#usize | 12 => 39#usize | 13 => 43#usize | 14 => 46#usize | 15 => 49#usize | 16 => 53#usize | 17 => 56#usize | 18 => 59#usize | _ => 60#usize)) = ok shiftI := by simpa [shift] using hcastShift have hbody : num.imp.dec2flt.slow.parse_long_mantissa_loop0.body F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 { m := 0#u64, p_biased := 0#i32 } d.num_digits d.decimal_point d.truncated d.digits exp none = ok (cont (d'.num_digits, d'.decimal_point, d'.truncated, d'.digits, exp', none)) := by cases d with | mk numDigits point truncated digits => have hcallMatch : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift { num_digits := numDigits, decimal_point := point, truncated := truncated, digits := digits } (match n.val with | 0 => 0#usize | 1 => 3#usize | 2 => 6#usize | 3 => 9#usize | 4 => 13#usize | 5 => 16#usize | 6 => 19#usize | 7 => 23#usize | 8 => 26#usize | 9 => 29#usize | 10 => 33#usize | 11 => 36#usize | 12 => 39#usize | 13 => 43#usize | 14 => 46#usize | 15 => 49#usize | 16 => 53#usize | 17 => 56#usize | 18 => 59#usize | _ => 60#usize) = ok d' := by simpa only [shift] using hcall unfold num.imp.dec2flt.slow.parse_long_mantissa_loop0.body simp only [if_pos houterCmp, core.option.Option.is_none] have hnone : (none : Option num.imp.dec2flt.common.BiasedFp).isNone = true := rfl simp only [hnone, if_true] rw [hncast] simp only [bind_tc_ok] rw [hselector] simp only [bind_tc_ok] change Aeneas.Std.bind (num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift ({ num_digits := numDigits, decimal_point := point, truncated := truncated, digits := digits } : num.imp.dec2flt.decimal_seq.DecimalSeq) (match n.val with | 0 => 0#usize | 1 => 3#usize | 2 => 6#usize | 3 => 9#usize | 4 => 13#usize | 5 => 16#usize | 6 => 19#usize | 7 => 23#usize | 8 => 26#usize | 9 => 29#usize | 10 => 33#usize | 11 => 36#usize | 12 => 39#usize | 13 => 43#usize | 14 => 46#usize | 15 => 49#usize | 16 => 53#usize | 17 => 56#usize | 18 => 59#usize | _ => 60#usize)) (fun (d : num.imp.dec2flt.decimal_seq.DecimalSeq) => do let i2 ← -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE if d.decimal_point < i2 then ok (cont (d.num_digits, d.decimal_point, d.truncated, d.digits, exp, some ({ m := 0#u64, p_biased := 0#i32 } : num.imp.dec2flt.common.BiasedFp))) else do let i3 ← lift (UScalar.hcast .I32 (match n.val with | 0 => 0#usize | 1 => 3#usize | 2 => 6#usize | 3 => 9#usize | 4 => 13#usize | 5 => 16#usize | 6 => 19#usize | 7 => 23#usize | 8 => 26#usize | 9 => 29#usize | 10 => 33#usize | 11 => 36#usize | 12 => 39#usize | 13 => 43#usize | 14 => 46#usize | 15 => 49#usize | 16 => 53#usize | 17 => 56#usize | 18 => 59#usize | _ => 60#usize)) let exp21 ← exp + i3 ok (cont (d.num_digits, d.decimal_point, d.truncated, d.digits, exp21, none))) = _ rw [hcallMatch] simp only [Aeneas.Std.bind, bind_tc_ok] rw [hnegRange] simp only [bind_tc_ok, hnotResetCmp, if_false] rw [hcastActual] simp only [bind_tc_ok] rw [hadd] rfl exact ⟨d', shift, exp', hbody, hcall, hshift, hexpVal, hlargePoint, hsmallPoint, hcap', hdigit', hhead', htrim, ⟨eta', u', hX', hY'', heta', hetau'', hsticky'⟩, hstallHead, hheadOneRecovery⟩ end dec2flt_model