NumberHelperRejection__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 not an unsigned numeric literal, parse_number returns normally with None.

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.InvalidOverflowBoundaryWitness

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: NumberHelperRejection__Refutation]
theorem NumberHelperRejection__Refutation : Not
  (∀ (s : Aeneas.Std.Slice.{0} Aeneas.Std.U8),
    dec2flt_model.SourceValidByteSlice s →
      @Ne.{1} (List.{0} Aeneas.Std.U8)
          (@Subtype.val.{1} (List.{0} Aeneas.Std.U8)
            (fun (l : List.{0} Aeneas.Std.U8) =>
              @LE.le.{0} Nat instLENat (@List.length.{0} Aeneas.Std.U8 l) Aeneas.Std.Usize.max)
            s)
          (@List.nil.{0} Aeneas.Std.U8) →
        Not
            (@Exists.{1} dec2flt_model.DecimalLexeme fun (x : dec2flt_model.DecimalLexeme) =>
              And (@Eq.{1} (Option.{0} Bool) (dec2flt_model.DecimalLexeme.leadingSign x) (@Option.none.{0} Bool))
                (And (dec2flt_model.DecimalGoalVocabulary.validNumeric dec2flt_model.DecimalGoalVocabularyDefault x)
                  (@Eq.{1} (List.{0} Nat)
                    (dec2flt_model.DecimalGoalVocabulary.bytes dec2flt_model.DecimalGoalVocabularyDefault s)
                    (dec2flt_model.DecimalGoalVocabulary.renderNumeric dec2flt_model.DecimalGoalVocabularyDefault
                      x)))) →
          @Eq.{1} (Aeneas.Std.Result.{0} (Option.{0} dec2flt_model.num.imp.dec2flt.decimal.Decimal))
            (dec2flt_model.num.imp.dec2flt.parse.parse_number s)
            (@Aeneas.Std.Result.ok.{0} (Option.{0} dec2flt_model.num.imp.dec2flt.decimal.Decimal)
              (@Option.none.{0} dec2flt_model.num.imp.dec2flt.decimal.Decimal))) := 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

Use the source-valid slice s supplied by InvalidOverflowBoundaryWitness. Its byte list is
[46]\mathbin{++}\operatorname{replicate}(9223372036854120450,49) \mathbin{++}[101,45,54,53,53,51,53,57,120].
The cited statement says that this slice is nonempty and that there is no valid numeric lexeme, with any leading sign, whose numeric rendering equals the bytes of s. In particular, there cannot be a valid numeric lexeme with no leading sign whose rendering is the bytes of s: if the target's unsigned-grammar existential supplied such a lexeme with the equality written as ``bytes equals rendering'', symmetry of equality would give precisely the rendering-equals-bytes witness excluded by the cited statement. Thus s satisfies the target's unsigned-grammar exclusion premise. The cited Boolean nonemptiness assertion is equivalent to the propositional inequality between the byte list and the empty list, so it also supplies the target's nonempty premise.
Suppose the displayed universal assertion were true and specialize it to this s. Source validity, propositional nonemptiness, and the unsigned exclusion just established would force parse_number(s) = ok None. But InvalidOverflowBoundaryWitness states instead that parse_number(s) = fail integerOverflow. Rewriting the forced equality by this witnessed parse result equates the distinct fail and ok constructors of the Aeneas Result type, an impossibility. Hence the universal assertion is false.

