P856_T1_LeftPointGrowth

Lean checked

Statement

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

Helper · Selected left shifts cover decimal-point growth

Consider one continuing loop-1 step at input point p\leq0, output point p', selected binary shift k, and leading digit z. Assume the exact selector alternative and the exact point alternatives stated in Lean: for p\leq-19 the output adds 18 or 19; for -18\leq p<0 the output is -1 or zero; and for p=0 it remains zero. 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_LeftStepCertificate
import Mathlib.Tactic.IntervalCases

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_LeftPointGrowth]
theorem P856_T1_LeftPointGrowth
    (p p' : Int) (k : Std.Usize) (z : Nat)
    (hpHi : p <= 0)
    (hsel :
      (p < 0 /\ exists n : Std.Usize,
        (n.val : Int) = -p /\
        num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
          F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n = ok k) \/
      (p = 0 /\ z < 5 /\
        k = if z = 1 then 2#usize else 1#usize))
    (hlarge : p <= -19 -> p' = p + 18 \/ p' = p + 19)
    (hsmall : -18 <= p -> p < 0 -> p' = -1 \/ p' = 0)
    (hzero : p = 0 -> p' = 0) :
    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

If p\leq-19, the selector certificate SlowShiftSelectorCertificate says k=60, while the point grows by only 18 or 19. If -18\leq p<0, let n=-p\in[1,18]. The same certificate gives the table value selected at n. Checking its eighteen literal entries shows n\leq k. Since p' is -1 or zero, p'-p\leq-p=n\leq k. Finally, if p=0, the stated output alternative gives p'=0, so the growth is zero. These cases exhaust p\leq0.

Lean proof


  by_cases hp19 : p <= -19
  · rcases hlarge hp19 with hp' | hp'
    · have hk : k = 60#usize := by
        rcases hsel with ⟨hpneg, n, hn, hcall⟩ | hzeroSel
        · have hc := SlowShiftSelectorCertificate
            F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
          dsimp only at hc
          rcases hc with ⟨hcall', _, _, _, hbig⟩
          have hn19 : 19 <= n.val := by omega
          have hkeq := Result.ok.inj (hcall.symm.trans hcall')
          apply UScalar.eq_of_val_eq
          rw [hkeq]
          exact (hbig hn19).1
        · omega
      rw [hp', hk]
      norm_num [UScalar.cast_val_eq]
    · have hk : k = 60#usize := by
        rcases hsel with ⟨hpneg, n, hn, hcall⟩ | hzeroSel
        · have hc := SlowShiftSelectorCertificate
            F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
          dsimp only at hc
          rcases hc with ⟨hcall', _, _, _, hbig⟩
          have hn19 : 19 <= n.val := by omega
          have hkeq := Result.ok.inj (hcall.symm.trans hcall')
          apply UScalar.eq_of_val_eq
          rw [hkeq]
          exact (hbig hn19).1
        · omega
      rw [hp', hk]
      norm_num [UScalar.cast_val_eq]
  · by_cases hp0 : p = 0
    · rw [hzero hp0, hp0]
      omega
    · have hpneg : p < 0 := by omega
      have hp18 : -18 <= p := by omega
      rcases hsel with ⟨_, n, hn, hcall⟩ | hzeroSel
      · have hnLo : 1 <= n.val := by omega
        have hnHi : n.val <= 18 := by omega
        have hc := SlowShiftSelectorCertificate
          F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
        dsimp only at hc
        rcases hc with ⟨hcall', _, _, _, _⟩
        have hkeq := Result.ok.inj (hcall.symm.trans hcall')
        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 hpneg with hp' | hp' <;> omega
      · omega

end dec2flt_model

Download Lean source · Download TeX source

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

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_LeftPointGrowth]
theorem P856_T1_LeftPointGrowth
    (p p' : Int) (k : Std.Usize) (z : Nat)
    (hpHi : p <= 0)
    (hsel :
      (p < 0 /\ exists n : Std.Usize,
        (n.val : Int) = -p /\
        num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
          F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n = ok k) \/
      (p = 0 /\ z < 5 /\
        k = if z = 1 then 2#usize else 1#usize))
    (hlarge : p <= -19 -> p' = p + 18 \/ p' = p + 19)
    (hsmall : -18 <= p -> p < 0 -> p' = -1 \/ p' = 0)
    (hzero : p = 0 -> p' = 0) :
    p' - p <= (k.val : Int) := by
-- BODY
  by_cases hp19 : p <= -19
  · rcases hlarge hp19 with hp' | hp'
    · have hk : k = 60#usize := by
        rcases hsel with ⟨hpneg, n, hn, hcall⟩ | hzeroSel
        · have hc := SlowShiftSelectorCertificate
            F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
          dsimp only at hc
          rcases hc with ⟨hcall', _, _, _, hbig⟩
          have hn19 : 19 <= n.val := by omega
          have hkeq := Result.ok.inj (hcall.symm.trans hcall')
          apply UScalar.eq_of_val_eq
          rw [hkeq]
          exact (hbig hn19).1
        · omega
      rw [hp', hk]
      norm_num [UScalar.cast_val_eq]
    · have hk : k = 60#usize := by
        rcases hsel with ⟨hpneg, n, hn, hcall⟩ | hzeroSel
        · have hc := SlowShiftSelectorCertificate
            F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
          dsimp only at hc
          rcases hc with ⟨hcall', _, _, _, hbig⟩
          have hn19 : 19 <= n.val := by omega
          have hkeq := Result.ok.inj (hcall.symm.trans hcall')
          apply UScalar.eq_of_val_eq
          rw [hkeq]
          exact (hbig hn19).1
        · omega
      rw [hp', hk]
      norm_num [UScalar.cast_val_eq]
  · by_cases hp0 : p = 0
    · rw [hzero hp0, hp0]
      omega
    · have hpneg : p < 0 := by omega
      have hp18 : -18 <= p := by omega
      rcases hsel with ⟨_, n, hn, hcall⟩ | hzeroSel
      · have hnLo : 1 <= n.val := by omega
        have hnHi : n.val <= 18 := by omega
        have hc := SlowShiftSelectorCertificate
          F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
        dsimp only at hc
        rcases hc with ⟨hcall', _, _, _, _⟩
        have hkeq := Result.ok.inj (hcall.symm.trans hcall')
        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 hpneg with hp' | hp' <;> omega
      · 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": "P856_T1_LeftPointGrowth",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "067ccaf7195dbf8dda827790683b4697e3421660261858c1d8d697e5a98d0919",
  "active_statement_hash": "e00f215b4d1e349dc9d491451fd16a0508dca3c0b7a4a38da602c9ac2edc001a",
  "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": {
    "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:b66034d3127d499aec02613ee8e577f669ac670c2439d5e01368e94b0eec876a",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}