Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lemma
usize, and the corresponding access to the extracted
power-of-five table all succeed. Writing the accessed pair as (a_q,b_q)
and D_q=a_q2^{64}+b_q, one has
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.DecimalGoalVocabularyDefault
import Tablet.IntegerPowerFiniteCertificate
import Tablet.IntegerPowerRealBridge
import Tablet.num_imp_dec2flt_lemire_power
import Tablet.num_imp_dec2flt_table_POWER_OF_FIVE_128
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: IntegerPowerTableCertificate]
theorem IntegerPowerTableCertificate :
∀ q : Std.I64, -342 ≤ q.val → q.val ≤ 308 →
∃ (q32 p : Std.I32) (delta : Std.I64) (index : Std.Usize)
(a b : Std.U64),
lift (IScalar.cast .I32 q) = ok q32 ∧
num.imp.dec2flt.lemire.power q32 = ok p ∧
p.val = 217706 * q.val / 65536 + 63 ∧
q - (-342)#i64 = ok delta ∧
lift (IScalar.hcast .Usize delta) = ok index ∧
Array.index_usize num.imp.dec2flt.table.POWER_OF_FIVE_128 index =
ok (a, b) ∧
let e : Int := 217706 * q.val / 65536 - q.val
let D : Nat := a.val * 2 ^ 64 + b.val
let T : Real := (2 : Real) ^ (127 - e) * (5 : Real) ^ q.val
(((2 : Real) ^ (127 : Nat) ≤ T ∧
T < (2 : Real) ^ (128 : Nat)) ∧
(q.val < 0 →
∃ n z : Nat,
q.val = -(n : Int) ∧
1 ≤ n ∧
1 ≤ z ∧
(2 : Nat) ^ (z - 1) < 5 ^ n ∧
5 ^ n < 2 ^ z ∧
e = -(z : Int) ∧
T = (2 : Real) ^ (z + 127) / (5 : Real) ^ n) ∧
((0 ≤ q.val ∧ q.val ≤ 55) → (D : Real) = T) ∧
((0 ≤ q.val ∧ q.val ≤ 23) → b.val = 0) ∧
((q.val < -27 ∨ 0 ≤ q.val) →
(D : Real) ≤ T ∧ T < (D : Real) + 1) ∧
((-27 ≤ q.val ∧ q.val < 0) →
(D : Real) - 1 < T ∧ T < D)) := 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 cast, and access to the length-651 table all succeed.
This establishes every success equation, the normalization and negative-index
representation, both small-range exactness clauses, and both directed
intervals in the statement.Lean proof
obtain ⟨hopcert, hcert, hsmallE⟩ := IntegerPowerFiniteCertificate
intro q hlow hhigh
have hc := IScalar.cast_inBounds_spec .I32 q (by scalar_tac)
obtain ⟨q32, hq32, hq32val⟩ := Aeneas.Std.WP.spec_imp_exists hc
have hdwp := IScalar.sub_spec (x := q) (y := (-342)#i64)
(by scalar_tac) (by scalar_tac)
obtain ⟨delta, hdelta, hdval⟩ := Aeneas.Std.WP.spec_imp_exists hdwp
have hdval' : delta.val = q.val + 342 := by simpa using hdval
have hiwp := IScalar.hcast_inBounds_spec .Usize delta (by
rw [hdval']
constructor <;> scalar_tac)
obtain ⟨index, hindex, hival⟩ := Aeneas.Std.WP.spec_imp_exists hiwp
let i : Fin 651 := ⟨(q.val + 342).toNat, by omega⟩
let ab := num.imp.dec2flt.table.POWER_OF_FIVE_128.val.get
⟨i.val, by simpa using i.isLt⟩
have hqeq : (i.val : Int) - 342 = q.val := by
change (((q.val + 342).toNat : Nat) : Int) - 342 = q.val
rw [Int.toNat_of_nonneg (by omega)]
omega
have hop := hopcert i
dsimp only at hop
let q32c : Std.I32 := IScalar.ofInt ((i.val : Int) - 342) (by
change -(2 : Int) ^ 31 ≤ (i.val : Int) - 342 ∧
(i.val : Int) - 342 ≤ (2 : Int) ^ 31 - 1
omega)
have hq32cval : q32c.val = q.val := by
rw [← hqeq]
simpa [q32c, IScalarTy.numBits] using
(IScalar.ofInt_val_eq (ty := .I32) (x := (i.val : Int) - 342) (by omega))
have hq32ceq : q32c = q32 := by
apply IScalar.eq_of_val_eq
omega
change (match num.imp.dec2flt.lemire.power q32c with
| ok y => decide (y.val = 217706 * ((i.val : Int) - 342) / 65536 + 63)
| fail _ => false
| div => false) = true at hop
rw [hqeq, hq32ceq] at hop
have hpExists : ∃ p : Std.I32,
num.imp.dec2flt.lemire.power q32 = ok p ∧
p.val = 217706 * q.val / 65536 + 63 := by
generalize hpdef : num.imp.dec2flt.lemire.power q32 = pres at hop
cases pres with
| fail err => simp at hop
| div => simp at hop
| ok p =>
simp at hop
exact ⟨p, rfl, hop⟩
obtain ⟨p, hp, hpval⟩ := hpExists
have hiNat : index.val = i.val := by
change index.val = (q.val + 342).toNat
rw [← hdval', ← hival]
simp
have htable : Array.index_usize
num.imp.dec2flt.table.POWER_OF_FIVE_128 index = ok ab := by
simp only [Array.index_usize]
simp [ab, hiNat]
have hrow := hcert i
dsimp only at hrow
rw [hqeq] at hrow
have hsmallERow := hsmallE i
dsimp only at hsmallERow
rw [hqeq] at hsmallERow
refine ⟨q32, p, delta, index, ab.1, ab.2, hq32, hp, hpval,
hdelta, hindex, htable, ?_⟩
exact IntegerPowerRealBridge q.val
(217706 * q.val / 65536 - q.val)
(ab.1.val * 2 ^ 64 + ab.2.val) ab.2.val
hrow.1 hrow.2 hsmallERow
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.IntegerPowerFiniteCertificate
import Tablet.IntegerPowerRealBridge
import Tablet.num_imp_dec2flt_lemire_power
import Tablet.num_imp_dec2flt_table_POWER_OF_FIVE_128
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: IntegerPowerTableCertificate]
theorem IntegerPowerTableCertificate :
∀ q : Std.I64, -342 ≤ q.val → q.val ≤ 308 →
∃ (q32 p : Std.I32) (delta : Std.I64) (index : Std.Usize)
(a b : Std.U64),
lift (IScalar.cast .I32 q) = ok q32 ∧
num.imp.dec2flt.lemire.power q32 = ok p ∧
p.val = 217706 * q.val / 65536 + 63 ∧
q - (-342)#i64 = ok delta ∧
lift (IScalar.hcast .Usize delta) = ok index ∧
Array.index_usize num.imp.dec2flt.table.POWER_OF_FIVE_128 index =
ok (a, b) ∧
let e : Int := 217706 * q.val / 65536 - q.val
let D : Nat := a.val * 2 ^ 64 + b.val
let T : Real := (2 : Real) ^ (127 - e) * (5 : Real) ^ q.val
(((2 : Real) ^ (127 : Nat) ≤ T ∧
T < (2 : Real) ^ (128 : Nat)) ∧
(q.val < 0 →
∃ n z : Nat,
q.val = -(n : Int) ∧
1 ≤ n ∧
1 ≤ z ∧
(2 : Nat) ^ (z - 1) < 5 ^ n ∧
5 ^ n < 2 ^ z ∧
e = -(z : Int) ∧
T = (2 : Real) ^ (z + 127) / (5 : Real) ^ n) ∧
((0 ≤ q.val ∧ q.val ≤ 55) → (D : Real) = T) ∧
((0 ≤ q.val ∧ q.val ≤ 23) → b.val = 0) ∧
((q.val < -27 ∨ 0 ≤ q.val) →
(D : Real) ≤ T ∧ T < (D : Real) + 1) ∧
((-27 ≤ q.val ∧ q.val < 0) →
(D : Real) - 1 < T ∧ T < D)) := by
-- BODY
obtain ⟨hopcert, hcert, hsmallE⟩ := IntegerPowerFiniteCertificate
intro q hlow hhigh
have hc := IScalar.cast_inBounds_spec .I32 q (by scalar_tac)
obtain ⟨q32, hq32, hq32val⟩ := Aeneas.Std.WP.spec_imp_exists hc
have hdwp := IScalar.sub_spec (x := q) (y := (-342)#i64)
(by scalar_tac) (by scalar_tac)
obtain ⟨delta, hdelta, hdval⟩ := Aeneas.Std.WP.spec_imp_exists hdwp
have hdval' : delta.val = q.val + 342 := by simpa using hdval
have hiwp := IScalar.hcast_inBounds_spec .Usize delta (by
rw [hdval']
constructor <;> scalar_tac)
obtain ⟨index, hindex, hival⟩ := Aeneas.Std.WP.spec_imp_exists hiwp
let i : Fin 651 := ⟨(q.val + 342).toNat, by omega⟩
let ab := num.imp.dec2flt.table.POWER_OF_FIVE_128.val.get
⟨i.val, by simpa using i.isLt⟩
have hqeq : (i.val : Int) - 342 = q.val := by
change (((q.val + 342).toNat : Nat) : Int) - 342 = q.val
rw [Int.toNat_of_nonneg (by omega)]
omega
have hop := hopcert i
dsimp only at hop
let q32c : Std.I32 := IScalar.ofInt ((i.val : Int) - 342) (by
change -(2 : Int) ^ 31 ≤ (i.val : Int) - 342 ∧
(i.val : Int) - 342 ≤ (2 : Int) ^ 31 - 1
omega)
have hq32cval : q32c.val = q.val := by
rw [← hqeq]
simpa [q32c, IScalarTy.numBits] using
(IScalar.ofInt_val_eq (ty := .I32) (x := (i.val : Int) - 342) (by omega))
have hq32ceq : q32c = q32 := by
apply IScalar.eq_of_val_eq
omega
change (match num.imp.dec2flt.lemire.power q32c with
| ok y => decide (y.val = 217706 * ((i.val : Int) - 342) / 65536 + 63)
| fail _ => false
| div => false) = true at hop
rw [hqeq, hq32ceq] at hop
have hpExists : ∃ p : Std.I32,
num.imp.dec2flt.lemire.power q32 = ok p ∧
p.val = 217706 * q.val / 65536 + 63 := by
generalize hpdef : num.imp.dec2flt.lemire.power q32 = pres at hop
cases pres with
| fail err => simp at hop
| div => simp at hop
| ok p =>
simp at hop
exact ⟨p, rfl, hop⟩
obtain ⟨p, hp, hpval⟩ := hpExists
have hiNat : index.val = i.val := by
change index.val = (q.val + 342).toNat
rw [← hdval', ← hival]
simp
have htable : Array.index_usize
num.imp.dec2flt.table.POWER_OF_FIVE_128 index = ok ab := by
simp only [Array.index_usize]
simp [ab, hiNat]
have hrow := hcert i
dsimp only at hrow
rw [hqeq] at hrow
have hsmallERow := hsmallE i
dsimp only at hsmallERow
rw [hqeq] at hsmallERow
refine ⟨q32, p, delta, index, ab.1, ab.2, hq32, hp, hpval,
hdelta, hindex, htable, ?_⟩
exact IntegerPowerRealBridge q.val
(217706 * q.val / 65536 - q.val)
(ab.1.val * 2 ^ 64 + ab.2.val) ab.2.val
hrow.1 hrow.2 hsmallERow
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Inspect related source (46)
- power · dec2flt/lemire.rs:121 Program Rust
- POWER_OF_FIVE_128 · dec2flt/table.rs:19 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
More program dependencies (13)
- 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)
- 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
Technical checking records
Local closure summary
{
"node": "IntegerPowerTableCertificate",
"closure_version": "patch_c_v1",
"active_decl_hash": "92c4254586c5bcc8b7ed62cb52b5badaee3ceaa51000a32fff02a5dee727a82c",
"active_statement_hash": "9c8b76a7277e08cc8130b24b893616acee55990c411f0a653386e372acd20694",
"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": "worker-result-local-closure-issuance-cycle-145",
"boundary_theorems": {},
"strict_theorem_deps": {
"IntegerPowerFiniteCertificate": "51241f81a8dc22e8",
"IntegerPowerRealBridge": "1e9cbf5ae71e7110"
},
"strict_definition_deps": {
"IntegerPowerFiniteCertificate": "7b88d77bb302cd1b",
"num_imp_dec2flt_lemire_power": "56b7c3bd69ca3c6a",
"num_imp_dec2flt_table_POWER_OF_FIVE_128": "bdd28e83b60fa362"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:89c2d4b18b657103cfc3f06dacad11697252116d4ff2a06f230f57a6bdfb0c41",
"current_fingerprint": "sound-v2:89c2d4b18b657103cfc3f06dacad11697252116d4ff2a06f230f57a6bdfb0c41",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}