P364_T1_NumberHelperDigitPrefix

Lean checked

Statement

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

Lemma · Maximal decimal-byte prefix

Every finite byte list s admits a decomposition s=DT such that every byte of D is an ASCII decimal digit (its value is between 48 and 57), and the first byte of T, if present, is not an ASCII decimal digit.

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

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P364_T1_NumberHelperDigitPrefix]
theorem P364_T1_NumberHelperDigitPrefix : forall xs : List Std.U8,
    exists digits tail,
      xs = digits ++ tail /\
      (forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) /\
      (forall b rest, tail = b :: rest ->
        Not (48 <= b.val /\ b.val <= 57)) := 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

Induct on the list. For the empty list, take both parts empty. For b::s, decide whether 48\leq b\leq57. If so, apply the induction hypothesis to s=DT and take (b::D,T). Every member of the new prefix is either b or a member of D, hence is a digit; the tail property is unchanged. If not, take ([],b::s); its prefix condition is vacuous and its tail starts with the stated nondigit. This establishes all clauses.

Lean proof


  intro xs
  induction xs with
  | nil => exact ⟨[], [], rfl, (by intro b hb; cases hb), (by
      intro b rest h
      cases h)⟩
  | cons b bs ih =>
    by_cases hb : 48 <= b.val /\ b.val <= 57
    · obtain ⟨digits, tail, hsplit, hdigits, htail⟩ := ih
      refine ⟨b :: digits, tail, by simp [hsplit], ?_, htail⟩
      intro c hc
      rcases List.mem_cons.mp hc with rfl | hc
      · exact hb
      · exact hdigits c hc
    · exact ⟨[], b :: bs, rfl, (by intro c hc; cases hc), (by
        intro c rest h
        cases h
        exact hb)⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.Preamble

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P364_T1_NumberHelperDigitPrefix]
theorem P364_T1_NumberHelperDigitPrefix : forall xs : List Std.U8,
    exists digits tail,
      xs = digits ++ tail /\
      (forall b, List.Mem b digits -> 48 <= b.val /\ b.val <= 57) /\
      (forall b rest, tail = b :: rest ->
        Not (48 <= b.val /\ b.val <= 57)) := by
-- BODY
  intro xs
  induction xs with
  | nil => exact ⟨[], [], rfl, (by intro b hb; cases hb), (by
      intro b rest h
      cases h)⟩
  | cons b bs ih =>
    by_cases hb : 48 <= b.val /\ b.val <= 57
    · obtain ⟨digits, tail, hsplit, hdigits, htail⟩ := ih
      refine ⟨b :: digits, tail, by simp [hsplit], ?_, htail⟩
      intro c hc
      rcases List.mem_cons.mp hc with rfl | hc
      · exact hb
      · exact hdigits c hc
    · exact ⟨[], b :: bs, rfl, (by intro c hc; cases hc), (by
        intro c rest h
        cases h
        exact hb)⟩

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": "P364_T1_NumberHelperDigitPrefix",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "38112980c421f7db591d34b0a33302b55f2b816a12abe779a179ccc19cb9190d",
  "active_statement_hash": "050f6e88f3e120932396bad1652062e24f833cacb5c9d39233e6db03de7c4d02",
  "kernel_axioms": [
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-73",
  "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:9a90e33a0764819c53e2b396f18632c1a61788026b48eb7fcb47007056fc9b87",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}