P856_T1_DecimalBinaryExponentBound

Lean checked

Statement

This explanation was written alongside the formalization to describe the statement and its reasoning.

Lemma · Decimal-to-binary capacity comparison

Let -306\leq p\leq0 and e\in\mathbb Z. If
10^{p-1}<2^e,
then p\leq e+714.

Lean statement

Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.

import Tablet.Preamble
import Mathlib.Tactic

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_DecimalBinaryExponentBound]
theorem P856_T1_DecimalBinaryExponentBound
    (p e : Int) (hpLo : -306 <= p) (hpHi : p <= 0)
    (hpow : (10 : Real) ^ (p - 1) < (2 : Real) ^ e) :
    p <= e + 714 := 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

The kernel-certified natural-number comparison 10^{307}<2^{1021} is used directly (by decide +kernel). Suppose for contradiction that p>e+714, so e\leq p-715. Put k=p+306, which is a natural number because p\geq-306. Monotonicity of integer powers of two gives
2^e\leq2^{p-715}=2^{k-1021}.
Moreover 2^k\leq10^k, while the certified comparison makes the denominator 2^{1021} strictly larger than 10^{307}. Positivity of all powers therefore gives
2^{k-1021}=\frac{2^k}{2^{1021}} \leq\frac{10^k}{10^{307}}=10^{k-307}=10^{p-1}.
This contradicts 10^{p-1}<2^e, and hence p\leq e+714.

Lean proof


  by_contra hnot
  have he : e <= p - 715 := by omega
  have hpCompare : (2 : Real) ^ e <= (2 : Real) ^ (p - 715) :=
    zpow_le_zpow_right₀ (by norm_num) he
  let k : Nat := (p + 306).toNat
  have hk : (k : Int) = p + 306 := by
    dsimp only [k]
    rw [Int.toNat_of_nonneg (by omega)]
  have hbaseNat : (10 : Nat) ^ 307 < 2 ^ 1021 := by
    decide +kernel
  have hbase : (10 : Real) ^ 307 < (2 : Real) ^ 1021 := by
    exact_mod_cast hbaseNat
  have hkpow : (2 : Real) ^ k <= (10 : Real) ^ k := by
    exact pow_le_pow_left₀ (by norm_num) (by norm_num) k
  have hratio :
      (2 : Real) ^ k / (2 : Real) ^ 1021 <=
        (10 : Real) ^ k / (10 : Real) ^ 307 := by
    calc
      (2 : Real) ^ k / (2 : Real) ^ 1021 <=
          (2 : Real) ^ k / (10 : Real) ^ 307 := by
            gcongr
      _ <= (10 : Real) ^ k / (10 : Real) ^ 307 := by
            gcongr
  have hmain : (2 : Real) ^ (p - 715) <= (10 : Real) ^ (p - 1) := by
    rw [show p - 715 = (k : Int) - 1021 by omega]
    rw [show p - 1 = (k : Int) - 307 by omega]
    rw [zpow_sub₀ (by norm_num : (2 : Real) ≠ 0)]
    rw [zpow_sub₀ (by norm_num : (10 : Real) ≠ 0)]
    norm_num only [zpow_natCast]
    exact hratio
  linarith

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.Preamble
import Mathlib.Tactic

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_DecimalBinaryExponentBound]
theorem P856_T1_DecimalBinaryExponentBound
    (p e : Int) (hpLo : -306 <= p) (hpHi : p <= 0)
    (hpow : (10 : Real) ^ (p - 1) < (2 : Real) ^ e) :
    p <= e + 714 := by
-- BODY
  by_contra hnot
  have he : e <= p - 715 := by omega
  have hpCompare : (2 : Real) ^ e <= (2 : Real) ^ (p - 715) :=
    zpow_le_zpow_right₀ (by norm_num) he
  let k : Nat := (p + 306).toNat
  have hk : (k : Int) = p + 306 := by
    dsimp only [k]
    rw [Int.toNat_of_nonneg (by omega)]
  have hbaseNat : (10 : Nat) ^ 307 < 2 ^ 1021 := by
    decide +kernel
  have hbase : (10 : Real) ^ 307 < (2 : Real) ^ 1021 := by
    exact_mod_cast hbaseNat
  have hkpow : (2 : Real) ^ k <= (10 : Real) ^ k := by
    exact pow_le_pow_left₀ (by norm_num) (by norm_num) k
  have hratio :
      (2 : Real) ^ k / (2 : Real) ^ 1021 <=
        (10 : Real) ^ k / (10 : Real) ^ 307 := by
    calc
      (2 : Real) ^ k / (2 : Real) ^ 1021 <=
          (2 : Real) ^ k / (10 : Real) ^ 307 := by
            gcongr
      _ <= (10 : Real) ^ k / (10 : Real) ^ 307 := by
            gcongr
  have hmain : (2 : Real) ^ (p - 715) <= (10 : Real) ^ (p - 1) := by
    rw [show p - 715 = (k : Int) - 1021 by omega]
    rw [show p - 1 = (k : Int) - 307 by omega]
    rw [zpow_sub₀ (by norm_num : (2 : Real) ≠ 0)]
    rw [zpow_sub₀ (by norm_num : (10 : Real) ≠ 0)]
    norm_num only [zpow_natCast]
    exact hratio
  linarith

end dec2flt_model

Proof structure

Follow the declared dependencies to read the supporting statements and proofs.

Explore this dependency tree

Inspect related source (44)
More program dependencies (11)
Standard-library dependencies (30)

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

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": "P856_T1_DecimalBinaryExponentBound",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "75edac2c4bef8839efac1556984547109603f0ae30b55b5b31b736fcfccf13d5",
  "active_statement_hash": "7f4a4283f83442cbbf6f460e29fedf54c4071caf778b5b51eb38b3b04345fc8c",
  "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": "revalidate-cycle-199",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {}
}
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:6d210db25457e2e3cd85d732566076dcc5e7b4745f60a87791c22c798324d485",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}