P826_T1_RightDoneCertificate

Lean checked

Statement

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

Helper · Exact successful exit of the right-normalization body

Let d,d' be decimal records and e,e' signed machine exponents. If the extracted loop-0 body, started from (d,e,\mathsf{none}), successfully returns \mathsf{done}(d',e',\mathsf{none}), then d'=d, e'=e, and the decimal point of d is nonpositive.

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

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P826_T1_RightDoneCertificate]
theorem P826_T1_RightDoneCertificate
    (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
    (e e' : Std.I32)
    (hbody :
      num.imp.dec2flt.slow.parse_long_mantissa_loop0.body
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
        { m := 0#u64, p_biased := 0#i32 }
        d.num_digits d.decimal_point d.truncated d.digits e none =
          ok (done (d'.num_digits, d'.decimal_point, d'.truncated,
            d'.digits, e', none))) :
    d' = d /\ e' = e /\ d.decimal_point.val <= 0 := 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

Unfold the extracted loop-0 body num imp dec2flt slow parse long mantissa. If the point is positive, the \mathsf{none} option enters the normalization branch. Split the cast, selector call, right shift, negation of the range constant, reset test, cast, and exponent addition. Every successful terminal result on either reset branch is a \mathsf{cont} constructor, while every other case fails or diverges. None can equal the assumed successful \mathsf{done}.
Thus the positive-point test is false, so the point is nonpositive. This branch immediately returns the unchanged tuple. Injectivity of the result, control-flow, and product constructors gives d'=d and e'=e.

Lean proof


  unfold num.imp.dec2flt.slow.parse_long_mantissa_loop0.body at hbody
  by_cases hp : d.decimal_point > 0#i32
  · simp only [hp, if_true, core.option.Option.is_none] at hbody
    simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
      true by rfl, if_true, lift, bind_tc_ok] at hbody
    cases hsel :
        num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
          F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 ()
            (IScalar.hcast .Usize d.decimal_point) with
    | fail err => simp [hsel] at hbody
    | div => simp [hsel] at hbody
    | ok shift =>
      rw [hsel] at hbody
      simp only [bind_tc_ok] at hbody
      cases hright :
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift with
      | fail err => simp [hright] at hbody
      | div => simp [hright] at hbody
      | ok q =>
        rw [hright] at hbody
        simp only [bind_tc_ok] at hbody
        cases hneg :
            -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE with
        | fail err => simp [hneg] at hbody
        | div => simp [hneg] at hbody
        | ok negRange =>
          rw [hneg] at hbody
          simp only [bind_tc_ok] at hbody
          by_cases hreset : q.decimal_point < negRange
          · simp [hreset] at hbody
          · simp only [hreset, if_false, lift] at hbody
            cases hadd : e + UScalar.hcast .I32 shift with
            | fail err => simp [hadd] at hbody
            | div => simp [hadd] at hbody
            | ok eout => simp [hadd] at hbody
  · simp only [hp, if_false] at hbody
    have ht := Result.ok.inj hbody
    have hs := ControlFlow.done.inj ht
    simp only [Prod.mk.injEq] at hs
    have hd : d' = d := by
      cases d
      cases d'
      simp_all only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
    have he : e' = e := by tauto
    refine ⟨hd, he, ?_⟩
    change ¬ d.decimal_point.val > 0 at hp
    omega

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.P826_T1_RightStepCertificate

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P826_T1_RightDoneCertificate]
theorem P826_T1_RightDoneCertificate
    (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
    (e e' : Std.I32)
    (hbody :
      num.imp.dec2flt.slow.parse_long_mantissa_loop0.body
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
        { m := 0#u64, p_biased := 0#i32 }
        d.num_digits d.decimal_point d.truncated d.digits e none =
          ok (done (d'.num_digits, d'.decimal_point, d'.truncated,
            d'.digits, e', none))) :
    d' = d /\ e' = e /\ d.decimal_point.val <= 0 := by
-- BODY
  unfold num.imp.dec2flt.slow.parse_long_mantissa_loop0.body at hbody
  by_cases hp : d.decimal_point > 0#i32
  · simp only [hp, if_true, core.option.Option.is_none] at hbody
    simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
      true by rfl, if_true, lift, bind_tc_ok] at hbody
    cases hsel :
        num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
          F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 ()
            (IScalar.hcast .Usize d.decimal_point) with
    | fail err => simp [hsel] at hbody
    | div => simp [hsel] at hbody
    | ok shift =>
      rw [hsel] at hbody
      simp only [bind_tc_ok] at hbody
      cases hright :
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift with
      | fail err => simp [hright] at hbody
      | div => simp [hright] at hbody
      | ok q =>
        rw [hright] at hbody
        simp only [bind_tc_ok] at hbody
        cases hneg :
            -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE with
        | fail err => simp [hneg] at hbody
        | div => simp [hneg] at hbody
        | ok negRange =>
          rw [hneg] at hbody
          simp only [bind_tc_ok] at hbody
          by_cases hreset : q.decimal_point < negRange
          · simp [hreset] at hbody
          · simp only [hreset, if_false, lift] at hbody
            cases hadd : e + UScalar.hcast .I32 shift with
            | fail err => simp [hadd] at hbody
            | div => simp [hadd] at hbody
            | ok eout => simp [hadd] at hbody
  · simp only [hp, if_false] at hbody
    have ht := Result.ok.inj hbody
    have hs := ControlFlow.done.inj ht
    simp only [Prod.mk.injEq] at hs
    have hd : d' = d := by
      cases d
      cases d'
      simp_all only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
    have he : e' = e := by tauto
    refine ⟨hd, he, ?_⟩
    change ¬ d.decimal_point.val > 0 at hp
    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 101 entries
Technical checking records
Local closure summary
{
  "node": "P826_T1_RightDoneCertificate",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "5a8307ccbeb3342f0f798372b5220e32e4b40a0922d8f632339df5a7b8a9bf04",
  "active_statement_hash": "33f357aaca013820c3bf7fc48659da9eefa100b46fb57fd74f4968b81441f493",
  "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": {
    "num_imp_dec2flt_slow_parse_long_mantissa": "d2b4145772dccc04"
  },
  "strict_definition_deps": {
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "59bf1ff9fe88fa8d",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "0cc5155758bc976a",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "1aaf1bb11c0b6a49",
    "num_imp_dec2flt_slow_parse_long_mantissa": "0ce7bdcf55d68c29",
    "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:5e08983f98b12bb1b217c2b9a5d1b8a87c3715d644adc93a12874fb56fcb3f44",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}