import Tablet.Binary64ModelDefault import Tablet.ModelF64FromU64 import Tablet.ModelF64FromBits import Tablet.ModelF64Mul import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64 import Tablet.F64_Insts_CoreOpsArithMulF64F64 import Tablet.F64_Insts_CoreOpsArithDivF64F64 import Tablet.F64_Insts_CoreOpsArithNegF64 import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS import Tablet.num_imp_dec2flt_Lemire_MIN_EXPONENT_FAST_PATH_default import Tablet.num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path open Aeneas Aeneas.Std Result ControlFlow Error set_option autoImplicit false set_option maxHeartbeats 2000000 set_option maxRecDepth 100000 namespace dec2flt_model -- [TABLET NODE: ParserExactRoundingFastPath] theorem ParserExactRoundingFastPath : num.imp.dec2flt.decimal.Decimal.try_fast_path F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64 F64.Insts.CoreOpsArithNegF64 { exponent := 0#i64, mantissa := 1#u64, negative := false, many_digits := false } = ok (some (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) := by -- BODY have one_scan : List.foldl (fun (old : Nat) (i : Nat) => if (i : Int) + 1 <= 1023 then i + 1 else old) 1 (List.range 2046) = 1023 := by set_option maxRecDepth 100000 in decide +kernel have hfrom : ModelF64FromU64 1#u64 = ok ⟨BitVec.ofNat 64 4607182418800017408⟩ := by set_option maxRecDepth 100000 in norm_num [ModelF64FromU64, Binary64ModelDefault] rw [one_scan] have hoverflow : ¬ (2 ^ 1024 : Rat) ≤ 1 + 2 ^ 970 := by set_option exponentiation.threshold 2048 in norm_num rw [if_neg hoverflow] split · rename_i htiny set_option exponentiation.threshold 2048 in norm_num at htiny · norm_num have hpow : F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path 0#usize = ok ⟨BitVec.ofNat 64 4607182418800017408⟩ := by unfold F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path have hand : lift (0#usize &&& 31#usize) = ok 0#usize := by rfl rw [hand] change ModelF64FromBits 4607182418800017408#u64 = _ rfl have hmul : ModelF64Mul ⟨BitVec.ofNat 64 4607182418800017408⟩ ⟨BitVec.ofNat 64 4607182418800017408⟩ = ok ⟨BitVec.ofNat 64 4607182418800017408⟩ := by have honeval : (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64).val = 4607182418800017408 := by rfl set_option maxRecDepth 100000 in norm_num [ModelF64Mul, Binary64ModelDefault, honeval] rw [one_scan] have hoverflow : ¬ (2 ^ 1024 : Rat) ≤ 1 + 2 ^ 970 := by set_option exponentiation.threshold 2048 in norm_num rw [if_neg hoverflow] split · rename_i htiny set_option exponentiation.threshold 2048 in norm_num at htiny · norm_num have hmax22 : F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH = 22#i64 := by rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH.eq_def] have hmax37 : F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_DISGUISED_FAST_PATH = 37#i64 := by rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_DISGUISED_FAST_PATH.eq_def] have hmaxMantissa : num.imp.dec2flt.Lemire.MAX_MANTISSA_FAST_PATH.default F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 = ok 9007199254740992#u64 := by unfold num.imp.dec2flt.Lemire.MAX_MANTISSA_FAST_PATH.default change (do let i ← F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS 1#u64 <<< i) = ok 9007199254740992#u64 rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] rfl have hmin : num.imp.dec2flt.Lemire.MIN_EXPONENT_FAST_PATH.default F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 = ok (-22)#i64 := by unfold num.imp.dec2flt.Lemire.MIN_EXPONENT_FAST_PATH.default change (do let i ← ok F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH HNeg.hNeg i) = ok (-22)#i64 rw [hmax22] rfl have hminField : (F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 : num.imp.dec2flt.Lemire F64 Std.U64).MIN_EXPONENT_FAST_PATH = ok (-22)#i64 := by rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def] change (do let i ← ok F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH HNeg.hNeg i) = ok (-22)#i64 rw [hmax22] rfl have hmax37Field : (F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 : num.imp.dec2flt.Lemire F64 Std.U64).MAX_EXPONENT_DISGUISED_FAST_PATH = ok 37#i64 := by rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def, hmax37] have hmaxMantissaField : (F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 : num.imp.dec2flt.Lemire F64 Std.U64).MAX_MANTISSA_FAST_PATH = ok 9007199254740992#u64 := by rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def] change (do let i ← F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS 1#u64 <<< i) = ok 9007199254740992#u64 rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] rfl have hcan : num.imp.dec2flt.decimal.Decimal.can_use_fast_path F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 { exponent := 0#i64, mantissa := 1#u64, negative := false, many_digits := false } = ok true := by unfold num.imp.dec2flt.decimal.Decimal.can_use_fast_path rw [hminField, hmax37Field, hmaxMantissaField] rfl have hmax22Field : (F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 : num.imp.dec2flt.Lemire F64 Std.U64).MAX_EXPONENT_FAST_PATH = ok 22#i64 := by rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def, hmax22] have hfromField : (F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 : num.imp.dec2flt.Lemire F64 Std.U64).from_u64 1#u64 = ok (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) := by rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def] change ModelF64FromU64 1#u64 = _ exact hfrom have hmulField : F64.Insts.CoreOpsArithMulF64F64.mul ⟨BitVec.ofNat 64 4607182418800017408⟩ ⟨BitVec.ofNat 64 4607182418800017408⟩ = ok (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) := by change ModelF64Mul _ _ = _ exact hmul unfold num.imp.dec2flt.decimal.Decimal.try_fast_path rw [show num.imp.dec2flt.fpu.fpu_precision.set_precision F64 = ok () by rfl] rw [hcan, hmax22Field, hfromField] norm_num rw [show lift (IScalar.hcast .Usize 0#i64) = ok 0#usize by rfl] change (do let x ← F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.pow10_fast_path 0#usize let t ← F64.Insts.CoreOpsArithMulF64F64.mul (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) x ok (some t)) = ok (some (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) rw [hpow] change (do let t ← F64.Insts.CoreOpsArithMulF64F64.mul (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64) ok (some t)) = ok (some (⟨BitVec.ofNat 64 4607182418800017408⟩ : F64)) rw [hmulField] rfl end dec2flt_model