Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Theorem
DispatchContracts is empty.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.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := 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
roundsMagnitude would require
slow_spec clause says that f rounds the accumulated magnitude,
hence that f rounds 1. The slowTarget_spec clause says that the
same f rounds the exact magnitude 10^{589824}. The latter fact forces
f.\mathit{val}=I, while the former is impossible for a word equal to I by
the preceding paragraph. This contradiction eliminates the assumed package
C, proving that DispatchContracts is empty.Lean proof
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.DecimalLexeme
import Tablet.DispatchContracts
import Tablet.F64
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DispatchContractsUninhabited]
theorem DispatchContractsUninhabited : ¬ Nonempty DispatchContracts := by
-- BODY
let zeros : List Nat := List.replicate 65535 0
let fraction : List Nat := zeros ++ [1]
have zeros_eq : zeros = List.replicate 65535 0 := rfl
have fraction_eq : fraction = zeros ++ [1] := rfl
let witness : DecimalLexeme := {
leadingSign := none
integerDigits := [0]
fractionDigits := some fraction
exponent := some (false, none, [6, 5, 5, 3, 6, 0])
}
let witnessBytes : List Std.U8 :=
[48#u8, 46#u8] ++ List.replicate 65535 48#u8 ++
[49#u8, 101#u8, 54#u8, 53#u8, 53#u8, 51#u8, 54#u8, 48#u8]
have witnessBytes_length : witnessBytes.length = 65545 := by
simp only [witnessBytes, List.length_append, List.length_replicate,
List.length_cons, List.length_nil]
let witnessSlice : Slice Std.U8 :=
⟨witnessBytes, by rw [witnessBytes_length]; scalar_tac⟩
have fold_zeros (k : Nat) :
(List.replicate k 0).foldl (fun a d => 10 * a + d) 0 = 0 := by
induction k with
| zero => rfl
| succ k ih => simpa [List.replicate_succ] using ih
have zeros_fold :
zeros.foldl (fun a d => 10 * a + d) 0 = 0 := by
rw [zeros_eq]
exact fold_zeros 65535
have zeros_length : zeros.length = 65535 := by
rw [zeros_eq]
exact List.length_replicate
have zeros_mem {d : Nat} (h : d ∈ zeros) : d = 0 := by
rw [zeros_eq, List.mem_replicate] at h
exact h.2
have zeros_map :
zeros.map (fun d => 48 + d) = List.replicate 65535 48 := by
rw [zeros_eq, List.map_replicate]
have fraction_length : fraction.length = 65536 := by
rw [fraction_eq, List.length_append, zeros_length]
rfl
have significand_fold :
([0] ++ fraction).foldl (fun a d => 10 * a + d) 0 = 1 := by
rw [List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, mul_zero, zero_add]
rw [fraction_eq, List.foldl_append, zeros_fold]
rfl
have witness_source_valid : SourceValidByteSlice witnessSlice := by
change witnessBytes.length ≤ 9223372036854775807
rw [witnessBytes_length]
norm_num
have witness_unsigned : witness.leadingSign = none := rfl
have witness_valid : DecimalGoalVocabularyDefault.validNumeric witness := by
dsimp only [DecimalGoalVocabularyDefault]
constructor
· simp [witness]
constructor
· simp only [witness]
intro d hd
rw [fraction_eq] at hd
rcases List.mem_append.mp hd with hd | hd
· rw [zeros_mem hd]
norm_num
· simp only [List.mem_singleton] at hd
omega
constructor
· left
simp [witness]
· simp [witness]
have witness_render :
DecimalGoalVocabularyDefault.renderNumeric witness =
DecimalGoalVocabularyDefault.bytes witnessSlice := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [witness, witnessSlice, witnessBytes, fraction, List.map_append,
List.map_cons, List.map_nil, List.map_replicate, Bool.false_eq_true,
reduceIte, Nat.reduceAdd, List.nil_append, List.cons_append]
rw [zeros_map]
norm_num
have witness_exact :
DecimalGoalVocabularyDefault.exactMagnitude witness =
(10 : Real) ^ (589824 : Nat) := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
rfl
have witness_accumulated :
DecimalGoalVocabularyDefault.accumulatedMagnitude witness = 1 := by
dsimp only [DecimalGoalVocabularyDefault, witness]
rw [significand_fold, fraction_length]
norm_num
let infinityBits : Nat := 2047 * 2 ^ 52
have one_not_infinity_target (w : F64) (hw : w.val = infinityBits) :
¬ DecimalGoalVocabularyDefault.roundsMagnitude (1 : Real) w := by
dsimp only [DecimalGoalVocabularyDefault]
simp only [hw, infinityBits]
norm_num
calc
(1 : Real) + 2 ^ 970 ≤ 2 ^ 970 + 2 ^ 970 := by
gcongr
exact one_le_pow₀ (by norm_num)
_ = 2 ^ 971 := by
rw [show (971 : Nat) = 970 + 1 by norm_num, pow_add]
ring
_ < 2 ^ 1024 := by
rw [show (1024 : Nat) = 971 + 53 by norm_num, pow_add]
norm_num
have huge_target_is_infinity (w : F64)
(hw : DecimalGoalVocabularyDefault.roundsMagnitude
((10 : Real) ^ (589824 : Nat)) w) :
w.val = infinityBits := by
dsimp only [DecimalGoalVocabularyDefault] at hw
rcases hw with ⟨_, _, hw⟩
by_contra hne
have hne' : w.val ≠ 2047 * 2 ^ 52 := by
simpa [infinityBits] using hne
rw [if_neg hne'] at hw
have hthreshold :
((2 : Real) ^ (1024 : Nat)) - ((2 : Real) ^ (970 : Nat)) ≤
(10 : Real) ^ (589824 : Nat) := by
calc
(2 : Real) ^ 1024 - 2 ^ 970 ≤ 2 ^ 1024 :=
sub_le_self _ (by positivity)
_ ≤ 10 ^ 1024 := by gcongr <;> norm_num
_ ≤ 10 ^ 589824 := by
rw [show (589824 : Nat) = 1024 + 588800 by norm_num, pow_add]
exact le_mul_of_one_le_right (by positivity) (one_le_pow₀ (by norm_num))
exact (not_lt_of_ge hthreshold) hw.1
rintro ⟨C⟩
have hslow := C.slow_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
have hexact := C.slowTarget_spec witnessSlice witness witness_source_valid
witness_unsigned witness_valid witness_render
dsimp only at hslow hexact
rw [witness_accumulated] at hslow
rw [witness_exact] at hexact
have hinfinity := huge_target_is_infinity _ hexact
exact one_not_infinity_target _ hinfinity hslow.2.2.1
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Inspect related source (44)
- BiasedFp · dec2flt/common.rs:52 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
More program dependencies (11)
- 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
- 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": "DispatchContractsUninhabited",
"closure_version": "patch_c_v1",
"active_decl_hash": "346016b7f58d48080b61b68728e5eaad2925f4dcfd7174b7549fbd8cb2eb49f0",
"active_statement_hash": "6684f9549b73c17855304fbcb8eaeba2cd6759bdf68e4ae47023a78c42867e3d",
"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-17",
"boundary_theorems": {},
"strict_theorem_deps": {
"DecimalGoalVocabularyDefault": "2bbf2be48b5a4a4b",
"DispatchContracts": "669e4a50a34e5fdd"
},
"strict_definition_deps": {
"DecimalGoalVocabulary": "c08dd4b4aea4abb4",
"DecimalGoalVocabularyDefault": "55eb6bce0e8a4131",
"DecimalLexeme": "8ad754cf2c272e73",
"DispatchContracts": "98677a653108d81f",
"F64": "ec4e25fbaf4e11d4",
"SourceValidByteSlice": "3dc42716a6378d26",
"num_imp_dec2flt_common_BiasedFp": "5c88d5d7976c5e8f"
}
}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:2aeff7d53053b3f018c7ab73195711f99e0e8e3a63badf905e712e6a0be7dbfb",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}