Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Helper · Exact slow-normalization selector certificate
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: SlowShiftSelectorCertificate]
theorem SlowShiftSelectorCertificate :
forall {F Clause0_Int : Type}
(traitsFloatInst : num.imp.traits.Float F Clause0_Int)
(n : Std.Usize),
let k : 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
num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
traitsFloatInst () n = ok k /\
k.val <= 60 /\
(n.val = 0 -> k.val = 0) /\
(1 <= n.val -> n.val <= 18 ->
2 ^ k.val <= 10 ^ n.val /\ 10 ^ n.val < 2 ^ (k.val + 1)) /\
(19 <= n.val ->
k.val = 60 /\ 10 ^ 18 < 2 ^ 60 /\ 2 ^ 60 < 10 ^ 19) := 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
Lean proof
intro F Clause0_Int traitsFloatInst n
dsimp
simp only [num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call]
rw [num.imp.dec2flt.slow.parse_long_mantissa.NUM_POWERS.eq_def,
num.imp.dec2flt.slow.parse_long_mantissa.POWERS.eq_def,
num.imp.dec2flt.slow.parse_long_mantissa.MAX_SHIFT.eq_def]
by_cases small : n.val < 19
· have cases : n.val = 0 ∨ n.val = 1 ∨ n.val = 2 ∨ n.val = 3 ∨
n.val = 4 ∨ n.val = 5 ∨ n.val = 6 ∨ n.val = 7 ∨
n.val = 8 ∨ n.val = 9 ∨ n.val = 10 ∨ n.val = 11 ∨
n.val = 12 ∨ n.val = 13 ∨ n.val = 14 ∨ n.val = 15 ∨
n.val = 16 ∨ n.val = 17 ∨ n.val = 18 := by omega
rcases cases with h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h
all_goals
simp [Array.make, Array.index_usize, h]
apply UScalar.eq_imp
norm_num [UScalar.cast_val_eq]
· change ¬ n.val < 19 at small
have large : 19 ≤ n.val := by omega
have normal : n.val = (n.val - 19) + 19 := by omega
rw [normal]
have branch : ¬ n < 19#usize := by
change ¬ n.val < 19
omega
simp [Array.index_usize, branch]
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: SlowShiftSelectorCertificate]
theorem SlowShiftSelectorCertificate :
forall {F Clause0_Int : Type}
(traitsFloatInst : num.imp.traits.Float F Clause0_Int)
(n : Std.Usize),
let k : 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
num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
traitsFloatInst () n = ok k /\
k.val <= 60 /\
(n.val = 0 -> k.val = 0) /\
(1 <= n.val -> n.val <= 18 ->
2 ^ k.val <= 10 ^ n.val /\ 10 ^ n.val < 2 ^ (k.val + 1)) /\
(19 <= n.val ->
k.val = 60 /\ 10 ^ 18 < 2 ^ 60 /\ 2 ^ 60 < 10 ^ 19) := by
-- BODY
intro F Clause0_Int traitsFloatInst n
dsimp
simp only [num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call]
rw [num.imp.dec2flt.slow.parse_long_mantissa.NUM_POWERS.eq_def,
num.imp.dec2flt.slow.parse_long_mantissa.POWERS.eq_def,
num.imp.dec2flt.slow.parse_long_mantissa.MAX_SHIFT.eq_def]
by_cases small : n.val < 19
· have cases : n.val = 0 ∨ n.val = 1 ∨ n.val = 2 ∨ n.val = 3 ∨
n.val = 4 ∨ n.val = 5 ∨ n.val = 6 ∨ n.val = 7 ∨
n.val = 8 ∨ n.val = 9 ∨ n.val = 10 ∨ n.val = 11 ∨
n.val = 12 ∨ n.val = 13 ∨ n.val = 14 ∨ n.val = 15 ∨
n.val = 16 ∨ n.val = 17 ∨ n.val = 18 := by omega
rcases cases with h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h | h
all_goals
simp [Array.make, Array.index_usize, h]
apply UScalar.eq_imp
norm_num [UScalar.cast_val_eq]
· change ¬ n.val < 19 at small
have large : 19 ≤ n.val := by omega
have normal : n.val = (n.val - 19) + 19 := by omega
rw [normal]
have branch : ¬ n < 19#usize := by
change ¬ n.val < 19
omega
simp [Array.index_usize, branch]
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Inspect related source (49)
- MAX_SHIFT · dec2flt/slow.rs:28 Program Rust
- NUM_POWERS · dec2flt/slow.rs:29 Program Rust
- POWERS · dec2flt/slow.rs:30 Program Rust
More program dependencies (16)
- call · dec2flt/slow.rs:33 Program Rust
- closure · dec2flt/slow.rs:33 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
- 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
- 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
- SlowShiftSelectorCertificate
- core num FpCategory
- core ops arith Div
- core ops arith Mul
- core ops arith Neg
- core ops bit BitOr
All 16 entries
- SlowShiftSelectorCertificate
- 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 slow parse long mantissa MAX SHIFT
- num imp dec2flt slow parse long mantissa NUM POWERS
- num imp dec2flt slow parse long mantissa POWERS
- num imp dec2flt slow parse long mantissa closure
- num imp dec2flt slow parse long mantissa closure Insts CoreOpsFunctionFnTupleUsizeUsize call
- num imp traits CastInto
- num imp traits Float
- num imp traits Int
Technical checking records
Local closure summary
{
"node": "SlowShiftSelectorCertificate",
"closure_version": "patch_c_v1",
"active_decl_hash": "9e6d4c82a5eb91d468d39b4463365f8dab54444225403b39e77c2a2856a7227f",
"active_statement_hash": "e085991640570f4b373b00638f4f1921848962bc72785674a251bfdfce1fb56f",
"kernel_axioms": [
"Classical.choice",
"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": "sidecar-sc-20261005-102107-68fc93-SlowShiftSelectorCertificate-cycle-180",
"boundary_theorems": {},
"strict_theorem_deps": {
"num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT": "a858290d96a26cbd",
"num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS": "6886acab8f15b99e",
"num_imp_dec2flt_slow_parse_long_mantissa_POWERS": "6886acab8f15b99e",
"num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call": "6886acab8f15b99e"
},
"strict_definition_deps": {
"num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT": "32f403f33bee78a7",
"num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS": "5969fcec51b40196",
"num_imp_dec2flt_slow_parse_long_mantissa_POWERS": "3b3dc92c505e8aac",
"num_imp_dec2flt_slow_parse_long_mantissa_closure": "658171309af8dc0e",
"num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call": "7df8a2c8e3717790",
"num_imp_traits_Float": "94ab5f784cdf5db8"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:7d4db028086e35079ac301bcb208609dcb6a8f2ce1c5d106c9482ad04ed61866",
"current_fingerprint": "sound-v2:7d4db028086e35079ac301bcb208609dcb6a8f2ce1c5d106c9482ad04ed61866",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}