P826_T1_RightCapacityStep

Lean checked

Statement

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

Helper · One-step right-normalization capacity inequality

Let p,p' be integer decimal points with p\geq1. Let the machine natural n have exact integer value p, and suppose the extracted selector returns the machine shift k. Assume the right-shift point clauses
p\geq19\Longrightarrow p'=p-18\text{ or }p-19,\qquad p\leq18\Longrightarrow p'=0\text{ or }1.
Then
p-p'\leq k.

Lean statement

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

import Tablet.P826_T1_RightStepCertificate
import Mathlib.Tactic.IntervalCases

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P826_T1_RightCapacityStep]
theorem P826_T1_RightCapacityStep (p p' : Int) (n k : Std.Usize)
    (hp : 1 <= p)
    (hn : (n.val : Int) = p)
    (hsel :
      num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n = ok k)
    (hlarge : 19 <= p -> p' = p - 18 \/ p' = p - 19)
    (hsmall : p <= 18 -> p' = 0 \/ p' = 1) :
    p - p' <= (k.val : Int) := 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

Use the exact call and literal table in SlowShiftSelectorCertificate. If p\geq19, then n\geq19 and the fallback shift is k=60. The point decreases by only 18 or 19, so the claim follows.
Otherwise 1\leq p\leq18, and the output point is zero or one. Direct evaluation of the eighteen literal table entries
3,6,9,13,16,19,23,26,29,33,36,39,43,46,49,53,56,59
shows n\leq k(n) for every 1\leq n\leq18. Since n=p and p'\geq0, we have p-p'\leq p=n\leq k, as required.

Lean proof


  have hc := SlowShiftSelectorCertificate
    F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
  dsimp only at hc
  rcases hc with ⟨hsel', hk60, hzero, hfinite, hbig⟩
  have hkeq := Result.ok.inj (hsel.symm.trans hsel')
  by_cases hp19 : 19 <= p
  · have hn19 : 19 <= n.val := by omega
    have hkval : k.val = 60 := by
      rw [hkeq]
      exact (hbig hn19).1
    rcases hlarge hp19 with h | h <;> omega
  · have hp18 : p <= 18 := by omega
    have hnLo : 1 <= n.val := by omega
    have hnHi : n.val <= 18 := by omega
    have htable (m : Nat) : 1 <= m -> m <= 18 ->
        let j : Std.Usize := match m 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
        (m : Int) <= (j.val : Int) := by
      intro hmLo hmHi
      interval_cases m <;> norm_num [UScalar.cast_val_eq] at *
    have hnk : (n.val : Int) <= (k.val : Int) := by
      rw [hkeq]
      exact htable n.val hnLo hnHi
    rcases hsmall hp18 with h | h <;> omega

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.P826_T1_RightStepCertificate
import Mathlib.Tactic.IntervalCases

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P826_T1_RightCapacityStep]
theorem P826_T1_RightCapacityStep (p p' : Int) (n k : Std.Usize)
    (hp : 1 <= p)
    (hn : (n.val : Int) = p)
    (hsel :
      num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n = ok k)
    (hlarge : 19 <= p -> p' = p - 18 \/ p' = p - 19)
    (hsmall : p <= 18 -> p' = 0 \/ p' = 1) :
    p - p' <= (k.val : Int) := by
-- BODY
  have hc := SlowShiftSelectorCertificate
    F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
  dsimp only at hc
  rcases hc with ⟨hsel', hk60, hzero, hfinite, hbig⟩
  have hkeq := Result.ok.inj (hsel.symm.trans hsel')
  by_cases hp19 : 19 <= p
  · have hn19 : 19 <= n.val := by omega
    have hkval : k.val = 60 := by
      rw [hkeq]
      exact (hbig hn19).1
    rcases hlarge hp19 with h | h <;> omega
  · have hp18 : p <= 18 := by omega
    have hnLo : 1 <= n.val := by omega
    have hnHi : n.val <= 18 := by omega
    have htable (m : Nat) : 1 <= m -> m <= 18 ->
        let j : Std.Usize := match m 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
        (m : Int) <= (j.val : Int) := by
      intro hmLo hmHi
      interval_cases m <;> norm_num [UScalar.cast_val_eq] at *
    have hnk : (n.val : Int) <= (k.val : Int) := by
      rw [hkeq]
      exact htable n.val hnLo hnHi
    rcases hsmall hp18 with h | h <;> omega

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (151)
More program dependencies (109)
Standard-library dependencies (39)

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
All 79 entries
Technical checking records
Local closure summary
{
  "node": "P826_T1_RightCapacityStep",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "9121766c05d6e15163003f02807abebb75658710687830a67d3aff6e2af7d595",
  "active_statement_hash": "186d7eef40af417e00286d3fcd0b9b98b70ae31749160574e5b76d69e09ba120",
  "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-196",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "SlowShiftSelectorCertificate": "963b7a2e670856e8"
  },
  "strict_definition_deps": {
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "SlowShiftSelectorCertificate": "7ebc2b39d69850c4",
    "num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call": "7df8a2c8e3717790"
  }
}
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:52868b7c04e32b155c59c03e1d068d8f86c5d024f47a5e3f21a291f371479f4b",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}