Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Helper · Exact scientific prefix with one trailing byte
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.Assumptions
import Tablet.ModelSliceSplitFirst
import Tablet.ModelU8IsAsciiDigit
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperScientificTrailingByte]
theorem NumberHelperScientificTrailingByte
(suffix residual : Slice Std.U8)
(hsuffix : suffix.val =
[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8, 120#u8])
(hresidual : residual.val = [120#u8]) :
num.imp.dec2flt.parse.parse_scientific suffix =
ok (some ((-655359)#i64), residual) := by
Proof
Natural-language proof
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.
Proof
usize bound in Assumptions supplies both slice
carriers. Extensionality identifies the given slices with these concrete
carriers.usize and the seven-byte
post-sign slice.i64 range. Thus the extracted function returns precisely the
claimed option, exponent, and residual slice.Lean proof
have hbound :
[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8,
120#u8].length <= Usize.max := by
have h := Usize.max_succ_eq_pow
rw [Dec2Flt.configured_x86_64_numBits] at h
norm_num at h ⊢
omega
let concrete : Slice Std.U8 :=
⟨[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8,
120#u8], hbound⟩
have hsuffixEq : suffix = concrete :=
(Slice.eq_iff _ _).2 (by simpa [concrete] using hsuffix)
have hresBound : [120#u8].length <= Usize.max := by
have h := Usize.max_succ_eq_pow
rw [Dec2Flt.configured_x86_64_numBits] at h
norm_num at h ⊢
omega
let concreteResidual : Slice Std.U8 := ⟨[120#u8], hresBound⟩
have hresidualEq : residual = concreteResidual :=
(Slice.eq_iff _ _).2 (by simpa [concreteResidual] using hresidual)
rw [hsuffixEq, hresidualEq]
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize, concrete]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
(UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8)) = 6#i64 := by rfl
have first_sum2 :
(0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8)) = ok 6#i64 := by rfl
have first_sum3 :
(0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8)) = ok 6#i64 := by rfl
have first_count : (0#usize + 1#usize) = ok 1#usize := by
change UScalar.add (0#usize) (1#usize) = ok 1#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
(60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8)) = ok 65#i64 := by rfl
have second_count : (1#usize + 1#usize) = ok 2#usize := by
change UScalar.add (1#usize) (1#usize) = ok 2#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
(650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8)) = ok 655#i64 := by rfl
have third_count : (2#usize + 1#usize) = ok 3#usize := by
change UScalar.add (2#usize) (1#usize) = ok 3#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
(6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8)) = ok 6553#i64 := by rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize := by
change UScalar.add (3#usize) (1#usize) = ok 4#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
(65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8)) = ok 65535#i64 := by rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize := by
change UScalar.add (4#usize) (1#usize) = ok 5#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have sixth_product :
(10#i64 * 65535#i64) = ok 655350#i64 := by rfl
have sixth_sum :
(655350#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 57#u8 48#u8)) = ok 655359#i64 := by rfl
have sixth_count : (5#usize + 1#usize) = ok 6#usize := by
change UScalar.add (5#usize) (1#usize) = ok 6#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, first_product, first_sum, first_count, first_digit,
first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, sixth_product, sixth_sum, sixth_count]
rw [Aeneas.Std.loop.eq_1]
have neg_final :
IScalar.neg (655359#i64) = ok ((-655359)#i64) := by rfl
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop, HNeg.hNeg, IScalar.neg, neg_final,
IScalar.tryMk, IScalar.tryMkOpt, Result.ofOption,
IScalar.check_bounds, Dec2Flt.configured_x86_64_numBits,
concreteResidual]
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.Assumptions
import Tablet.ModelSliceSplitFirst
import Tablet.ModelU8IsAsciiDigit
import Tablet.num_imp_dec2flt_parse_parse_scientific
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: NumberHelperScientificTrailingByte]
theorem NumberHelperScientificTrailingByte
(suffix residual : Slice Std.U8)
(hsuffix : suffix.val =
[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8, 120#u8])
(hresidual : residual.val = [120#u8]) :
num.imp.dec2flt.parse.parse_scientific suffix =
ok (some ((-655359)#i64), residual) := by
-- BODY
have hbound :
[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8,
120#u8].length <= Usize.max := by
have h := Usize.max_succ_eq_pow
rw [Dec2Flt.configured_x86_64_numBits] at h
norm_num at h ⊢
omega
let concrete : Slice Std.U8 :=
⟨[45#u8, 54#u8, 53#u8, 53#u8, 51#u8, 53#u8, 57#u8,
120#u8], hbound⟩
have hsuffixEq : suffix = concrete :=
(Slice.eq_iff _ _).2 (by simpa [concrete] using hsuffix)
have hresBound : [120#u8].length <= Usize.max := by
have h := Usize.max_succ_eq_pow
rw [Dec2Flt.configured_x86_64_numBits] at h
norm_num at h ⊢
omega
let concreteResidual : Slice Std.U8 := ⟨[120#u8], hresBound⟩
have hresidualEq : residual = concreteResidual :=
(Slice.eq_iff _ _).2 (by simpa [concreteResidual] using hresidual)
rw [hsuffixEq, hresidualEq]
simp [num.imp.dec2flt.parse.parse_scientific,
core.slice.Slice.split_first, dec2flt_model.ModelSliceSplitFirst,
core.num.U8.is_ascii_digit, dec2flt_model.ModelU8IsAsciiDigit,
Slice.index_usize, concrete]
simp [num.imp.dec2flt.parse.parse_scientific_loop]
rw [Aeneas.Std.loop.eq_1]
have first_product : (10#i64 * 0#i64) = ok 0#i64 := by rfl
have first_sum : (0#i64 + 6#i64) = ok 6#i64 := by rfl
have first_digit :
(UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8)) = 6#i64 := by rfl
have first_sum2 :
(0#i64 + UScalar.hcast IScalarTy.I64
(core.num.U8.wrapping_sub 54#u8 48#u8)) = ok 6#i64 := by rfl
have first_sum3 :
(0#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 54#u8 48#u8)) = ok 6#i64 := by rfl
have first_count : (0#usize + 1#usize) = ok 1#usize := by
change UScalar.add (0#usize) (1#usize) = ok 1#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have second_product : (10#i64 * 6#i64) = ok 60#i64 := by rfl
have second_sum :
(60#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8)) = ok 65#i64 := by rfl
have second_count : (1#usize + 1#usize) = ok 2#usize := by
change UScalar.add (1#usize) (1#usize) = ok 2#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have third_product : (10#i64 * 65#i64) = ok 650#i64 := by rfl
have third_sum :
(650#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8)) = ok 655#i64 := by rfl
have third_count : (2#usize + 1#usize) = ok 3#usize := by
change UScalar.add (2#usize) (1#usize) = ok 3#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have fourth_product : (10#i64 * 655#i64) = ok 6550#i64 := by rfl
have fourth_sum :
(6550#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 51#u8 48#u8)) = ok 6553#i64 := by rfl
have fourth_count : (3#usize + 1#usize) = ok 4#usize := by
change UScalar.add (3#usize) (1#usize) = ok 4#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have fifth_product : (10#i64 * 6553#i64) = ok 65530#i64 := by rfl
have fifth_sum :
(65530#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 53#u8 48#u8)) = ok 65535#i64 := by rfl
have fifth_count : (4#usize + 1#usize) = ok 5#usize := by
change UScalar.add (4#usize) (1#usize) = ok 5#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
have sixth_product :
(10#i64 * 65535#i64) = ok 655350#i64 := by rfl
have sixth_sum :
(655350#i64 + UScalar.hcast IScalarTy.I64
(UScalar.wrapping_sub 57#u8 48#u8)) = ok 655359#i64 := by rfl
have sixth_count : (5#usize + 1#usize) = ok 6#usize := by
change UScalar.add (5#usize) (1#usize) = ok 6#usize
unfold UScalar.add UScalar.tryMk UScalar.tryMkOpt
simp [Result.ofOption, UScalar.check_bounds,
Dec2Flt.configured_x86_64_numBits]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, first_product, first_sum, first_count, first_digit,
first_sum2]
rw [first_sum3]
simp
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, second_product, second_sum, second_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, third_product, third_sum, third_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, fourth_product, fourth_sum, fourth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, fifth_product, fifth_sum, fifth_count]
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
Slice.index_usize, Aeneas.Std.lift, core.num.U8.wrapping_sub,
U8.size_eq, sixth_product, sixth_sum, sixth_count]
rw [Aeneas.Std.loop.eq_1]
have neg_final :
IScalar.neg (655359#i64) = ok ((-655359)#i64) := by rfl
simp [num.imp.dec2flt.parse.parse_scientific_loop.body,
core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.drop,
Slice.length, List.drop, HNeg.hNeg, IScalar.neg, neg_final,
IScalar.tryMk, IScalar.tryMkOpt, Result.ofOption,
IScalar.check_bounds, Dec2Flt.configured_x86_64_numBits,
concreteResidual]
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Inspect related source (47)
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:142 Program Rust
- body · dec2flt/parse.rs:142 Program Rust
More program dependencies (14)
- 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
- BiasedFp · dec2flt/common.rs:52 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- CastInto · traits.rs:18 Program Rust
- Float · traits.rs:74 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Int · traits.rs:27 Program Rust
Standard-library dependencies (30)
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- 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
- 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
- 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
- Dec2Flt.configured_x86_64_numBits
- 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
All 31 entries
- Binary64Model
- Binary64ModelDefault
- F64
- ModelF64Classify
- ModelF64Clone
- ModelF64Div
- ModelF64ExponentMask
- ModelF64FromBits
- ModelF64FromU64
- ModelF64Infinity
- ModelF64MantissaDigits
- ModelF64MantissaMask
- ModelF64Mul
- ModelF64Nan
- ModelF64Neg
- ModelF64NegInfinity
- ModelF64ToBits
- ModelOptionBranch
- ModelOptionFromResidual
- ModelSliceFirst
- ModelSliceSplitFirst
- ModelStrAsBytes
- ModelU64BitAnd
- ModelU64BitOr
- ModelU64Shl
- ModelU64Shr
- ModelU8IsAsciiDigit
- NumberHelperScientificTrailingByte
- Preamble
- core num FpCategory
- num imp dec2flt parse parse scientific
Technical checking records
Local closure summary
{
"node": "NumberHelperScientificTrailingByte",
"closure_version": "patch_c_v1",
"active_decl_hash": "3641756bc956a120af3bec8cc363aec4745d01acb69d16c8e018d3b8d1c4dc6c",
"active_statement_hash": "ab587051eef686008d2d429db6bb7275c66359a92ad213de32a683fec1e3cb96",
"kernel_axioms": [
"Classical.choice",
"Dec2Flt.configured_x86_64_numBits",
"Quot.sound",
"propext"
],
"toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
"lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
"checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
"approved_axioms_hash": "ab64d13f256386ee0e494a5abcc6a5db49512cf3d90bbdfcabd6327793a31f95",
"axcheck_status": "Agreed",
"accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-118",
"boundary_theorems": {},
"strict_theorem_deps": {
"ModelSliceSplitFirst": "f617ee05dd2925a9",
"num_imp_dec2flt_parse_parse_scientific": "ba81300a2601d639"
},
"strict_definition_deps": {
"ModelSliceSplitFirst": "4ed9c51a5bb9fb58",
"ModelU8IsAsciiDigit": "67d39fc6c37cfc41",
"Preamble": "956f3baee2191107",
"num_imp_dec2flt_parse_parse_scientific": "76b01b9377828a5f"
}
}Prose assessment
{
"label": "Lean proof closed; predictive prose review no longer required",
"assessment_status": null,
"fingerprint_relation": "unknown",
"assessment_fingerprint": null,
"current_fingerprint": "sound-v2:aa60b4710346fcd4d797dd88f8d602100a1603dc59e60ad5ae1ee742892e3a63",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}