Lean proof


  intro hall
  obtain ⟨s, _, _, hvalid, _, hne, hnoNumeric, _, _, hparse, _⟩ :=
    InvalidOverflowBoundaryWitness
  have hunsigned : Not (exists x : DecimalLexeme,
      x.leadingSign = none /\
      DecimalGoalVocabularyDefault.validNumeric x /\
      DecimalGoalVocabularyDefault.bytes s =
        DecimalGoalVocabularyDefault.renderNumeric x) := by
    rintro ⟨x, _, hxvalid, hxbytes⟩
    exact hnoNumeric ⟨x, hxvalid, hxbytes.symm⟩
  have hne' : s.val ≠ [] := by
    simpa only [bne_iff_ne] using hne
  have hnormal := hall s hvalid hne' hunsigned
  rw [hparse] at hnormal
  cases hnormal

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.InvalidOverflowBoundaryWitness

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: NumberHelperRejection__Refutation]
theorem NumberHelperRejection__Refutation : Not
  (∀ (s : Aeneas.Std.Slice.{0} Aeneas.Std.U8),
    dec2flt_model.SourceValidByteSlice s →
      @Ne.{1} (List.{0} Aeneas.Std.U8)
          (@Subtype.val.{1} (List.{0} Aeneas.Std.U8)
            (fun (l : List.{0} Aeneas.Std.U8) =>
              @LE.le.{0} Nat instLENat (@List.length.{0} Aeneas.Std.U8 l) Aeneas.Std.Usize.max)
            s)
          (@List.nil.{0} Aeneas.Std.U8) →
        Not
            (@Exists.{1} dec2flt_model.DecimalLexeme fun (x : dec2flt_model.DecimalLexeme) =>
              And (@Eq.{1} (Option.{0} Bool) (dec2flt_model.DecimalLexeme.leadingSign x) (@Option.none.{0} Bool))
                (And (dec2flt_model.DecimalGoalVocabulary.validNumeric dec2flt_model.DecimalGoalVocabularyDefault x)
                  (@Eq.{1} (List.{0} Nat)
                    (dec2flt_model.DecimalGoalVocabulary.bytes dec2flt_model.DecimalGoalVocabularyDefault s)
                    (dec2flt_model.DecimalGoalVocabulary.renderNumeric dec2flt_model.DecimalGoalVocabularyDefault
                      x)))) →
          @Eq.{1} (Aeneas.Std.Result.{0} (Option.{0} dec2flt_model.num.imp.dec2flt.decimal.Decimal))
            (dec2flt_model.num.imp.dec2flt.parse.parse_number s)
            (@Aeneas.Std.Result.ok.{0} (Option.{0} dec2flt_model.num.imp.dec2flt.decimal.Decimal)
              (@Option.none.{0} dec2flt_model.num.imp.dec2flt.decimal.Decimal))) := by
-- BODY
  intro hall
  obtain ⟨s, _, _, hvalid, _, hne, hnoNumeric, _, _, hparse, _⟩ :=
    InvalidOverflowBoundaryWitness
  have hunsigned : Not (exists x : DecimalLexeme,
      x.leadingSign = none /\
      DecimalGoalVocabularyDefault.validNumeric x /\
      DecimalGoalVocabularyDefault.bytes s =
        DecimalGoalVocabularyDefault.renderNumeric x) := by
    rintro ⟨x, _, hxvalid, hxbytes⟩
    exact hnoNumeric ⟨x, hxvalid, hxbytes.symm⟩
  have hne' : s.val ≠ [] := by
    simpa only [bne_iff_ne] using hne
  have hnormal := hall s hvalid hne' hunsigned
  rw [hparse] at hnormal
  cases hnormal

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 166 entries
Technical checking records
Local closure summary
{
  "node": "NumberHelperRejection__Refutation",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "9584be518e8a403911c3cd26676df7ddfb7a9c6e314b26439a778a141b61b85b",
  "active_statement_hash": "f85385dacf30f6c1486e332e8f3b0798cf2370a6290a396f2b8093a1ad5764a2",
  "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-119",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "InvalidOverflowBoundaryWitness": "7da3742aef5e9c73"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "1696fb9af4405e6e",
    "DecimalGoalVocabularyDefault": "512f8d0aea894250",
    "DecimalLexeme": "8ad754cf2c272e73",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
    "F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
    "F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "SourceValidByteSlice": "3dc42716a6378d26",
    "num_float_parse_ParseFloatError": "c43614ff2149ecf2",
    "num_imp_dec2flt_dec2flt": "f9f7d93449a25efa",
    "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:5f23cccf5d61971104013ae774e3ee0f05e699dbbcc34f581fdab9d4ef78847b",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}