Definition and explanation
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lean definition
This module includes declarations linked to the Aeneas extraction. The source view pairs each matched declaration with its Rust input.
import Tablet.Assumptions
import Tablet.Preamble
import Tablet.num_imp_dec2flt_common_BiasedFp
import Tablet.num_imp_dec2flt_common_BiasedFp_zero_pow2
import Tablet.num_imp_dec2flt_lemire_compute_product_approx
import Tablet.num_imp_dec2flt_lemire_power
import Tablet.num_imp_traits_Float
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
noncomputable section
namespace dec2flt_model
-- [TABLET NODE: num_imp_dec2flt_lemire_compute_float]
/-- [dec2flt_model::num::imp::dec2flt::lemire::compute_float]:
Source: 'num/imp/../../dec2flt/lemire.rs', lines 26:0-114:1
Visibility: public -/
def num.imp.dec2flt.lemire.compute_float
{F : Type} {Clause0_Int : Type} (traitsFloatInst : num.imp.traits.Float F
Clause0_Int) (q : Std.I64) (w : Std.U64) :
Result num.imp.dec2flt.common.BiasedFp
:=
-- BODY
do
let fp_zero ← num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32
let i ← traitsFloatInst.INFINITE_POWER
let fp_inf ← num.imp.dec2flt.common.BiasedFp.zero_pow2 i
let fp_error ← num.imp.dec2flt.common.BiasedFp.zero_pow2 (-1)#i32
if w = 0#u64
then ok fp_zero
else
let i1 ← traitsFloatInst.SMALLEST_POWER_OF_TEN
let i2 ← lift (IScalar.cast .I64 i1)
if q < i2
then ok fp_zero
else
let i3 ← traitsFloatInst.LARGEST_POWER_OF_TEN
let i4 ← lift (IScalar.cast .I64 i3)
if q > i4
then ok fp_inf
else
let lz ← lift (core.num.U64.leading_zeros w)
let w1 ← w <<< lz
let i5 ← traitsFloatInst.SIG_BITS
let i6 ← lift (UScalar.cast .Usize i5)
let i7 ← i6 + 3#usize
let (lo, hi) ← num.imp.dec2flt.lemire.compute_product_approx q w1 i7
if lo = 18446744073709551615#u64
then
let inside_safe_exponent ←
if q >= (-27)#i64
then ok (q <= 55#i64)
else ok false
if inside_safe_exponent
then
let i8 ← hi >>> 63#i32
let upperbit ← lift (UScalar.hcast .I32 i8)
let i9 ← upperbit + 64#i32
let i10 ← lift (UScalar.hcast .I32 i5)
let i11 ← i9 - i10
let i12 ← i11 - 3#i32
let mantissa ← hi >>> i12
let i13 ← lift (IScalar.cast .I32 q)
let i14 ← num.imp.dec2flt.lemire.power i13
let i15 ← i14 + upperbit
let i16 ← lift (UScalar.hcast .I32 lz)
let i17 ← i15 - i16
let i18 ← traitsFloatInst.EXP_MIN
let i19 ← i17 - i18
let power2 ← i19 + 1#i32
if power2 <= 0#i32
then
let i20 ← -. power2
let i21 ← i20 + 1#i32
if i21 >= 64#i32
then ok fp_zero
else
let i22 ← i20 + 1#i32
let mantissa1 ← mantissa >>> i22
let i23 ← lift (mantissa1 &&& 1#u64)
let mantissa2 ← mantissa1 + i23
let mantissa3 ← mantissa2 >>> 1#i32
let i24 ← 1#u64 <<< i5
let power21 ←
lift (IScalar.cast_fromBool .I32 (mantissa3 >= i24))
ok { m := mantissa3, p_biased := power21 }
else
let mantissa1 ←
if lo <= 1#u64
then
do
let i20 ← traitsFloatInst.MIN_EXPONENT_ROUND_TO_EVEN
let i21 ← lift (IScalar.cast .I64 i20)
if q >= i21
then
let i22 ← traitsFloatInst.MAX_EXPONENT_ROUND_TO_EVEN
let i23 ← lift (IScalar.cast .I64 i22)
if q <= i23
then
let i24 ← lift (mantissa &&& 3#u64)
if i24 = 1#u64
then
let i25 ← lift (UScalar.hcast .I32 i5)
let i26 ← i9 - i25
let i27 ← i26 - 3#i32
let i28 ← mantissa <<< i27
if i28 = hi
then let i29 ← lift (~~~ 1#u64)
ok (mantissa &&& i29)
else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
let i20 ← lift (mantissa1 &&& 1#u64)
let mantissa2 ← mantissa1 + i20
let mantissa3 ← mantissa2 >>> 1#i32
let i21 ← 2#u64 <<< i5
let (mantissa4, power21) ←
if mantissa3 >= i21
then
do
let mantissa5 ← 1#u64 <<< i5
let power22 ← power2 + 1#i32
ok (mantissa5, power22)
else ok (mantissa3, power2)
let i22 ← 1#u64 <<< i5
let i23 ← lift (~~~ i22)
let mantissa5 ← lift (mantissa4 &&& i23)
if power21 >= i
then ok fp_inf
else ok { m := mantissa5, p_biased := power21 }
else ok fp_error
else
let i8 ← hi >>> 63#i32
let upperbit ← lift (UScalar.hcast .I32 i8)
let i9 ← upperbit + 64#i32
let i10 ← lift (UScalar.hcast .I32 i5)
let i11 ← i9 - i10
let i12 ← i11 - 3#i32
let mantissa ← hi >>> i12
let i13 ← lift (IScalar.cast .I32 q)
let i14 ← num.imp.dec2flt.lemire.power i13
let i15 ← i14 + upperbit
let i16 ← lift (UScalar.hcast .I32 lz)
let i17 ← i15 - i16
let i18 ← traitsFloatInst.EXP_MIN
let i19 ← i17 - i18
let power2 ← i19 + 1#i32
if power2 <= 0#i32
then
let i20 ← -. power2
let i21 ← i20 + 1#i32
if i21 >= 64#i32
then ok fp_zero
else
let i22 ← i20 + 1#i32
let mantissa1 ← mantissa >>> i22
let i23 ← lift (mantissa1 &&& 1#u64)
let mantissa2 ← mantissa1 + i23
let mantissa3 ← mantissa2 >>> 1#i32
let i24 ← 1#u64 <<< i5
let power21 ←
lift (IScalar.cast_fromBool .I32 (mantissa3 >= i24))
ok { m := mantissa3, p_biased := power21 }
else
let mantissa1 ←
if lo <= 1#u64
then
do
let i20 ← traitsFloatInst.MIN_EXPONENT_ROUND_TO_EVEN
let i21 ← lift (IScalar.cast .I64 i20)
if q >= i21
then
let i22 ← traitsFloatInst.MAX_EXPONENT_ROUND_TO_EVEN
let i23 ← lift (IScalar.cast .I64 i22)
if q <= i23
then
let i24 ← lift (mantissa &&& 3#u64)
if i24 = 1#u64
then
let i25 ← lift (UScalar.hcast .I32 i5)
let i26 ← i9 - i25
let i27 ← i26 - 3#i32
let i28 ← mantissa <<< i27
if i28 = hi
then let i29 ← lift (~~~ 1#u64)
ok (mantissa &&& i29)
else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
let i20 ← lift (mantissa1 &&& 1#u64)
let mantissa2 ← mantissa1 + i20
let mantissa3 ← mantissa2 >>> 1#i32
let i21 ← 2#u64 <<< i5
let (mantissa4, power21) ←
if mantissa3 >= i21
then
do
let mantissa5 ← 1#u64 <<< i5
let power22 ← power2 + 1#i32
ok (mantissa5, power22)
else ok (mantissa3, power2)
let i22 ← 1#u64 <<< i5
let i23 ← lift (~~~ i22)
let mantissa5 ← lift (mantissa4 &&& i23)
if power21 >= i
then ok fp_inf
else ok { m := mantissa5, p_biased := power21 }
Preservation and explanation
Natural-language argument
The status above describes the Lean proof. Its explanatory prose may remain a sketch after that proof closes.
Explanatory prose status
Prose retained as authored. The explanatory prose is preserved as it stood when captured.
The authored explanation is included with the statement above.
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Used by
- AssemblyCorrespondence
- ClassificationDeterminism
- ClassificationSignificandDigit
- ClassificationTotality
- DispatchAbstractComposition Refutation
- DispatchComponentCompliance Refutation
All 50 entries
- AssemblyCorrespondence
- ClassificationDeterminism
- ClassificationSignificandDigit
- ClassificationTotality
- DispatchAbstractComposition Refutation
- DispatchComponentCompliance Refutation
- ExponentValueAgreement
- IntegerComputeFloatControlFlow
- IntegerCoreRounding
- IntegerCorrectOrDefer
- NativeCorrectOrDefer
- NumberHelperAcceptance Refutation
- NumberHelperRejection Refutation
- ParserAccumulatedRounding
- ParserComputeFloatExponentRange
- ParserComputeFloatInfinityMantissa
- ParserComputeFloatMantissaBound
- ParserEqualTargetRounding
- ParserInfinity
- ParserInvalidRejection Refutation
- ParserNanAcceptance
- ParserNonNanResults
- ParserNumericAcceptance Refutation
- ParserNumericLemirePairCertificate
- ParserNumericSign
- ParserNumericSlowPathOverflowWitness
- ParserReachableSlowMagnitudeRounding
- ParserSelectedExponent
- ParserSelectedMagnitudeSign
- ParserSelectedMantissaBound
- ParserSignedZero
- ParserSlowControlFlow
- ParserSlowReachableDecimalSeq
- ParserTotality Refutation
- RoundingDeterminism
- RoundingTotality
- SlowAccumulatedRounding Refutation
- SpecialHelperInfinity
- SpecialHelperNan
- SpecialHelperRejection
- TrellisConditional c0b964755dfba82a
- TrellisConditional c0b964755dfba82a ConditionInhabited
- TrellisConditional c0b964755dfba82a CounterexampleExcluded
- TrellisConditional d67247e4c442fb9d
- TrellisConditional d67247e4c442fb9d ConditionInhabited
- TrellisConditional d67247e4c442fb9d CounterexampleExcluded
- TrellisConditional dd99b8a97fe23649
- TrellisConditional dd99b8a97fe23649 ConditionInhabited
- TrellisConditional dd99b8a97fe23649 CounterexampleExcluded
- num imp dec2flt dec2flt with trace
Inspect related source (52)
- compute_float · dec2flt/lemire.rs:26 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- zero_pow2 · dec2flt/common.rs:62 Program Rust
More program dependencies (19)
- compute_product_approx · dec2flt/lemire.rs:134 Program Rust
- power · dec2flt/lemire.rs:121 Program Rust
- Float · traits.rs:74 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- full_multiplication · dec2flt/lemire.rs:126 Program Rust
- LARGEST_POWER_OF_FIVE · dec2flt/table.rs:10 Program Rust
- POWER_OF_FIVE_128 · dec2flt/table.rs:19 Program Rust
- SMALLEST_POWER_OF_FIVE · dec2flt/table.rs:9 Program Rust
- CastInto · traits.rs:18 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Int · traits.rs:27 Program Rust
Standard-library dependencies (30)
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
- INFINITY · core/src/num/f64.rs:512 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
- NAN · core/src/num/f64.rs:509 Rust library
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
- classify · core/src/num/f64.rs:782 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- as_bytes · core/src/str/mod.rs:498 Rust library
- FpCategory · core/src/num/mod.rs:1522 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
Related source and models come from the extraction records and declared dependencies.
Proof assumptions and review
Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.
Transitive assumptions
- Classical.choice
- Quot.sound
- propext
This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.
Helper theorems included
- core num FpCategory
- core ops arith Div
- core ops arith Mul
- core ops arith Neg
- core ops bit BitOr
- core ops bit Shl
All 19 entries
- core num FpCategory
- core ops arith Div
- core ops arith Mul
- core ops arith Neg
- core ops bit BitOr
- core ops bit Shl
- core ops bit Shr
- num imp dec2flt common BiasedFp
- num imp dec2flt common BiasedFp zero pow2
- num imp dec2flt lemire compute float
- num imp dec2flt lemire compute product approx
- num imp dec2flt lemire full multiplication
- num imp dec2flt lemire power
- num imp dec2flt table LARGEST POWER OF FIVE
- num imp dec2flt table POWER OF FIVE 128
- num imp dec2flt table SMALLEST POWER OF FIVE
- num imp traits CastInto
- num imp traits Float
- num imp traits Int
Technical checking records
Local closure summary
{
"node": "num_imp_dec2flt_lemire_compute_float",
"closure_version": "patch_c_v1",
"active_decl_hash": "deeba6f82a9820bbff1d121fe0a80763b843aefcf0781b716671c2133d31fd05",
"active_statement_hash": "",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"propext"
],
"toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
"lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
"checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
"approved_axioms_hash": "d5c04ffa333d9b33b238a527f5beaa2be82e021d3e9c0bbe01b1310280f7f55a",
"axcheck_status": "Agreed",
"accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-23",
"boundary_theorems": {},
"strict_theorem_deps": {},
"strict_definition_deps": {
"num_imp_dec2flt_common_BiasedFp": "c43614ff2149ecf2",
"num_imp_dec2flt_common_BiasedFp_zero_pow2": "0f99ae12c6707137",
"num_imp_dec2flt_lemire_compute_product_approx": "af91b9cbef7779f3",
"num_imp_dec2flt_lemire_power": "56b7c3bd69ca3c6a",
"num_imp_traits_Float": "441f66c67c37e04c"
}
}Prose assessment
{
"label": "Prose review has no verdict in this snapshot",
"assessment_status": null,
"fingerprint_relation": "unknown",
"assessment_fingerprint": null,
"current_fingerprint": null,
"superseded_for_theorem_closure": false
}Review verdicts
{}