Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Theorem
f64 result, that result is obtained by applying the literal's lexical sign to a nonnegative magnitude word, including zero and infinity magnitudes.Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.AssemblyCorrespondence
import Tablet.DecimalGoalVocabularyDefault
import Tablet.F64
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.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64
import Tablet.ModelF64Neg
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.NativeCorrectOrDefer
import Tablet.ParserSelectedMagnitudeSign
import Tablet.SourceValidByteSlice
import Tablet.SpecialHelperRejection
import Tablet.num_imp_dec2flt_Dec2FltAssemblyTrace
import Tablet.num_imp_dec2flt_Dec2FltTrace
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
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericSign]
theorem ParserNumericSign :
∀ (s : Str) (x : DecimalLexeme) (f : F64), DecimalGoalVocabularyDefault.sourceString s ->
DecimalGoalVocabularyDefault.validNumeric x -> DecimalGoalVocabularyDefault.bytes s = DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
∃ magnitude : F64, DecimalGoalVocabularyDefault.signedMagnitude (DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f := 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
validNumeric hypothesis
says that every integer and fractional digit is below ten and that either the
integer list is nonempty or the fraction is present with a nonempty digit
list. Let B be renderNumeric x with its leading-sign contribution
removed. Thus B is the concatenation of the integer digit bytes, the
optional point and fractional digit bytes, and the optional exponent suffix.
It is nonempty: if the integer list is nonempty its first byte is 48+d for
some d<10, while if that list is empty, validity supplies a present nonempty
fraction and B begins with the point byte 46. In particular, the first
byte of B is in \{48,\ldots,57\} or is 46, and hence is neither sign
byte 43 nor 45.none, the complete byte list is B. The
sourceString hypothesis and ModelStrAsBytes say that the
first bind in num imp dec2flt dec2flt with trace returns the
identical complete ordered slice, and ModelSliceFirst returns its
actual head. The extracted sign tests therefore remove exactly the initial
45 or 43 in the first two cases and remove nothing in the third. The
range-from-one call is in bounds because the signed inputs are nonempty, and
returns precisely their tail B; every branch consequently reaches the
nonempty body B. Moreover its Boolean
lexicalNegative in DecimalGoalVocabularyDefault,
EmptyInput nor SignOnly constructor listed
by num imp dec2flt Dec2FltTrace can describe this execution.specialLiteral
in DecimalGoalVocabularyDefault, an unsigned infinity spelling has
first byte 105 or 73 (lower- or uppercase ASCII i), and an
unsigned NaN spelling has first byte 110 or 78 (lower- or uppercase ASCII
n). This follows directly from the first pair in the
asciiCaseEq relation: for lower byte 105 the actual byte is 105
or satisfies a+32=105, hence is 73, and similarly for lower byte 110.
Neither possibility equals a digit byte or 46. Thus
inf and the
eight-byte infinity alternatives; the second excludes nan.
Together with the source-valid body just proved, (2) lets us apply
SpecialHelperRejection for the separate Boolean argument
\mathit{neg}. The concrete Lemire record
F64 Insts Dec2flt modelNumImpDec2fltLemireU64 selects
F64 Insts Dec2flt modelNumImpTraitsFloatExtU64, whose
FloatInst field is exactly
F64 Insts Dec2flt modelNumImpTraitsFloatU64; hence the helper call
in the dispatcher is literally the one in the cited rejection theorem. We
obtain
ok (r,tr) return makes it ok r. Injectivity of
ok, followed by injectivity of the successful
core.result.Result.Ok constructor against the public hypothesis,
therefore supplies a trace tr_0 with
parse_number in the traced definition must return
normally, since a failed bind would contradict (4). Suppose first that its
option result were none. Equation (3) says that the following
special-helper bind also returns none. The only remaining code in
that branch binds the invalid-error constructor. If that bind fails, (4) is
impossible; if it succeeds, the branch returns Err with an
Invalid trace, contradicting the Ok f first component of
(4) by constructor disjointness. Consequently the numeric helper returned
some r for a record r. The dispatcher passes exactly
try_fast_path; in particular
d.\mathit{negative}=\mathit{neg}. Its bind too must return normally.some v. Apply
NativeCorrectOrDefer to the exact record (5) and the equality
try_fast_path(d) = ok (some v). Its none
alternative contradicts constructor disjointness. The other alternative
supplies v' and a magnitude m such that
some v = some v' and
signedMagnitude(d.negative,m,v'); option-constructor injectivity
gives v=v'. The some branch of
num imp dec2flt dec2flt with trace returns exactly
Ok v with a FastPath constructor from
num imp dec2flt Dec2FltTrace. Comparing this return with (4) gives
f=v. Substituting this equality, (5), and (1) into the supplied
signed-magnitude relation proves the conclusion with witness m. Notice
that no acceptance theorem for the unrestricted numeric helper was used.try_fast_path(d) = ok none. The remainder
of the extracted definition computes its first raw pair, its optional second
pair, any forced deferral, and the optional slow replacement. Every one of
these operations is bound in the result monad. Thus any failed compute,
checked increment, comparison, slow parse, cast, constant lookup, shift, OR,
assembly, or final negation would propagate a failure and contradict (4).
Following the successful binds leaves a selected pair p, an assembled U64
word w, and an assembly result a. The declaration schema
num imp dec2flt Dec2FltAssemblyTrace and the record literal in
num imp dec2flt dec2flt with trace give a record tr with
Assembled tr. The constructor schema
num imp dec2flt Dec2FltTrace, disjointness from its other five
constructors, and injectivity of Assembled identify this exact tr
with tr_0 in (4). In the nonnegative branch the same record literal has
tr.\mathit{negative}=\mathsf{false},
tr.\mathit{lexical\_sign\_applied}=\mathsf{false}, and
tr.\mathit{result}=a=f; in the negative branch all three corresponding
facts are true except that the last field is the successfully negated result
f. Since the branch test is precisely c=45, (1) says these are exactly
the two cases of lexicalNegative x.Assembled tr trace. With (6)
it yields
ok a. Determinism of this definition and injectivity of
ok therefore give a'=a.assembledWord
from DecimalGoalVocabularyDefault, its right side is the single raw
word formula determined by p. The relations in (7) and (8) therefore give
w.\mathit{val}=a.\mathit{val}. Since F64 identifies F64 with
the same one-field 64-bit carrier as U64, carrier extensionality identifies
w=a; in particular (7) gives
lexicalNegative x is false, the nonnegative record facts above give
f=a. By (9), unfolding signedMagnitude in
DecimalGoalVocabularyDefault asks for
a.\mathit{val}<2^{63} and
f.\mathit{val}=a.\mathit{val}+0, both of which hold. This case includes
both an absent leading sign and a leading plus.lexicalNegative x is true, the last successful bind invokes the
concrete negation record F64 Insts CoreOpsArithNegF64 on a. Its
bound semantics ModelF64Neg toggles exactly bit 63. Bound (9) says that bit was
clear, so its xor with 2^{63} is the disjoint-bit sum
a.\mathit{val}+2^{63}, with every lower magnitude bit unchanged. The
negative record field and (4) identify that returned word with f. Hence
signedMagnitude(true,a,f). The argument used only the clear
sign-bit bound, so it includes magnitude zero and the positive-infinity
magnitude as required.Lean proof
intro s x f hsource hvalid hbytes hpublic
have bind_ok_inv : ∀ {α β : Type} (r : Result α) (g : α → Result β) y,
Bind.bind r g = ok y → ∃ z, r = ok z ∧ g z = ok y := by
intro α β r g y hr
cases r with
| fail err => simp [Bind.bind, Aeneas.Std.bind] at hr
| div => simp [Bind.bind, Aeneas.Std.bind] at hr
| ok z => exact ⟨z, rfl, hr⟩
have numeric_head : ∀ (y : DecimalLexeme),
y.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric y ->
∃ n rest, DecimalGoalVocabularyDefault.renderNumeric y = n :: rest ∧
(n = 46 ∨ (48 ≤ n ∧ n ≤ 57)) := by
intro y hsign hval
rcases y with ⟨sign, ints, frac, exp⟩
simp only at hsign
subst sign
dsimp only [DecimalGoalVocabularyDefault] at hval ⊢
rcases hval with ⟨hints, hfrac, hnonempty, hexp⟩
cases ints with
| nil =>
simp only [List.map_nil, List.nil_append] at hnonempty ⊢
cases frac with
| none => simp at hnonempty
| some ds =>
cases ds with
| nil => simp at hnonempty
| cons d ds => exact ⟨46, _, rfl, Or.inl rfl⟩
| cons d ds =>
have hd : d < 10 := hints d (by simp)
exact ⟨48 + d, _, rfl, Or.inr (by omega)⟩
have numeric_not_special : ∀ (y : DecimalLexeme) (nan : Bool),
y.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric y ->
¬ DecimalGoalVocabularyDefault.specialLiteral
(DecimalGoalVocabularyDefault.renderNumeric y) none nan := by
intro y nan hsign hval hspecial
obtain ⟨n, rest, hrender, hn⟩ := numeric_head y hsign hval
rcases hspecial with ⟨body, hbody, hcase⟩
change DecimalGoalVocabularyDefault.renderNumeric y = body at hbody
rw [hrender] at hbody
cases hbody
dsimp only [DecimalGoalVocabularyDefault] at hcase
cases nan with
| false =>
simp only [Bool.false_eq_true, if_false] at hcase
rcases hcase with hcase | hcase
· cases hcase
rename_i hfirst _
rcases hfirst with hfirst | hfirst <;> omega
· cases hcase
rename_i hfirst _
rcases hfirst with hfirst | hfirst <;> omega
| true =>
simp only [if_true] at hcase
cases hcase
rename_i hfirst _
rcases hfirst with hfirst | hfirst <;> omega
let unsigned : DecimalLexeme := { x with leadingSign := none }
have unsigned_sign : unsigned.leadingSign = none := rfl
have unsigned_valid : DecimalGoalVocabularyDefault.validNumeric unsigned := by
simpa [DecimalGoalVocabularyDefault, unsigned] using hvalid
obtain ⟨head, rest, unsigned_render, head_range⟩ :=
numeric_head unsigned unsigned_sign unsigned_valid
unfold num.imp.dec2flt.dec2flt at hpublic
obtain ⟨out, hout, hpublic⟩ := bind_ok_inv _ _ _ hpublic
rcases out with ⟨publicResult, trace⟩
cases hpublic
have traced :
num.imp.dec2flt.dec2flt_with_trace
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f, trace) := hout
rcases s with ⟨source, source_bound⟩
cases source with
| nil =>
dsimp only [DecimalGoalVocabularyDefault] at hbytes
cases hs : x.leadingSign with
| none =>
have : DecimalGoalVocabularyDefault.renderNumeric x = [] := hbytes.symm
obtain ⟨n, tail, hn, _⟩ := numeric_head x hs hvalid
rw [hn] at this
simp at this
| some sign =>
cases sign <;> simp [DecimalGoalVocabularyDefault, hs] at hbytes
| cons first tail =>
unfold num.imp.dec2flt.dec2flt_with_trace at traced
obtain ⟨body, hbody, traced⟩ := bind_ok_inv _ _ _ traced
have hbodyEq : body = (⟨first :: tail, source_bound⟩ : Slice Std.U8) := by
simpa [core.str.Str.as_bytes, ModelStrAsBytes] using hbody.symm
subst body
obtain ⟨firstOption, hfirst, traced⟩ := bind_ok_inv _ _ _ traced
have hfirstEq : firstOption = some first := by
simpa [core.slice.Slice.first, ModelSliceFirst] using hfirst.symm
subst firstOption
obtain ⟨body1, hbody1, traced⟩ := bind_ok_inv _ _ _ traced
have lexical :
body1.val ≠ [] ∧ SourceValidByteSlice body1 ∧
DecimalGoalVocabularyDefault.bytes body1 =
DecimalGoalVocabularyDefault.renderNumeric unsigned ∧
(decide (first = 45#u8) : Bool) =
DecimalGoalVocabularyDefault.lexicalNegative x := by
cases hsign : x.leadingSign with
| none =>
have full : first.val :: tail.map (fun b => b.val) = head :: rest := by
calc
first.val :: tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric x := hbytes
_ = DecimalGoalVocabularyDefault.renderNumeric unsigned := by
simp [DecimalGoalVocabularyDefault, unsigned, hsign]
_ = head :: rest := unsigned_render
have firstVal : first.val = head := (List.cons.inj full).1
have hminus : first ≠ 45#u8 := by
intro heq
subst first
simp at firstVal
rcases head_range with hr | hr <;> omega
have hplus : first ≠ 43#u8 := by
intro heq
subst first
simp at firstVal
rcases head_range with hr | hr <;> omega
simp only [hminus, hplus, if_false] at hbody1
cases hbody1
refine ⟨by simp, ?_, ?_, ?_⟩
· exact hsource.1
· simpa [DecimalGoalVocabularyDefault, unsigned, hsign] using hbytes
· simp [DecimalGoalVocabularyDefault, hsign, hminus]
| some sign =>
cases sign with
| false =>
have full : first.val :: tail.map (fun b => b.val) =
43 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
calc
first.val :: tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric x := hbytes
_ = 43 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
simp [DecimalGoalVocabularyDefault, unsigned, hsign]
have firstVal : first.val = 43 := (List.cons.inj full).1
have firstEq : first = 43#u8 := UScalar.eq_of_val_eq firstVal
have tailRender : tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric unsigned :=
(List.cons.inj full).2
simp only [firstEq, reduceCtorEq, if_false, if_true] at hbody1
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop] at hbody1
cases hbody1
refine ⟨?_, ?_, ?_, ?_⟩
· intro hempty
have tailEmpty : tail = [] := by simpa using hempty
rw [tailEmpty] at tailRender
simp at tailRender
rw [unsigned_render] at tailRender
simp at tailRender
· unfold SourceValidByteSlice
have hslen := hsource.1
simp at hslen ⊢
omega
· exact tailRender
· simp [DecimalGoalVocabularyDefault, hsign, firstEq]
| true =>
have full : first.val :: tail.map (fun b => b.val) =
45 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
calc
first.val :: tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric x := hbytes
_ = 45 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
simp [DecimalGoalVocabularyDefault, unsigned, hsign]
have firstVal : first.val = 45 := (List.cons.inj full).1
have firstEq : first = 45#u8 := UScalar.eq_of_val_eq firstVal
have tailRender : tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric unsigned :=
(List.cons.inj full).2
simp only [firstEq, if_true] at hbody1
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop] at hbody1
cases hbody1
refine ⟨?_, ?_, ?_, ?_⟩
· intro hempty
have tailEmpty : tail = [] := by simpa using hempty
rw [tailEmpty] at tailRender
simp at tailRender
rw [unsigned_render] at tailRender
simp at tailRender
· unfold SourceValidByteSlice
have hslen := hsource.1
simp at hslen ⊢
omega
· exact tailRender
· simp [DecimalGoalVocabularyDefault, hsign, firstEq]
rcases lexical with ⟨bodyNonempty, bodyValid, bodyRender, signEq⟩
have noInf : ¬ DecimalGoalVocabularyDefault.specialLiteral
(DecimalGoalVocabularyDefault.bytes body1) none false := by
rw [bodyRender]
exact numeric_not_special unsigned false unsigned_sign unsigned_valid
have noNan : ¬ DecimalGoalVocabularyDefault.specialLiteral
(DecimalGoalVocabularyDefault.bytes body1) none true := by
rw [bodyRender]
exact numeric_not_special unsigned true unsigned_sign unsigned_valid
have specialReject :=
SpecialHelperRejection body1 (decide (first = 45#u8))
bodyValid noInf noNan
obtain ⟨empty, hempty, traced⟩ := bind_ok_inv _ _ _ traced
by_cases emptyTrue : empty = true
· simp only [emptyTrue, if_true] at traced
obtain ⟨pfe, hpfe, traced⟩ := bind_ok_inv _ _ _ traced
cases traced
· have emptyFalse : empty = false := Bool.eq_false_of_not_eq_true emptyTrue
simp only [emptyFalse, if_false] at traced
obtain ⟨parsed, hparsed, traced⟩ := bind_ok_inv _ _ _ traced
cases parsed with
| none =>
obtain ⟨special, hspecial, traced⟩ := bind_ok_inv _ _ _ traced
rw [specialReject] at hspecial
cases hspecial
obtain ⟨pfe, hpfe, traced⟩ := bind_ok_inv _ _ _ traced
cases traced
| some r =>
obtain ⟨fast, hfast, traced⟩ := bind_ok_inv _ _ _ traced
cases fast with
| some value =>
have hnative := NativeCorrectOrDefer
({ r with negative := decide (first = 45#u8) })
(some value) hfast
rcases hnative with hnone | ⟨value', magnitude, hvalue, _, _, hsigned⟩
· simp at hnone
· cases hvalue
cases traced
refine ⟨magnitude, ?_⟩
simpa [signEq] using hsigned
| none =>
obtain ⟨firstPair, hfirstPair, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨phase1, hphase1, traced⟩ := bind_ok_inv _ _ _ traced
rcases phase1 with ⟨many1, many2, firstPair1, fp, guard⟩
obtain ⟨phase2, hphase2, traced⟩ := bind_ok_inv _ _ _ traced
rcases phase2 with
⟨post, secondExp, secondMant, secondResult, secondEqual, forced⟩
obtain ⟨phase3, hphase3, traced⟩ := bind_ok_inv _ _ _ traced
rcases phase3 with ⟨selected, slowGuard, slowResult⟩
obtain ⟨i, hi, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨i1, hi1, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨i2, hi2, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨word, hword, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨assembled, hassembled, traced⟩ := bind_ok_inv _ _ _ traced
by_cases negative : first = 45#u8
· simp only [negative, if_true] at traced
obtain ⟨result, hresult, traced⟩ := bind_ok_inv _ _ _ traced
cases traced
obtain ⟨wordSpec, wordBound⟩ :=
ParserSelectedMagnitudeSign
(⟨first :: tail, source_bound⟩ : Str) f _ hsource hout
change DecimalGoalVocabularyDefault.assembledWord selected word at wordSpec
change word.val < 2 ^ 63 at wordBound
obtain ⟨canonical, hcanonical, canonicalSpec⟩ :=
AssemblyCorrespondence selected
rw [hassembled] at hcanonical
cases hcanonical
have assembledVal : assembled.val = word.val := by
dsimp only [DecimalGoalVocabularyDefault] at wordSpec canonicalSpec
exact canonicalSpec.trans wordSpec.symm
have assembledBound : assembled.val < 2 ^ 63 := by omega
refine ⟨assembled, ?_⟩
rw [← signEq]
simp only [negative, decide_true]
change ModelF64Neg assembled = ok f at hresult
cases hresult
dsimp only [DecimalGoalVocabularyDefault]
refine ⟨assembledBound, ?_⟩
have hxor : assembled.val ^^^ (2 ^ 63) =
(2 ^ 63) ||| assembled.val := by
apply Nat.eq_of_testBit_eq
intro k
rw [Nat.testBit_xor, Nat.testBit_or, Nat.testBit_two_pow]
by_cases hk : k = 63
· subst k
rw [Nat.testBit_lt_two_pow assembledBound]
decide
· have hk' : 63 ≠ k := Ne.symm hk
simp [hk, hk']
have hor : (2 ^ 63) ||| assembled.val =
assembled.val + 2 ^ 63 := by
have h := Nat.two_pow_add_eq_or_of_lt assembledBound 1
simpa [Nat.add_comm] using h.symm
change (assembled.bv ^^^ BitVec.ofNat 64 (2 ^ 63)).toNat =
assembled.val + 2 ^ 63
rw [BitVec.toNat_xor, BitVec.toNat_ofNat]
norm_num
exact hxor.trans hor
· simp only [negative, if_false] at traced
cases traced
obtain ⟨wordSpec, wordBound⟩ :=
ParserSelectedMagnitudeSign
(⟨first :: tail, source_bound⟩ : Str) f _ hsource hout
change DecimalGoalVocabularyDefault.assembledWord selected word at wordSpec
change word.val < 2 ^ 63 at wordBound
obtain ⟨canonical, hcanonical, canonicalSpec⟩ :=
AssemblyCorrespondence selected
rw [hassembled] at hcanonical
cases hcanonical
have assembledVal : f.val = word.val := by
dsimp only [DecimalGoalVocabularyDefault] at wordSpec canonicalSpec
exact canonicalSpec.trans wordSpec.symm
have assembledBound : f.val < 2 ^ 63 := by omega
refine ⟨f, ?_⟩
rw [← signEq]
simp only [negative, decide_false]
dsimp only [DecimalGoalVocabularyDefault]
exact ⟨assembledBound, by simp⟩
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.AssemblyCorrespondence
import Tablet.DecimalGoalVocabularyDefault
import Tablet.F64
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.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64
import Tablet.ModelF64Neg
import Tablet.ModelSliceFirst
import Tablet.ModelStrAsBytes
import Tablet.NativeCorrectOrDefer
import Tablet.ParserSelectedMagnitudeSign
import Tablet.SourceValidByteSlice
import Tablet.SpecialHelperRejection
import Tablet.num_imp_dec2flt_Dec2FltAssemblyTrace
import Tablet.num_imp_dec2flt_Dec2FltTrace
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
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ParserNumericSign]
theorem ParserNumericSign :
∀ (s : Str) (x : DecimalLexeme) (f : F64), DecimalGoalVocabularyDefault.sourceString s ->
DecimalGoalVocabularyDefault.validNumeric x -> DecimalGoalVocabularyDefault.bytes s = DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
∃ magnitude : F64, DecimalGoalVocabularyDefault.signedMagnitude (DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f := by
-- BODY
intro s x f hsource hvalid hbytes hpublic
have bind_ok_inv : ∀ {α β : Type} (r : Result α) (g : α → Result β) y,
Bind.bind r g = ok y → ∃ z, r = ok z ∧ g z = ok y := by
intro α β r g y hr
cases r with
| fail err => simp [Bind.bind, Aeneas.Std.bind] at hr
| div => simp [Bind.bind, Aeneas.Std.bind] at hr
| ok z => exact ⟨z, rfl, hr⟩
have numeric_head : ∀ (y : DecimalLexeme),
y.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric y ->
∃ n rest, DecimalGoalVocabularyDefault.renderNumeric y = n :: rest ∧
(n = 46 ∨ (48 ≤ n ∧ n ≤ 57)) := by
intro y hsign hval
rcases y with ⟨sign, ints, frac, exp⟩
simp only at hsign
subst sign
dsimp only [DecimalGoalVocabularyDefault] at hval ⊢
rcases hval with ⟨hints, hfrac, hnonempty, hexp⟩
cases ints with
| nil =>
simp only [List.map_nil, List.nil_append] at hnonempty ⊢
cases frac with
| none => simp at hnonempty
| some ds =>
cases ds with
| nil => simp at hnonempty
| cons d ds => exact ⟨46, _, rfl, Or.inl rfl⟩
| cons d ds =>
have hd : d < 10 := hints d (by simp)
exact ⟨48 + d, _, rfl, Or.inr (by omega)⟩
have numeric_not_special : ∀ (y : DecimalLexeme) (nan : Bool),
y.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric y ->
¬ DecimalGoalVocabularyDefault.specialLiteral
(DecimalGoalVocabularyDefault.renderNumeric y) none nan := by
intro y nan hsign hval hspecial
obtain ⟨n, rest, hrender, hn⟩ := numeric_head y hsign hval
rcases hspecial with ⟨body, hbody, hcase⟩
change DecimalGoalVocabularyDefault.renderNumeric y = body at hbody
rw [hrender] at hbody
cases hbody
dsimp only [DecimalGoalVocabularyDefault] at hcase
cases nan with
| false =>
simp only [Bool.false_eq_true, if_false] at hcase
rcases hcase with hcase | hcase
· cases hcase
rename_i hfirst _
rcases hfirst with hfirst | hfirst <;> omega
· cases hcase
rename_i hfirst _
rcases hfirst with hfirst | hfirst <;> omega
| true =>
simp only [if_true] at hcase
cases hcase
rename_i hfirst _
rcases hfirst with hfirst | hfirst <;> omega
let unsigned : DecimalLexeme := { x with leadingSign := none }
have unsigned_sign : unsigned.leadingSign = none := rfl
have unsigned_valid : DecimalGoalVocabularyDefault.validNumeric unsigned := by
simpa [DecimalGoalVocabularyDefault, unsigned] using hvalid
obtain ⟨head, rest, unsigned_render, head_range⟩ :=
numeric_head unsigned unsigned_sign unsigned_valid
unfold num.imp.dec2flt.dec2flt at hpublic
obtain ⟨out, hout, hpublic⟩ := bind_ok_inv _ _ _ hpublic
rcases out with ⟨publicResult, trace⟩
cases hpublic
have traced :
num.imp.dec2flt.dec2flt_with_trace
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s =
ok (core.result.Result.Ok f, trace) := hout
rcases s with ⟨source, source_bound⟩
cases source with
| nil =>
dsimp only [DecimalGoalVocabularyDefault] at hbytes
cases hs : x.leadingSign with
| none =>
have : DecimalGoalVocabularyDefault.renderNumeric x = [] := hbytes.symm
obtain ⟨n, tail, hn, _⟩ := numeric_head x hs hvalid
rw [hn] at this
simp at this
| some sign =>
cases sign <;> simp [DecimalGoalVocabularyDefault, hs] at hbytes
| cons first tail =>
unfold num.imp.dec2flt.dec2flt_with_trace at traced
obtain ⟨body, hbody, traced⟩ := bind_ok_inv _ _ _ traced
have hbodyEq : body = (⟨first :: tail, source_bound⟩ : Slice Std.U8) := by
simpa [core.str.Str.as_bytes, ModelStrAsBytes] using hbody.symm
subst body
obtain ⟨firstOption, hfirst, traced⟩ := bind_ok_inv _ _ _ traced
have hfirstEq : firstOption = some first := by
simpa [core.slice.Slice.first, ModelSliceFirst] using hfirst.symm
subst firstOption
obtain ⟨body1, hbody1, traced⟩ := bind_ok_inv _ _ _ traced
have lexical :
body1.val ≠ [] ∧ SourceValidByteSlice body1 ∧
DecimalGoalVocabularyDefault.bytes body1 =
DecimalGoalVocabularyDefault.renderNumeric unsigned ∧
(decide (first = 45#u8) : Bool) =
DecimalGoalVocabularyDefault.lexicalNegative x := by
cases hsign : x.leadingSign with
| none =>
have full : first.val :: tail.map (fun b => b.val) = head :: rest := by
calc
first.val :: tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric x := hbytes
_ = DecimalGoalVocabularyDefault.renderNumeric unsigned := by
simp [DecimalGoalVocabularyDefault, unsigned, hsign]
_ = head :: rest := unsigned_render
have firstVal : first.val = head := (List.cons.inj full).1
have hminus : first ≠ 45#u8 := by
intro heq
subst first
simp at firstVal
rcases head_range with hr | hr <;> omega
have hplus : first ≠ 43#u8 := by
intro heq
subst first
simp at firstVal
rcases head_range with hr | hr <;> omega
simp only [hminus, hplus, if_false] at hbody1
cases hbody1
refine ⟨by simp, ?_, ?_, ?_⟩
· exact hsource.1
· simpa [DecimalGoalVocabularyDefault, unsigned, hsign] using hbytes
· simp [DecimalGoalVocabularyDefault, hsign, hminus]
| some sign =>
cases sign with
| false =>
have full : first.val :: tail.map (fun b => b.val) =
43 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
calc
first.val :: tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric x := hbytes
_ = 43 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
simp [DecimalGoalVocabularyDefault, unsigned, hsign]
have firstVal : first.val = 43 := (List.cons.inj full).1
have firstEq : first = 43#u8 := UScalar.eq_of_val_eq firstVal
have tailRender : tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric unsigned :=
(List.cons.inj full).2
simp only [firstEq, reduceCtorEq, if_false, if_true] at hbody1
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop] at hbody1
cases hbody1
refine ⟨?_, ?_, ?_, ?_⟩
· intro hempty
have tailEmpty : tail = [] := by simpa using hempty
rw [tailEmpty] at tailRender
simp at tailRender
rw [unsigned_render] at tailRender
simp at tailRender
· unfold SourceValidByteSlice
have hslen := hsource.1
simp at hslen ⊢
omega
· exact tailRender
· simp [DecimalGoalVocabularyDefault, hsign, firstEq]
| true =>
have full : first.val :: tail.map (fun b => b.val) =
45 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
calc
first.val :: tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric x := hbytes
_ = 45 :: DecimalGoalVocabularyDefault.renderNumeric unsigned := by
simp [DecimalGoalVocabularyDefault, unsigned, hsign]
have firstVal : first.val = 45 := (List.cons.inj full).1
have firstEq : first = 45#u8 := UScalar.eq_of_val_eq firstVal
have tailRender : tail.map (fun b => b.val) =
DecimalGoalVocabularyDefault.renderNumeric unsigned :=
(List.cons.inj full).2
simp only [firstEq, if_true] at hbody1
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop] at hbody1
cases hbody1
refine ⟨?_, ?_, ?_, ?_⟩
· intro hempty
have tailEmpty : tail = [] := by simpa using hempty
rw [tailEmpty] at tailRender
simp at tailRender
rw [unsigned_render] at tailRender
simp at tailRender
· unfold SourceValidByteSlice
have hslen := hsource.1
simp at hslen ⊢
omega
· exact tailRender
· simp [DecimalGoalVocabularyDefault, hsign, firstEq]
rcases lexical with ⟨bodyNonempty, bodyValid, bodyRender, signEq⟩
have noInf : ¬ DecimalGoalVocabularyDefault.specialLiteral
(DecimalGoalVocabularyDefault.bytes body1) none false := by
rw [bodyRender]
exact numeric_not_special unsigned false unsigned_sign unsigned_valid
have noNan : ¬ DecimalGoalVocabularyDefault.specialLiteral
(DecimalGoalVocabularyDefault.bytes body1) none true := by
rw [bodyRender]
exact numeric_not_special unsigned true unsigned_sign unsigned_valid
have specialReject :=
SpecialHelperRejection body1 (decide (first = 45#u8))
bodyValid noInf noNan
obtain ⟨empty, hempty, traced⟩ := bind_ok_inv _ _ _ traced
by_cases emptyTrue : empty = true
· simp only [emptyTrue, if_true] at traced
obtain ⟨pfe, hpfe, traced⟩ := bind_ok_inv _ _ _ traced
cases traced
· have emptyFalse : empty = false := Bool.eq_false_of_not_eq_true emptyTrue
simp only [emptyFalse, if_false] at traced
obtain ⟨parsed, hparsed, traced⟩ := bind_ok_inv _ _ _ traced
cases parsed with
| none =>
obtain ⟨special, hspecial, traced⟩ := bind_ok_inv _ _ _ traced
rw [specialReject] at hspecial
cases hspecial
obtain ⟨pfe, hpfe, traced⟩ := bind_ok_inv _ _ _ traced
cases traced
| some r =>
obtain ⟨fast, hfast, traced⟩ := bind_ok_inv _ _ _ traced
cases fast with
| some value =>
have hnative := NativeCorrectOrDefer
({ r with negative := decide (first = 45#u8) })
(some value) hfast
rcases hnative with hnone | ⟨value', magnitude, hvalue, _, _, hsigned⟩
· simp at hnone
· cases hvalue
cases traced
refine ⟨magnitude, ?_⟩
simpa [signEq] using hsigned
| none =>
obtain ⟨firstPair, hfirstPair, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨phase1, hphase1, traced⟩ := bind_ok_inv _ _ _ traced
rcases phase1 with ⟨many1, many2, firstPair1, fp, guard⟩
obtain ⟨phase2, hphase2, traced⟩ := bind_ok_inv _ _ _ traced
rcases phase2 with
⟨post, secondExp, secondMant, secondResult, secondEqual, forced⟩
obtain ⟨phase3, hphase3, traced⟩ := bind_ok_inv _ _ _ traced
rcases phase3 with ⟨selected, slowGuard, slowResult⟩
obtain ⟨i, hi, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨i1, hi1, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨i2, hi2, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨word, hword, traced⟩ := bind_ok_inv _ _ _ traced
obtain ⟨assembled, hassembled, traced⟩ := bind_ok_inv _ _ _ traced
by_cases negative : first = 45#u8
· simp only [negative, if_true] at traced
obtain ⟨result, hresult, traced⟩ := bind_ok_inv _ _ _ traced
cases traced
obtain ⟨wordSpec, wordBound⟩ :=
ParserSelectedMagnitudeSign
(⟨first :: tail, source_bound⟩ : Str) f _ hsource hout
change DecimalGoalVocabularyDefault.assembledWord selected word at wordSpec
change word.val < 2 ^ 63 at wordBound
obtain ⟨canonical, hcanonical, canonicalSpec⟩ :=
AssemblyCorrespondence selected
rw [hassembled] at hcanonical
cases hcanonical
have assembledVal : assembled.val = word.val := by
dsimp only [DecimalGoalVocabularyDefault] at wordSpec canonicalSpec
exact canonicalSpec.trans wordSpec.symm
have assembledBound : assembled.val < 2 ^ 63 := by omega
refine ⟨assembled, ?_⟩
rw [← signEq]
simp only [negative, decide_true]
change ModelF64Neg assembled = ok f at hresult
cases hresult
dsimp only [DecimalGoalVocabularyDefault]
refine ⟨assembledBound, ?_⟩
have hxor : assembled.val ^^^ (2 ^ 63) =
(2 ^ 63) ||| assembled.val := by
apply Nat.eq_of_testBit_eq
intro k
rw [Nat.testBit_xor, Nat.testBit_or, Nat.testBit_two_pow]
by_cases hk : k = 63
· subst k
rw [Nat.testBit_lt_two_pow assembledBound]
decide
· have hk' : 63 ≠ k := Ne.symm hk
simp [hk, hk']
have hor : (2 ^ 63) ||| assembled.val =
assembled.val + 2 ^ 63 := by
have h := Nat.two_pow_add_eq_or_of_lt assembledBound 1
simpa [Nat.add_comm] using h.symm
change (assembled.bv ^^^ BitVec.ofNat 64 (2 ^ 63)).toNat =
assembled.val + 2 ^ 63
rw [BitVec.toNat_xor, BitVec.toNat_ofNat]
norm_num
exact hxor.trans hor
· simp only [negative, if_false] at traced
cases traced
obtain ⟨wordSpec, wordBound⟩ :=
ParserSelectedMagnitudeSign
(⟨first :: tail, source_bound⟩ : Str) f _ hsource hout
change DecimalGoalVocabularyDefault.assembledWord selected word at wordSpec
change word.val < 2 ^ 63 at wordBound
obtain ⟨canonical, hcanonical, canonicalSpec⟩ :=
AssemblyCorrespondence selected
rw [hassembled] at hcanonical
cases hcanonical
have assembledVal : f.val = word.val := by
dsimp only [DecimalGoalVocabularyDefault] at wordSpec canonicalSpec
exact canonicalSpec.trans wordSpec.symm
have assembledBound : f.val < 2 ^ 63 := by omega
refine ⟨f, ?_⟩
rw [← signEq]
simp only [negative, decide_false]
dsimp only [DecimalGoalVocabularyDefault]
exact ⟨assembledBound, by simp⟩
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
- AssemblyCorrespondence
- DecimalGoalVocabularyDefault
- F64
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
All 26 entries
- AssemblyCorrespondence
- DecimalGoalVocabularyDefault
- F64
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64
- F64 Insts Dec2flt modelNumImpTraitsFloatU64
- ModelF64Neg
- ModelSliceFirst
- ModelStrAsBytes
- NativeCorrectOrDefer
- ParserSelectedMagnitudeSign
- SourceValidByteSlice
- SpecialHelperRejection
- num imp dec2flt Dec2FltAssemblyTrace
- num imp dec2flt Dec2FltTrace
- num imp dec2flt biased fp to float
- num imp dec2flt dec2flt
- num imp dec2flt dec2flt with trace
- num imp dec2flt decimal Decimal try fast path
- num imp dec2flt lemire compute float
- num imp dec2flt parse parse inf nan
- num imp dec2flt parse parse number
- num imp dec2flt slow parse long mantissa
Used by
No other declaration in this version lists this one as a dependency.
Inspect related source (201)
More program dependencies (159)
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- biased_fp_to_float · dec2flt/mod.rs:282 Program Rust
- dec2flt · dec2flt/mod.rs:508 Program Rust
- dec2flt_with_trace · dec2flt/mod.rs:355 Program Rust
- try_fast_path · dec2flt/decimal.rs:59 Program Rust
- compute_float · dec2flt/lemire.rs:26 Program Rust
- parse_inf_nan · dec2flt/parse.rs:241 Program Rust
- parse_number · dec2flt/parse.rs:231 Program Rust
- parse_long_mantissa · dec2flt/slow.rs:27 Program Rust
- parse_long_mantissa_loop0 · dec2flt/slow.rs:51 Program Rust
- body · dec2flt/slow.rs:51 Program Rust
- parse_long_mantissa_loop1 · dec2flt/slow.rs:69 Program Rust
- body · dec2flt/slow.rs:69 Program Rust
- parse_long_mantissa_loop2 · dec2flt/slow.rs:94 Program Rust
- body · dec2flt/slow.rs:94 Program Rust
- MAX_EXPONENT_DISGUISED_FAST_PATH · dec2flt/mod.rs:220 Program Rust
- MAX_EXPONENT_FAST_PATH · dec2flt/mod.rs:219 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
- pow10_fast_path · dec2flt/mod.rs:222 Program Rust
- from_u64_bits · traits.rs:341 Program Rust
- integer_decode · traits.rs:348 Program Rust
- BITS · traits.rs:319 Program Rust
- EXP_MASK · traits.rs:321 Program Rust
- INFINITY · traits.rs:312 Program Rust
- LARGEST_POWER_OF_TEN · traits.rs:327 Program Rust
- MAX_EXPONENT_ROUND_TO_EVEN · traits.rs:325 Program Rust
- MIN_EXPONENT_ROUND_TO_EVEN · traits.rs:324 Program Rust
- NAN · traits.rs:314 Program Rust
- NEG_INFINITY · traits.rs:313 Program Rust
- NEG_NAN · traits.rs:317 Program Rust
- SIG_MASK · traits.rs:322 Program Rust
- SIG_TOTAL_BITS · traits.rs:320 Program Rust
- SMALLEST_POWER_OF_TEN · traits.rs:328 Program Rust
- classify · traits.rs:334 Program Rust
- to_bits · traits.rs:330 Program Rust
- read_u64 · dec2flt/common.rs:18 Program Rust
- Dec2flt_modelNumImpTraitsInt · traits.rs:51 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- default · dec2flt/mod.rs:128 Program Rust
- default · dec2flt/mod.rs:121 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- eq · dec2flt/common.rs:51 Program Rust
- zero_pow2 · dec2flt/common.rs:62 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- can_use_fast_path · dec2flt/decimal.rs:42 Program Rust
- INT_POW10 · dec2flt/decimal.rs:8 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- DECIMAL_POINT_RANGE · dec2flt/decimal_seq.rs:67 Program Rust
- left_shift · dec2flt/decimal_seq.rs:129 Program Rust
- left_shift_loop0 · dec2flt/decimal_seq.rs:138 Program Rust
- body · dec2flt/decimal_seq.rs:138 Program Rust
- left_shift_loop1 · dec2flt/decimal_seq.rs:152 Program Rust
- body · dec2flt/decimal_seq.rs:152 Program Rust
- right_shift · dec2flt/decimal_seq.rs:175 Program Rust
- right_shift_loop0 · dec2flt/decimal_seq.rs:180 Program Rust
- body · dec2flt/decimal_seq.rs:180 Program Rust
- right_shift_loop0_loop0 · dec2flt/decimal_seq.rs:190 Program Rust
- body · dec2flt/decimal_seq.rs:190 Program Rust
- right_shift_loop1 · dec2flt/decimal_seq.rs:209 Program Rust
- body · dec2flt/decimal_seq.rs:209 Program Rust
- right_shift_loop2 · dec2flt/decimal_seq.rs:216 Program Rust
- body · dec2flt/decimal_seq.rs:216 Program Rust
- round · dec2flt/decimal_seq.rs:96 Program Rust
- round_loop · dec2flt/decimal_seq.rs:106 Program Rust
- body · dec2flt/decimal_seq.rs:106 Program Rust
- parse_decimal_seq · dec2flt/decimal_seq.rs:283 Program Rust
- parse_decimal_seq_loop0 · dec2flt/decimal_seq.rs:290 Program Rust
- body · dec2flt/decimal_seq.rs:290 Program Rust
- parse_decimal_seq_loop1 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop2 · dec2flt/decimal_seq.rs:303 Program Rust
- body · dec2flt/decimal_seq.rs:303 Program Rust
- parse_decimal_seq_loop3 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop4 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop5 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop6 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop7 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- set_precision · dec2flt/fpu.rs:99 Program Rust
- compute_product_approx · dec2flt/lemire.rs:134 Program Rust
- power · dec2flt/lemire.rs:121 Program Rust
- parse_partial_number · dec2flt/parse.rs:161 Program Rust
- pfe_empty · dec2flt/mod.rs:270 Program Rust
- pfe_invalid · dec2flt/mod.rs:277 Program Rust
- MAX_SHIFT · dec2flt/slow.rs:28 Program Rust
- call · dec2flt/slow.rs:33 Program Rust
- Float · traits.rs:74 Program Rust
- default · traits.rs:116 Program Rust
- default · traits.rs:104 Program Rust
- default · traits.rs:119 Program Rust
- default · traits.rs:110 Program Rust
- default · traits.rs:113 Program Rust
- default · traits.rs:101 Program Rust
- FloatExt · traits.rs:170 Program Rust
- offset_from · dec2flt/common.rs:30 Program Rust
- write_u64 · dec2flt/common.rs:25 Program Rust
- Dec2flt_modelNumImpTraitsCastIntoI16 · traits.rs:45 Program Rust
- ONE · traits.rs:53 Program Rust
- ZERO · traits.rs:52 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- is_8digits · dec2flt/common.rs:40 Program Rust
- default · dec2flt/decimal_seq.rs:33 Program Rust
- MAX_DIGITS · dec2flt/decimal_seq.rs:63 Program Rust
- MAX_DIGITS_WITHOUT_OVERFLOW · dec2flt/decimal_seq.rs:66 Program Rust
- trim · dec2flt/decimal_seq.rs:82 Program Rust
- trim_loop · dec2flt/decimal_seq.rs:91 Program Rust
- body · dec2flt/decimal_seq.rs:91 Program Rust
- count_trailing_zeros · dec2flt/decimal_seq.rs:235 Program Rust
- count_trailing_zeros_loop · dec2flt/decimal_seq.rs:239 Program Rust
- body · dec2flt/decimal_seq.rs:239 Program Rust
- number_of_digits_decimal_left_shift · dec2flt/decimal_seq.rs:368 Program Rust
- number_of_digits_decimal_left_shift_loop · dec2flt/decimal_seq.rs:434 Program Rust
- body · dec2flt/decimal_seq.rs:434 Program Rust
- parse_decimal_exponent · dec2flt/decimal_seq.rs:269 Program Rust
- parse_decimal_exponent_loop · dec2flt/decimal_seq.rs:272 Program Rust
- body · dec2flt/decimal_seq.rs:272 Program Rust
- parse_digits_into_seq · dec2flt/decimal_seq.rs:256 Program Rust
- parse_digits_into_seq_loop · dec2flt/decimal_seq.rs:258 Program Rust
- body · dec2flt/decimal_seq.rs:258 Program Rust
- full_multiplication · dec2flt/lemire.rs:126 Program Rust
- adjust_many_digit_count · dec2flt/parse.rs:86 Program Rust
- adjust_many_digit_count_loop · dec2flt/parse.rs:89 Program Rust
- body · dec2flt/parse.rs:89 Program Rust
- parse_many_digits · dec2flt/parse.rs:104 Program Rust
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:142 Program Rust
- body · dec2flt/parse.rs:142 Program Rust
- try_parse_digits · dec2flt/parse.rs:30 Program Rust
- try_parse_digits_loop0 · dec2flt/parse.rs:33 Program Rust
- body · dec2flt/parse.rs:33 Program Rust
- try_parse_digits_loop1 · dec2flt/parse.rs:50 Program Rust
- body · dec2flt/parse.rs:50 Program Rust
- NUM_POWERS · dec2flt/slow.rs:29 Program Rust
- POWERS · dec2flt/slow.rs:30 Program Rust
- closure · dec2flt/slow.rs:33 Program Rust
- LARGEST_POWER_OF_FIVE · dec2flt/table.rs:10 Program Rust
- POWER_OF_FIVE_128 · dec2flt/table.rs:19 Program Rust
- SMALLEST_POWER_OF_FIVE · dec2flt/table.rs:9 Program Rust
- CastInto · traits.rs:18 Program Rust
- Int · traits.rs:27 Program Rust
- cast · traits.rs:46 Program Rust
- try_add_digit · dec2flt/decimal_seq.rs:73 Program Rust
- TABLE · dec2flt/decimal_seq.rs:370 Program Rust
- TABLE_POW5 · dec2flt/decimal_seq.rs:379 Program Rust
- MIN_19DIGIT_INT · dec2flt/parse.rs:8 Program Rust
- parse_8digits · dec2flt/parse.rs:18 Program Rust
- try_parse_19digits · dec2flt/parse.rs:61 Program Rust
- try_parse_19digits_loop · dec2flt/parse.rs:64 Program Rust
- body · dec2flt/parse.rs:64 Program Rust
- MASK · dec2flt/parse.rs:19 Program Rust
- MUL1 · dec2flt/parse.rs:20 Program Rust
- MUL2 · dec2flt/parse.rs:21 Program Rust
Standard-library dependencies (39)
- neg · core/src/ops/arith.rs:719 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- as_bytes · core/src/str/mod.rs:498 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- clone · core/src/clone.rs:698 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
- INFINITY · core/src/num/f64.rs:512 Rust library
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
- NAN · core/src/num/f64.rs:509 Rust library
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
- classify · core/src/num/f64.rs:782 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- CoreOpsArithDivF64F64 · core/src/ops/arith.rs:511 Rust library
- CoreOpsArithMulF64F64 · core/src/ops/arith.rs:344 Rust library
- CoreOpsArithNegF64 · core/src/ops/arith.rs:713 Rust library
- CoreMarkerCopy · core/src/marker.rs:57 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- CoreCloneClone · core/src/clone.rs:696 Rust library
- CoreOpsBitBitAndU64U64 · core/src/ops/bit.rs:174 Rust library
- CoreOpsBitBitOrU64U64 · core/src/ops/bit.rs:278 Rust library
- CoreOpsBitShlU32U64 · core/src/ops/bit.rs:483 Rust library
- CoreOpsBitShrU32U64 · core/src/ops/bit.rs:606 Rust library
- FpCategory · core/src/num/mod.rs:1522 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
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
- Classical.choice
- Dec2Flt.configured_x86_64_numBits
- Quot.sound
- propext
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
- AssemblyCorrespondence
- Binary64AdjacentNormalValues
- Binary64ApplySign
- Binary64EncoderCarryArithmetic
- Binary64ExactPositiveDivRounds
- Binary64ExactPositiveMulRounds
All 183 entries
- AssemblyCorrespondence
- Binary64AdjacentNormalValues
- Binary64ApplySign
- Binary64EncoderCarryArithmetic
- Binary64ExactPositiveDivRounds
- Binary64ExactPositiveMulRounds
- Binary64FastPathGuard
- Binary64FastPathIndexCasts
- Binary64FiniteMagnitudeStrictMono
- Binary64FromU64Exact
- Binary64IntPow10Index
- Binary64Model
- Binary64ModelDefault
- Binary64NativeCallDomain
- Binary64NormalEncoderRounds
- Binary64Pow10FastPathExact
- Binary64ZeroDivRounds
- Binary64ZeroMulRounds
- DecimalGoalVocabulary
- DecimalGoalVocabularyDefault
- DecimalLexeme
- F64
- F64 Insts CoreCloneClone
- F64 Insts CoreMarkerCopy
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT DISGUISED FAST PATH
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT FAST PATH
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 pow10 fast path
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64 from u64 bits
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64 integer decode
- F64 Insts Dec2flt modelNumImpTraitsFloatU64
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 BITS
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 EXP MASK
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 INFINITY
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 LARGEST POWER OF TEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 MAX EXPONENT ROUND TO EVEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 MIN EXPONENT ROUND TO EVEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NAN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NEG INFINITY
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NEG NAN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG MASK
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG TOTAL BITS
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SMALLEST POWER OF TEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 classify
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 to bits
- ModelF64Classify
- ModelF64Clone
- ModelF64Div
- ModelF64ExponentMask
- ModelF64FromBits
- ModelF64FromU64
- ModelF64Infinity
- ModelF64MantissaDigits
- ModelF64MantissaMask
- ModelF64Mul
- ModelF64Nan
- ModelF64Neg
- ModelF64NegInfinity
- ModelF64ToBits
- ModelOptionBranch
- ModelOptionFromResidual
- ModelSliceFirst
- ModelSliceSplitFirst
- ModelStrAsBytes
- ModelU64BitAnd
- ModelU64BitOr
- ModelU64Shl
- ModelU64Shr
- ModelU8IsAsciiDigit
- NativeCorrectOrDefer
- NumberHelperReadEightBytes
- ParserComputeFloatExponentRange
- ParserComputeFloatMantissaBound
- ParserExponentConstants
- ParserNumericSign
- ParserSelectedExponent
- ParserSelectedMagnitudeSign
- ParserSelectedMantissaBound
- ParserSlowExponentRange
- ParserSlowLoopInfinityResult
- ParserSlowLoopMinimumExponent
- ParserSlowLoopZeroResult
- ParserSlowMantissaBound
- ParserSpecialRejectionSafeLength
- Preamble
- ResultLoopPartial
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice offset from
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice read u64
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice write u64
- SourceValidByteSlice
- SpecialHelperRejection
- U64 Insts CoreOpsBitBitAndU64U64
- U64 Insts CoreOpsBitBitOrU64U64
- U64 Insts CoreOpsBitShlU32U64
- U64 Insts CoreOpsBitShrU32U64
- U64 Insts Dec2flt modelNumImpTraitsCastIntoI16
- U64 Insts Dec2flt modelNumImpTraitsCastIntoI16 cast
- U64 Insts Dec2flt modelNumImpTraitsInt
- U64 Insts Dec2flt modelNumImpTraitsInt ONE
- U64 Insts Dec2flt modelNumImpTraitsInt ZERO
- core num FpCategory
- core ops arith Div
- core ops arith Mul
- core ops arith Neg
- core ops bit BitOr
- core ops bit Shl
- core ops bit Shr
- num float parse FloatErrorKind
- num float parse ParseFloatError
- num imp dec2flt Dec2FltAssemblyTrace
- num imp dec2flt Dec2FltTrace
- num imp dec2flt Lemire
- num imp dec2flt Lemire MAX MANTISSA FAST PATH default
- num imp dec2flt biased fp to float
- num imp dec2flt common BiasedFp
- num imp dec2flt common BiasedFp Insts CoreCmpPartialEqBiasedFp eq
- num imp dec2flt common BiasedFp zero pow2
- num imp dec2flt common is 8digits
- num imp dec2flt dec2flt
- num imp dec2flt dec2flt with trace
- num imp dec2flt decimal Decimal
- num imp dec2flt decimal Decimal can use fast path
- num imp dec2flt decimal Decimal try fast path
- num imp dec2flt decimal INT POW10
- num imp dec2flt decimal seq DecimalSeq
- num imp dec2flt decimal seq DecimalSeq DECIMAL POINT RANGE
- num imp dec2flt decimal seq DecimalSeq Insts CoreDefaultDefault default
- num imp dec2flt decimal seq DecimalSeq MAX DIGITS
- num imp dec2flt decimal seq DecimalSeq MAX DIGITS WITHOUT OVERFLOW
- num imp dec2flt decimal seq DecimalSeq left shift
- num imp dec2flt decimal seq DecimalSeq right shift
- num imp dec2flt decimal seq DecimalSeq round
- num imp dec2flt decimal seq DecimalSeq trim
- num imp dec2flt decimal seq DecimalSeq try add digit
- num imp dec2flt decimal seq count trailing zeros
- num imp dec2flt decimal seq number of digits decimal left shift
- num imp dec2flt decimal seq number of digits decimal left shift TABLE
- num imp dec2flt decimal seq number of digits decimal left shift TABLE POW5
- num imp dec2flt decimal seq parse decimal exponent
- num imp dec2flt decimal seq parse decimal seq
- num imp dec2flt decimal seq parse digits into seq
- num imp dec2flt fpu fpu precision set precision
- num imp dec2flt lemire compute float
- num imp dec2flt lemire compute product approx
- num imp dec2flt lemire full multiplication
- num imp dec2flt lemire power
- num imp dec2flt parse MIN 19DIGIT INT
- num imp dec2flt parse adjust many digit count
- num imp dec2flt parse parse 8digits
- num imp dec2flt parse parse 8digits MASK
- num imp dec2flt parse parse 8digits MUL1
- num imp dec2flt parse parse 8digits MUL2
- num imp dec2flt parse parse inf nan
- num imp dec2flt parse parse many digits
- num imp dec2flt parse parse number
- num imp dec2flt parse parse partial number
- num imp dec2flt parse parse scientific
- num imp dec2flt parse try parse 19digits
- num imp dec2flt parse try parse digits
- num imp dec2flt pfe empty
- num imp dec2flt pfe invalid
- num imp dec2flt slow parse long mantissa
- num imp dec2flt slow parse long mantissa MAX SHIFT
- num imp dec2flt slow parse long mantissa NUM POWERS
- num imp dec2flt slow parse long mantissa POWERS
- num imp dec2flt slow parse long mantissa closure
- num imp dec2flt slow parse long mantissa closure Insts CoreOpsFunctionFnTupleUsizeUsize call
- num imp dec2flt table LARGEST POWER OF FIVE
- num imp dec2flt table POWER OF FIVE 128
- num imp dec2flt table SMALLEST POWER OF FIVE
- num imp traits CastInto
- num imp traits Float
- num imp traits FloatExt
- num imp traits Float EXP BIAS default
- num imp traits Float EXP BITS default
- num imp traits Float EXP MIN default
- num imp traits Float EXP SAT default
- num imp traits Float SIG BITS default
- num imp traits Int
Technical checking records
Local closure summary
{
"node": "ParserNumericSign",
"closure_version": "patch_c_v1",
"active_decl_hash": "233cb88e7aad81fc48a47f4bc97b679536a3fab781f2cdbc3605160043fa3394",
"active_statement_hash": "46f26e04cb84d054a6de5e92e87ec56e193ded13ba0c9d2932637ff683f0f382",
"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-135",
"boundary_theorems": {},
"strict_theorem_deps": {
"AssemblyCorrespondence": "87bf7c2abde897a2",
"DecimalGoalVocabularyDefault": "94cb4c406f8efb78",
"NativeCorrectOrDefer": "4eb7d1b8e4ed1a56",
"ParserSelectedMagnitudeSign": "70c47baac228615a",
"SpecialHelperRejection": "e1e229c5dd3ecf3c",
"num_imp_dec2flt_dec2flt_with_trace": "d2b4145772dccc04",
"num_imp_traits_Float_SIG_BITS_default": "9ab622d85ef04d94"
},
"strict_definition_deps": {
"DecimalGoalVocabulary": "c08dd4b4aea4abb4",
"DecimalGoalVocabularyDefault": "3016c00221d29252",
"DecimalLexeme": "303e59678842cea4",
"F64": "ec4e25fbaf4e11d4",
"F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
"F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
"F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
"F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64": "60afe26c6a80cf0f",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS": "887b52d84a3fc9c4",
"ModelF64Neg": "78a021de99eb373b",
"ModelSliceFirst": "a31394b3c1080f71",
"Preamble": "86dc391ab250c79b",
"SourceValidByteSlice": "3dc42716a6378d26",
"core_ops_arith_Neg": "0ff07135a60bcbf9",
"num_float_parse_ParseFloatError": "c43614ff2149ecf2",
"num_imp_dec2flt_Dec2FltAssemblyTrace": "7bda5de02611ad76",
"num_imp_dec2flt_Dec2FltTrace": "51a72ca46ca811cd",
"num_imp_dec2flt_Lemire": "1923f90c53d323e6",
"num_imp_dec2flt_biased_fp_to_float": "acdde060e8d35ca7",
"num_imp_dec2flt_common_BiasedFp": "5c88d5d7976c5e8f",
"num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq": "fbbf553e3c502a05",
"num_imp_dec2flt_dec2flt": "f9f7d93449a25efa",
"num_imp_dec2flt_dec2flt_with_trace": "5665189e0304a27e",
"num_imp_dec2flt_decimal_Decimal": "4c41a56bf44cb31e",
"num_imp_dec2flt_decimal_Decimal_try_fast_path": "2e4888f65a06b49f",
"num_imp_dec2flt_lemire_compute_float": "39d89e3f0a8a9d4c",
"num_imp_dec2flt_parse_parse_inf_nan": "85655c19a8791b54",
"num_imp_dec2flt_parse_parse_number": "f73f8bc11faa6db3",
"num_imp_dec2flt_pfe_empty": "89046d1da5ac1ce2",
"num_imp_dec2flt_pfe_invalid": "21db875427d92c6d",
"num_imp_dec2flt_slow_parse_long_mantissa": "cd8af64c3688b60f",
"num_imp_traits_Float": "02acccb9db3e30f2",
"num_imp_traits_FloatExt": "f996e5400649797d"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:0eb236e214e54bfd6769416c3cf596ed78f62d98ddb871afe06a7d9de5463e62",
"current_fingerprint": "sound-v2:0eb236e214e54bfd6769416c3cf596ed78f62d98ddb871afe06a7d9de5463e62",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}