NumberHelperAcceptance__Refutation

Lean checked

Statement

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

Theorem

The following result is false: For every nonempty Rust byte slice that is exactly an unsigned numeric literal, parse_number returns normally with Some of a Decimal record.

Lean statement

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

import Tablet.DecimalGoalVocabularyDefault
import Tablet.SourceValidByteSlice
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float
import Tablet.NumberHelperAcceptanceSafeLength
import Tablet.NumberHelperMaximalExecution
import Tablet.NumberHelperMaximalWitnessLexical
import Tablet.NumberHelperSafeLengthSharpness

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: NumberHelperAcceptance__Refutation]
theorem NumberHelperAcceptance__Refutation : ¬ (∀ (s : Slice Std.U8) (x : DecimalLexeme), SourceValidByteSlice s -> s.val ≠ [] -> x.leadingSign = none ->
      DecimalGoalVocabularyDefault.validNumeric x -> DecimalGoalVocabularyDefault.bytes s = DecimalGoalVocabularyDefault.renderNumeric x ->
      ∃ d, num.imp.dec2flt.parse.parse_number s = ok (some d)) := 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

Assume, for contradiction, the stated universal acceptance property. By NumberHelperSafeLengthSharpness, there are a source-valid slice s and an unsigned valid numeric lexeme x whose rendering is exactly s, where the bytes of s are a point, followed by 9223372036854120450 copies of ASCII 1, followed by e-655359. The cited statement gives that s is nonempty and that the extracted parse_number on s returns fail integerOverflow.
Instantiate the assumed universal property with this s and x, using the source-validity, nonemptiness, absent leading sign, numeric validity, and exact-rendering facts supplied by the cited lemma. It yields a decimal record d such that the same call to parse_number returns ok (some d). Substituting the failure equation into this success equation identifies fail integerOverflow with ok (some d), which is impossible because fail and ok are distinct constructors of the extracted Result type. This contradiction refutes the universal property.

Lean proof


  intro haccept
  obtain ⟨s, x, _, _, _, hsource, hnonempty, hsign, hvalid, hrenders,
    hfailure⟩ := NumberHelperSafeLengthSharpness
  have hnonempty' : Ne s.val [] := by
    simpa only [bne_iff_ne] using hnonempty
  obtain ⟨d, hsuccess⟩ :=
    haccept s x hsource hnonempty' hsign hvalid hrenders
  rw [hfailure] at hsuccess
  cases hsuccess

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.SourceValidByteSlice
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float
import Tablet.NumberHelperAcceptanceSafeLength
import Tablet.NumberHelperMaximalExecution
import Tablet.NumberHelperMaximalWitnessLexical
import Tablet.NumberHelperSafeLengthSharpness

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: NumberHelperAcceptance__Refutation]
theorem NumberHelperAcceptance__Refutation : ¬ (∀ (s : Slice Std.U8) (x : DecimalLexeme), SourceValidByteSlice s -> s.val ≠ [] -> x.leadingSign = none ->
      DecimalGoalVocabularyDefault.validNumeric x -> DecimalGoalVocabularyDefault.bytes s = DecimalGoalVocabularyDefault.renderNumeric x ->
      ∃ d, num.imp.dec2flt.parse.parse_number s = ok (some d)) := by
-- BODY
  intro haccept
  obtain ⟨s, x, _, _, _, hsource, hnonempty, hsign, hvalid, hrenders,
    hfailure⟩ := NumberHelperSafeLengthSharpness
  have hnonempty' : Ne s.val [] := by
    simpa only [bne_iff_ne] using hnonempty
  obtain ⟨d, hsuccess⟩ :=
    haccept s x hsource hnonempty' hsign hvalid hrenders
  rw [hfailure] at hsuccess
  cases hsuccess

Proof structure

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

Explore this dependency tree

Inspect related source (201)
More program dependencies (159)
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 66 entries
Technical checking records
Local closure summary
{
  "node": "NumberHelperAcceptance__Refutation",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "8e0a54b2bbf783046521d6501a059d89b17f4445a3457b43fbd4367c3cf8ccb7",
  "active_statement_hash": "e5592fffc9d120e43d932736ad0f7290fc958b45ed2743498aee4bd12ff18890",
  "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-115",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "NumberHelperSafeLengthSharpness": "4e8605e902e86049"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "4da7f295a9b85b50",
    "DecimalGoalVocabularyDefault": "512f8d0aea894250",
    "DecimalLexeme": "bf0c609978369054",
    "SourceValidByteSlice": "3dc42716a6378d26",
    "num_imp_dec2flt_decimal_Decimal": "c43614ff2149ecf2",
    "num_imp_dec2flt_parse_parse_number": "f73f8bc11faa6db3"
  }
}
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:5a789d917e08c7f521d293b66e4829b0d7feab6eb350fa7091b3c0cc3e4cf3e3",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}