ParserNumericLeadingZeroCertificate

Lean checked

Statement

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

Helper · Leading integer zero scan

If body consists of the two bytes 0. followed by a slice first, then the leading-zero loop of the extracted decimal parser succeeds and returns a slice whose contents are the point followed by first.

Lean statement

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

import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserNumericLeadingZeroCertificate]
theorem ParserNumericLeadingZeroCertificate (body first : Slice Std.U8)
    (hbody : body.val = [48#u8, 46#u8] ++ first.val) :
    exists point : Slice Std.U8,
      point.val = 46#u8 :: first.val /\
      num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 body = ok point := 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

Expand the leading-zero loop in num imp dec2flt decimal seq parse decimal seq. The input is nonempty, its first byte is 48, and dropping that byte is in bounds, so the first iteration continues with the point-prefixed suffix. That suffix is nonempty and has first byte 46 rather than 48, so the second iteration returns it unchanged. The result has exactly the contents claimed in the statement.

Lean proof


  have hpointBound : (46#u8 :: first.val).length <= Usize.max := by
    have hb := body.property
    rw [hbody] at hb
    simp only [List.cons_append, List.nil_append, List.length_cons] at hb ⊢
    omega
  let point : Slice Std.U8 := ⟨46#u8 :: first.val, hpointBound⟩
  have hdropBody : Slice.drop body 1#usize = point := by
    apply (Slice.eq_iff _ _).2
    simp [Slice.drop, hbody, point]
  unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
  rw [Aeneas.Std.loop.eq_1]
  simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
    core.slice.Slice.is_empty, Slice.index_usize, hbody,
    core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.length,
    hdropBody]
  rw [Aeneas.Std.loop.eq_1]
  simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
    core.slice.Slice.is_empty, Slice.index_usize, point]

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.num_imp_dec2flt_decimal_seq_parse_decimal_seq

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserNumericLeadingZeroCertificate]
theorem ParserNumericLeadingZeroCertificate (body first : Slice Std.U8)
    (hbody : body.val = [48#u8, 46#u8] ++ first.val) :
    exists point : Slice Std.U8,
      point.val = 46#u8 :: first.val /\
      num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0 body = ok point := by
-- BODY
  have hpointBound : (46#u8 :: first.val).length <= Usize.max := by
    have hb := body.property
    rw [hbody] at hb
    simp only [List.cons_append, List.nil_append, List.length_cons] at hb ⊢
    omega
  let point : Slice Std.U8 := ⟨46#u8 :: first.val, hpointBound⟩
  have hdropBody : Slice.drop body 1#usize = point := by
    apply (Slice.eq_iff _ _).2
    simp [Slice.drop, hbody, point]
  unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0
  rw [Aeneas.Std.loop.eq_1]
  simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
    core.slice.Slice.is_empty, Slice.index_usize, hbody,
    core.slice.index.SliceIndexRangeFromUsizeSlice.index, Slice.length,
    hdropBody]
  rw [Aeneas.Std.loop.eq_1]
  simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop0.body,
    core.slice.Slice.is_empty, Slice.index_usize, point]

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (77)
More program dependencies (44)
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
All 13 entries
Technical checking records
Local closure summary
{
  "node": "ParserNumericLeadingZeroCertificate",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "af454d004a09d47826d2b970d1befe875b12ca1a41623e60865fe8053d7a5ede",
  "active_statement_hash": "b5c054be6d64d305345c31a14a8e2b70418813334174d0355b01cf8e20023207",
  "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-126",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "num_imp_dec2flt_decimal_seq_parse_decimal_seq": "7a20708611001f01"
  },
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_parse_decimal_seq": "15eb2db9d4385140"
  }
}
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:6cf32e28ca21f319499f95b37ea143c8d43228ec84efebd0221ebc13cd6b6c7b",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}