Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Theorem
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.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
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ClassificationDeterminism]
theorem ClassificationDeterminism :
(∀ (bs : List Nat) c₁ c₂, (∀ b ∈ bs, b < 256) ->
DecimalGoalVocabularyDefault.classifies bs c₁ -> DecimalGoalVocabularyDefault.classifies bs c₂ -> c₁ = c₂) ∧
(∀ (bs : List Nat) x₁ x₂, (∀ b ∈ bs, b < 256) ->
DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x₁)) ->
DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x₂)) -> x₁ = x₂) := 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.
Earlier prose review
An earlier review questioned the prose argument. Lean subsequently checked the formal proof. Review of the statement’s intended meaning is a separate judgment.
Proof
nan, or of 105 for
inf and infinity. Such a first byte is respectively
110 or 78, or 105 or 73, and hence is neither 43 nor 45. Applying
the first cancellation fact recovers the optional special sign and leaves
equal bodies. The pointwise case relation also forces the body to have the
same length as its fixed lowercase word. Thus length 8 distinguishes
infinity from the two length-3 words. Between the length-3
words, the first letter after case-normalization is 110 for nan
and 105 for inf; their possible actual bytes
\{110,78\} and \{105,73\} are disjoint. Therefore an equal body has a
unique word, and in particular a unique Boolean kind (NaN versus infinity).
Together with the recovered sign, this proves uniqueness of the complete
special classification payload.none, its
definition asserts both that no numeric witness exists and that no special
witness exists; either possible some classification supplies exactly
the forbidden witness. Finally, two none values are definitionally
equal. This exhaustive case analysis proves the first conjunct.List Nat.Lean proof
let signBytes : Option Bool → List Nat := fun sign =>
match sign with | none => [] | some negative => [if negative then 45 else 43]
let digitBytes : List Nat → List Nat := fun ds => ds.map (fun d => 48 + d)
let AllDigits : List Nat → Prop := fun ds => ∀ d ∈ ds, d < 10
let SignFreeHead : List Nat → Prop := fun xs =>
∀ h t, xs = h :: t → h ≠ 43 ∧ h ≠ 45
let DigitFreeHead : List Nat → Prop := fun xs =>
∀ h t, xs = h :: t → h < 48 ∨ 58 ≤ h
let exponentBytes : Option (Bool × Option Bool × List Nat) → List Nat := fun e =>
match e with
| none => []
| some (upper, sign, ds) =>
(if upper then 69 else 101) :: signBytes sign ++ digitBytes ds
let fractionBytes : Option (List Nat) → List Nat := fun f =>
match f with | none => [] | some ds => 46 :: digitBytes ds
let ValidNumeric : DecimalLexeme → Prop := fun x =>
AllDigits x.integerDigits ∧
(match x.fractionDigits with | none => True | some ds => AllDigits ds) ∧
(x.integerDigits ≠ [] ∨
match x.fractionDigits with | none => False | some ds => ds ≠ []) ∧
(match x.exponent with
| none => True
| some (_, _, ds) => ds ≠ [] ∧ AllDigits ds)
let RenderNumeric : DecimalLexeme → List Nat := fun x =>
signBytes x.leadingSign ++ digitBytes x.integerDigits ++
fractionBytes x.fractionDigits ++ exponentBytes x.exponent
let CaseEq : List Nat → List Nat → Prop := fun xs ys =>
List.Forall₂ (fun actual lower => actual = lower ∨ actual + 32 = lower) xs ys
let SpecialBody : List Nat → Bool → Prop := fun body nan =>
if nan then CaseEq body [110, 97, 110]
else CaseEq body [105, 110, 102] ∨
CaseEq body [105, 110, 102, 105, 110, 105, 116, 121]
let SpecialLiteral : List Nat → Option Bool → Bool → Prop := fun bs sign nan =>
∃ body, bs = signBytes sign ++ body ∧ SpecialBody body nan
let NumericLiteral : List Nat → DecimalLexeme → Prop := fun bs x =>
ValidNumeric x ∧ RenderNumeric x = bs
let Classifies : List Nat → Option (Sum DecimalLexeme (Option Bool × Bool)) → Prop :=
fun bs c => match c with
| some (Sum.inl x) => NumericLiteral bs x
| some (Sum.inr (sign, nan)) => SpecialLiteral bs sign nan
| none => (¬ ∃ x, NumericLiteral bs x) ∧ (¬ ∃ sign nan, SpecialLiteral bs sign nan)
have sign_split : ∀ s₁ s₂ xs ys,
SignFreeHead xs → SignFreeHead ys →
signBytes s₁ ++ xs = signBytes s₂ ++ ys → s₁ = s₂ ∧ xs = ys := by
intro s₁ s₂ xs ys hxs hys heq
cases s₁ with
| none =>
cases s₂ with
| none => exact ⟨rfl, by simpa [signBytes] using heq⟩
| some b₂ =>
cases b₂ <;> simp only [signBytes, ↓reduceIte, List.nil_append,
List.cons_append, List.append_nil] at heq
· have := hxs 43 ys heq
exact False.elim (this.1 rfl)
· have := hxs 45 ys heq
exact False.elim (this.2 rfl)
| some b₁ =>
cases s₂ with
| none =>
cases b₁ <;> simp only [signBytes, ↓reduceIte, List.nil_append,
List.cons_append, List.append_nil] at heq
· have := hys 43 xs heq.symm
exact False.elim (this.1 rfl)
· have := hys 45 xs heq.symm
exact False.elim (this.2 rfl)
| some b₂ =>
cases b₁ <;> cases b₂
· simp only [signBytes, ↓reduceIte, List.cons_append, List.append_nil,
List.cons.injEq] at heq
exact ⟨rfl, heq.2⟩
· simp [signBytes] at heq
· simp [signBytes] at heq
· simp only [signBytes, ↓reduceIte, List.cons_append, List.append_nil,
List.cons.injEq] at heq
exact ⟨rfl, heq.2⟩
have digits_split : ∀ ds₁ ds₂ xs ys,
AllDigits ds₁ → AllDigits ds₂ →
DigitFreeHead xs → DigitFreeHead ys →
digitBytes ds₁ ++ xs = digitBytes ds₂ ++ ys → ds₁ = ds₂ ∧ xs = ys := by
intro ds₁
induction ds₁ with
| nil =>
intro bs xs ys has hbs hxs hys heq
cases bs with
| nil => exact ⟨rfl, by simpa [digitBytes] using heq⟩
| cons b bs =>
simp only [digitBytes, List.map_cons, List.nil_append, List.cons_append,
List.cons.injEq] at heq
have hb : b < 10 := hbs b (by simp)
have hx := hxs (48 + b) (digitBytes bs ++ ys) heq
omega
| cons a ds₁ ih =>
intro bs xs ys has hbs hxs hys heq
cases bs with
| nil =>
simp only [digitBytes, List.map_cons, List.nil_append, List.cons_append,
List.cons.injEq] at heq
have ha : a < 10 := has a (by simp)
have hy := hys (48 + a) (digitBytes ds₁ ++ xs) heq.symm
omega
| cons b bs =>
simp only [digitBytes, List.map_cons, List.cons_append, List.cons.injEq] at heq
have hab : a = b := by omega
subst b
have has' : AllDigits ds₁ := by
intro d hd
exact has d (by simp [hd])
have hbs' : AllDigits bs := by
intro d hd
exact hbs d (by simp [hd])
have hr := ih bs xs ys has' hbs' hxs hys heq.2
exact ⟨by simp [hr.1], hr.2⟩
have digitBytes_signfree : ∀ ds,
AllDigits ds → SignFreeHead (digitBytes ds) := by
intro ds hds h t heq
cases ds with
| nil => simp [digitBytes] at heq
| cons d ds =>
simp only [digitBytes, List.map_cons, List.cons.injEq] at heq
have hd : d < 10 := hds d (by simp)
omega
have exponentBytes_digitfree : ∀ e, DigitFreeHead (exponentBytes e) := by
intro e h t heq
cases e with
| none => simp [exponentBytes] at heq
| some value =>
rcases value with ⟨upper, sign, ds⟩
cases upper <;> simp [exponentBytes] at heq <;> omega
have fracExp_digitfree : ∀ f e,
DigitFreeHead (fractionBytes f ++ exponentBytes e) := by
intro f e h t heq
cases f with
| none =>
simpa [fractionBytes] using exponentBytes_digitfree e h t heq
| some ds =>
simp [fractionBytes] at heq
omega
have numericBody_signfree : ∀ i f e,
AllDigits i →
(i ≠ [] ∨ match f with | none => False | some ds => ds ≠ []) →
SignFreeHead (digitBytes i ++ fractionBytes f ++ exponentBytes e) := by
intro i f e hi hnonempty h t heq
cases i with
| nil =>
simp only [List.nil_eq, ne_eq, not_true_eq_false, false_or] at hnonempty
cases f with
| none => simp at hnonempty
| some ds =>
cases ds with
| nil => simp at hnonempty
| cons d ds =>
simp [digitBytes, fractionBytes] at heq
omega
| cons d ds =>
simp only [digitBytes, List.map_cons, List.cons_append, List.cons.injEq] at heq
have hd : d < 10 := hi d (by simp)
omega
have exponent_inj : ∀ e₁ e₂,
(match e₁ with | none => True | some (_, _, ds) => AllDigits ds) →
(match e₂ with | none => True | some (_, _, ds) => AllDigits ds) →
exponentBytes e₁ = exponentBytes e₂ → e₁ = e₂ := by
intro e₁ e₂ hv₁ hv₂ heq
cases e₁ with
| none =>
cases e₂ with
| none => rfl
| some value₂ =>
rcases value₂ with ⟨upper₂, sign₂, ds₂⟩
cases upper₂ <;> simp [exponentBytes] at heq
| some value₁ =>
rcases value₁ with ⟨upper₁, sign₁, ds₁⟩
cases e₂ with
| none => cases upper₁ <;> simp [exponentBytes] at heq
| some value₂ =>
rcases value₂ with ⟨upper₂, sign₂, ds₂⟩
cases upper₁ <;> cases upper₂
· have htail : signBytes sign₁ ++ digitBytes ds₁ =
signBytes sign₂ ++ digitBytes ds₂ := by
simpa [exponentBytes] using heq
have hs := sign_split sign₁ sign₂ (digitBytes ds₁) (digitBytes ds₂)
(digitBytes_signfree ds₁ hv₁) (digitBytes_signfree ds₂ hv₂) htail
have hd := digits_split ds₁ ds₂ [] [] hv₁ hv₂
(by simp [DigitFreeHead]) (by simp [DigitFreeHead]) (by simpa using hs.2)
simp [hs.1, hd.1]
· simp [exponentBytes] at heq
· simp [exponentBytes] at heq
· have htail : signBytes sign₁ ++ digitBytes ds₁ =
signBytes sign₂ ++ digitBytes ds₂ := by
simpa [exponentBytes] using heq
have hs := sign_split sign₁ sign₂ (digitBytes ds₁) (digitBytes ds₂)
(digitBytes_signfree ds₁ hv₁) (digitBytes_signfree ds₂ hv₂) htail
have hd := digits_split ds₁ ds₂ [] [] hv₁ hv₂
(by simp [DigitFreeHead]) (by simp [DigitFreeHead]) (by simpa using hs.2)
simp [hs.1, hd.1]
have exponentValidity_digits : ∀ (e : Option (Bool × Option Bool × List Nat)),
(match e with | none => True | some (_, _, ds) => ds ≠ [] ∧ AllDigits ds) →
(match e with | none => True | some (_, _, ds) => AllDigits ds) := by
intro e h
cases e with
| none => trivial
| some value =>
rcases value with ⟨upper, sign, ds⟩
exact h.2
have fracExp_inj : ∀ f₁ f₂ e₁ e₂,
(match f₁ with | none => True | some ds => AllDigits ds) →
(match f₂ with | none => True | some ds => AllDigits ds) →
(match e₁ with | none => True | some (_, _, ds) => AllDigits ds) →
(match e₂ with | none => True | some (_, _, ds) => AllDigits ds) →
fractionBytes f₁ ++ exponentBytes e₁ =
fractionBytes f₂ ++ exponentBytes e₂ →
f₁ = f₂ ∧ e₁ = e₂ := by
intro f₁ f₂ e₁ e₂ hf₁ hf₂ he₁ he₂ heq
cases f₁ with
| none =>
cases f₂ with
| none =>
have he : e₁ = e₂ := exponent_inj e₁ e₂ he₁ he₂ (by simpa [fractionBytes] using heq)
exact ⟨rfl, he⟩
| some ds₂ =>
cases e₁ with
| none => simp [fractionBytes, exponentBytes] at heq
| some value₁ =>
rcases value₁ with ⟨upper₁, sign₁, es₁⟩
cases upper₁ <;> simp [fractionBytes, exponentBytes] at heq
| some ds₁ =>
cases f₂ with
| none =>
cases e₂ with
| none => simp [fractionBytes, exponentBytes] at heq
| some value₂ =>
rcases value₂ with ⟨upper₂, sign₂, es₂⟩
cases upper₂ <;> simp [fractionBytes, exponentBytes] at heq
| some ds₂ =>
simp only [fractionBytes, List.cons_append, List.cons.injEq] at heq
have hd := digits_split ds₁ ds₂ (exponentBytes e₁) (exponentBytes e₂)
hf₁ hf₂ (exponentBytes_digitfree e₁) (exponentBytes_digitfree e₂) heq.2
have he := exponent_inj e₁ e₂ he₁ he₂ hd.2
exact ⟨by simp [hd.1], he⟩
have numeric_inj : ∀ x₁ x₂,
ValidNumeric x₁ → ValidNumeric x₂ →
RenderNumeric x₁ = RenderNumeric x₂ → x₁ = x₂ := by
rintro ⟨s₁, i₁, f₁, e₁⟩ ⟨s₂, i₂, f₂, e₂⟩ hv₁ hv₂ heq
simp only [ValidNumeric] at hv₁ hv₂
simp only [RenderNumeric] at heq
have hs := sign_split s₁ s₂
(digitBytes i₁ ++ fractionBytes f₁ ++ exponentBytes e₁)
(digitBytes i₂ ++ fractionBytes f₂ ++ exponentBytes e₂)
(numericBody_signfree i₁ f₁ e₁ hv₁.1 hv₁.2.2.1)
(numericBody_signfree i₂ f₂ e₂ hv₂.1 hv₂.2.2.1)
(by simpa [List.append_assoc] using heq)
have hi := digits_split i₁ i₂
(fractionBytes f₁ ++ exponentBytes e₁)
(fractionBytes f₂ ++ exponentBytes e₂)
hv₁.1 hv₂.1 (fracExp_digitfree f₁ e₁) (fracExp_digitfree f₂ e₂)
(by simpa [List.append_assoc] using hs.2)
have he₁ := exponentValidity_digits e₁ hv₁.2.2.2
have he₂ := exponentValidity_digits e₂ hv₂.2.2.2
have hf := fracExp_inj f₁ f₂ e₁ e₂ hv₁.2.1 hv₂.2.1 he₁ he₂ hi.2
cases hs.1
cases hi.1
cases hf.1
cases hf.2
rfl
have caseEq_largeHead : ∀ body lower lowers,
90 ≤ lower → CaseEq body (lower :: lowers) →
∃ actual rest, body = actual :: rest ∧ 58 ≤ actual := by
intro body lower lowers hlower hcase
cases hcase with
| cons hhead htail =>
refine ⟨_, _, rfl, ?_⟩
rcases hhead with hhead | hhead <;> omega
have specialBody_largeHead : ∀ body nan,
SpecialBody body nan → ∃ actual rest, body = actual :: rest ∧ 58 ≤ actual := by
intro body nan hbody
cases nan
· simp only [SpecialBody, Bool.false_eq_true, if_false] at hbody
rcases hbody with hshort | hlong
· exact caseEq_largeHead body 105 [110, 102] (by omega) hshort
· exact caseEq_largeHead body 105 [110, 102, 105, 110, 105, 116, 121] (by omega) hlong
· simp only [SpecialBody, if_true] at hbody
exact caseEq_largeHead body 110 [97, 110] (by omega) hbody
have specialBody_signfree : ∀ body nan,
SpecialBody body nan → SignFreeHead body := by
intro body nan hbody h t heq
rcases specialBody_largeHead body nan hbody with ⟨actual, rest, hshape, hlarge⟩
rw [hshape] at heq
simp only [List.cons.injEq] at heq
omega
have nan_inf_disjoint : ∀ body infTail,
CaseEq body [110, 97, 110] → CaseEq body (105 :: infTail) → False := by
intro body infTail hnan hinf
cases hnan with
| cons hnanHead hnanTail =>
cases hinf with
| cons hinfHead hinfTailProof =>
rcases hnanHead with hnanHead | hnanHead <;>
rcases hinfHead with hinfHead | hinfHead <;> omega
have special_inj : ∀ bs s₁ nan₁ s₂ nan₂,
SpecialLiteral bs s₁ nan₁ → SpecialLiteral bs s₂ nan₂ →
(s₁, nan₁) = (s₂, nan₂) := by
intro bs s₁ nan₁ s₂ nan₂ h₁ h₂
rcases h₁ with ⟨body₁, hbs₁, hbody₁⟩
rcases h₂ with ⟨body₂, hbs₂, hbody₂⟩
have heq : signBytes s₁ ++ body₁ = signBytes s₂ ++ body₂ := hbs₁.symm.trans hbs₂
have hs := sign_split s₁ s₂ body₁ body₂
(specialBody_signfree body₁ nan₁ hbody₁)
(specialBody_signfree body₂ nan₂ hbody₂) heq
cases hs.1
cases hs.2
cases nan₁ <;> cases nan₂
· rfl
· simp only [SpecialBody, Bool.false_eq_true, if_false] at hbody₁
simp only [SpecialBody, if_true] at hbody₂
rcases hbody₁ with hshort | hlong
· exact False.elim (nan_inf_disjoint body₁ [110, 102] hbody₂ hshort)
· exact False.elim
(nan_inf_disjoint body₁ [110, 102, 105, 110, 105, 116, 121] hbody₂ hlong)
· simp only [SpecialBody, if_true] at hbody₁
simp only [SpecialBody, Bool.false_eq_true, if_false] at hbody₂
rcases hbody₂ with hshort | hlong
· exact False.elim (nan_inf_disjoint body₁ [110, 102] hbody₁ hshort)
· exact False.elim
(nan_inf_disjoint body₁ [110, 102, 105, 110, 105, 116, 121] hbody₁ hlong)
· rfl
have numericBody_smallHead : ∀ i f e,
AllDigits i →
(i ≠ [] ∨ match f with | none => False | some ds => ds ≠ []) →
∃ actual rest,
digitBytes i ++ fractionBytes f ++ exponentBytes e = actual :: rest ∧ actual < 58 := by
intro i f e hi hnonempty
cases i with
| nil =>
simp only [ne_eq, not_true_eq_false, false_or] at hnonempty
cases f with
| none => simp at hnonempty
| some ds =>
refine ⟨46, digitBytes ds ++ exponentBytes e, ?_, by omega⟩
simp [digitBytes, fractionBytes]
| cons d ds =>
have hd : d < 10 := hi d (by simp)
refine ⟨48 + d, digitBytes ds ++ fractionBytes f ++ exponentBytes e, ?_, by omega⟩
simp [digitBytes]
have numeric_special_disjoint : ∀ x bs sign nan,
ValidNumeric x → RenderNumeric x = bs → SpecialLiteral bs sign nan → False := by
rintro ⟨lead, i, f, e⟩ bs sign nan hv hrender hspecial
simp only [ValidNumeric] at hv
simp only [RenderNumeric] at hrender
rcases hspecial with ⟨body, hbs, hbody⟩
have heq : signBytes lead ++ (digitBytes i ++ fractionBytes f ++ exponentBytes e) =
signBytes sign ++ body := by
rw [← hbs, ← hrender]
simp [List.append_assoc]
have hs := sign_split lead sign (digitBytes i ++ fractionBytes f ++ exponentBytes e) body
(numericBody_signfree i f e hv.1 hv.2.2.1) (specialBody_signfree body nan hbody) heq
rcases numericBody_smallHead i f e hv.1 hv.2.2.1 with ⟨nhead, ntail, hnshape, hnsmall⟩
rcases specialBody_largeHead body nan hbody with ⟨shead, stail, hsshape, hslarge⟩
rw [hnshape, hsshape] at hs
simp only [List.cons.injEq] at hs
omega
have classification_unique : ∀ bs c₁ c₂,
Classifies bs c₁ → Classifies bs c₂ → c₁ = c₂ := by
intro bs c₁ c₂ h₁ h₂
cases c₁ with
| none =>
cases c₂ with
| none => rfl
| some value₂ =>
cases value₂ with
| inl x₂ =>
exact False.elim (h₁.1 ⟨x₂, h₂⟩)
| inr special₂ =>
rcases special₂ with ⟨sign₂, nan₂⟩
exact False.elim (h₁.2 ⟨sign₂, nan₂, h₂⟩)
| some value₁ =>
cases c₂ with
| none =>
cases value₁ with
| inl x₁ =>
exact False.elim (h₂.1 ⟨x₁, h₁⟩)
| inr special₁ =>
rcases special₁ with ⟨sign₁, nan₁⟩
exact False.elim (h₂.2 ⟨sign₁, nan₁, h₁⟩)
| some value₂ =>
cases value₁ with
| inl x₁ =>
cases value₂ with
| inl x₂ =>
have hx := numeric_inj x₁ x₂ h₁.1 h₂.1 (h₁.2.trans h₂.2.symm)
cases hx
rfl
| inr special₂ =>
rcases special₂ with ⟨sign₂, nan₂⟩
exact False.elim (numeric_special_disjoint x₁ bs sign₂ nan₂ h₁.1 h₁.2 h₂)
| inr special₁ =>
rcases special₁ with ⟨sign₁, nan₁⟩
cases value₂ with
| inl x₂ =>
exact False.elim (numeric_special_disjoint x₂ bs sign₁ nan₁ h₂.1 h₂.2 h₁)
| inr special₂ =>
rcases special₂ with ⟨sign₂, nan₂⟩
have hs := special_inj bs sign₁ nan₁ sign₂ nan₂ h₁ h₂
cases hs
rfl
constructor
· intro bs c₁ c₂ _ h₁ h₂
change Classifies bs c₁ at h₁
change Classifies bs c₂ at h₂
exact classification_unique bs c₁ c₂ h₁ h₂
· intro bs x₁ x₂ _ h₁ h₂
change NumericLiteral bs x₁ at h₁
change NumericLiteral bs x₂ at h₂
exact numeric_inj x₁ x₂ h₁.1 h₂.1 (h₁.2.trans h₂.2.symm)
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
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
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ClassificationDeterminism]
theorem ClassificationDeterminism :
(∀ (bs : List Nat) c₁ c₂, (∀ b ∈ bs, b < 256) ->
DecimalGoalVocabularyDefault.classifies bs c₁ -> DecimalGoalVocabularyDefault.classifies bs c₂ -> c₁ = c₂) ∧
(∀ (bs : List Nat) x₁ x₂, (∀ b ∈ bs, b < 256) ->
DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x₁)) ->
DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x₂)) -> x₁ = x₂) := by
-- BODY
let signBytes : Option Bool → List Nat := fun sign =>
match sign with | none => [] | some negative => [if negative then 45 else 43]
let digitBytes : List Nat → List Nat := fun ds => ds.map (fun d => 48 + d)
let AllDigits : List Nat → Prop := fun ds => ∀ d ∈ ds, d < 10
let SignFreeHead : List Nat → Prop := fun xs =>
∀ h t, xs = h :: t → h ≠ 43 ∧ h ≠ 45
let DigitFreeHead : List Nat → Prop := fun xs =>
∀ h t, xs = h :: t → h < 48 ∨ 58 ≤ h
let exponentBytes : Option (Bool × Option Bool × List Nat) → List Nat := fun e =>
match e with
| none => []
| some (upper, sign, ds) =>
(if upper then 69 else 101) :: signBytes sign ++ digitBytes ds
let fractionBytes : Option (List Nat) → List Nat := fun f =>
match f with | none => [] | some ds => 46 :: digitBytes ds
let ValidNumeric : DecimalLexeme → Prop := fun x =>
AllDigits x.integerDigits ∧
(match x.fractionDigits with | none => True | some ds => AllDigits ds) ∧
(x.integerDigits ≠ [] ∨
match x.fractionDigits with | none => False | some ds => ds ≠ []) ∧
(match x.exponent with
| none => True
| some (_, _, ds) => ds ≠ [] ∧ AllDigits ds)
let RenderNumeric : DecimalLexeme → List Nat := fun x =>
signBytes x.leadingSign ++ digitBytes x.integerDigits ++
fractionBytes x.fractionDigits ++ exponentBytes x.exponent
let CaseEq : List Nat → List Nat → Prop := fun xs ys =>
List.Forall₂ (fun actual lower => actual = lower ∨ actual + 32 = lower) xs ys
let SpecialBody : List Nat → Bool → Prop := fun body nan =>
if nan then CaseEq body [110, 97, 110]
else CaseEq body [105, 110, 102] ∨
CaseEq body [105, 110, 102, 105, 110, 105, 116, 121]
let SpecialLiteral : List Nat → Option Bool → Bool → Prop := fun bs sign nan =>
∃ body, bs = signBytes sign ++ body ∧ SpecialBody body nan
let NumericLiteral : List Nat → DecimalLexeme → Prop := fun bs x =>
ValidNumeric x ∧ RenderNumeric x = bs
let Classifies : List Nat → Option (Sum DecimalLexeme (Option Bool × Bool)) → Prop :=
fun bs c => match c with
| some (Sum.inl x) => NumericLiteral bs x
| some (Sum.inr (sign, nan)) => SpecialLiteral bs sign nan
| none => (¬ ∃ x, NumericLiteral bs x) ∧ (¬ ∃ sign nan, SpecialLiteral bs sign nan)
have sign_split : ∀ s₁ s₂ xs ys,
SignFreeHead xs → SignFreeHead ys →
signBytes s₁ ++ xs = signBytes s₂ ++ ys → s₁ = s₂ ∧ xs = ys := by
intro s₁ s₂ xs ys hxs hys heq
cases s₁ with
| none =>
cases s₂ with
| none => exact ⟨rfl, by simpa [signBytes] using heq⟩
| some b₂ =>
cases b₂ <;> simp only [signBytes, ↓reduceIte, List.nil_append,
List.cons_append, List.append_nil] at heq
· have := hxs 43 ys heq
exact False.elim (this.1 rfl)
· have := hxs 45 ys heq
exact False.elim (this.2 rfl)
| some b₁ =>
cases s₂ with
| none =>
cases b₁ <;> simp only [signBytes, ↓reduceIte, List.nil_append,
List.cons_append, List.append_nil] at heq
· have := hys 43 xs heq.symm
exact False.elim (this.1 rfl)
· have := hys 45 xs heq.symm
exact False.elim (this.2 rfl)
| some b₂ =>
cases b₁ <;> cases b₂
· simp only [signBytes, ↓reduceIte, List.cons_append, List.append_nil,
List.cons.injEq] at heq
exact ⟨rfl, heq.2⟩
· simp [signBytes] at heq
· simp [signBytes] at heq
· simp only [signBytes, ↓reduceIte, List.cons_append, List.append_nil,
List.cons.injEq] at heq
exact ⟨rfl, heq.2⟩
have digits_split : ∀ ds₁ ds₂ xs ys,
AllDigits ds₁ → AllDigits ds₂ →
DigitFreeHead xs → DigitFreeHead ys →
digitBytes ds₁ ++ xs = digitBytes ds₂ ++ ys → ds₁ = ds₂ ∧ xs = ys := by
intro ds₁
induction ds₁ with
| nil =>
intro bs xs ys has hbs hxs hys heq
cases bs with
| nil => exact ⟨rfl, by simpa [digitBytes] using heq⟩
| cons b bs =>
simp only [digitBytes, List.map_cons, List.nil_append, List.cons_append,
List.cons.injEq] at heq
have hb : b < 10 := hbs b (by simp)
have hx := hxs (48 + b) (digitBytes bs ++ ys) heq
omega
| cons a ds₁ ih =>
intro bs xs ys has hbs hxs hys heq
cases bs with
| nil =>
simp only [digitBytes, List.map_cons, List.nil_append, List.cons_append,
List.cons.injEq] at heq
have ha : a < 10 := has a (by simp)
have hy := hys (48 + a) (digitBytes ds₁ ++ xs) heq.symm
omega
| cons b bs =>
simp only [digitBytes, List.map_cons, List.cons_append, List.cons.injEq] at heq
have hab : a = b := by omega
subst b
have has' : AllDigits ds₁ := by
intro d hd
exact has d (by simp [hd])
have hbs' : AllDigits bs := by
intro d hd
exact hbs d (by simp [hd])
have hr := ih bs xs ys has' hbs' hxs hys heq.2
exact ⟨by simp [hr.1], hr.2⟩
have digitBytes_signfree : ∀ ds,
AllDigits ds → SignFreeHead (digitBytes ds) := by
intro ds hds h t heq
cases ds with
| nil => simp [digitBytes] at heq
| cons d ds =>
simp only [digitBytes, List.map_cons, List.cons.injEq] at heq
have hd : d < 10 := hds d (by simp)
omega
have exponentBytes_digitfree : ∀ e, DigitFreeHead (exponentBytes e) := by
intro e h t heq
cases e with
| none => simp [exponentBytes] at heq
| some value =>
rcases value with ⟨upper, sign, ds⟩
cases upper <;> simp [exponentBytes] at heq <;> omega
have fracExp_digitfree : ∀ f e,
DigitFreeHead (fractionBytes f ++ exponentBytes e) := by
intro f e h t heq
cases f with
| none =>
simpa [fractionBytes] using exponentBytes_digitfree e h t heq
| some ds =>
simp [fractionBytes] at heq
omega
have numericBody_signfree : ∀ i f e,
AllDigits i →
(i ≠ [] ∨ match f with | none => False | some ds => ds ≠ []) →
SignFreeHead (digitBytes i ++ fractionBytes f ++ exponentBytes e) := by
intro i f e hi hnonempty h t heq
cases i with
| nil =>
simp only [List.nil_eq, ne_eq, not_true_eq_false, false_or] at hnonempty
cases f with
| none => simp at hnonempty
| some ds =>
cases ds with
| nil => simp at hnonempty
| cons d ds =>
simp [digitBytes, fractionBytes] at heq
omega
| cons d ds =>
simp only [digitBytes, List.map_cons, List.cons_append, List.cons.injEq] at heq
have hd : d < 10 := hi d (by simp)
omega
have exponent_inj : ∀ e₁ e₂,
(match e₁ with | none => True | some (_, _, ds) => AllDigits ds) →
(match e₂ with | none => True | some (_, _, ds) => AllDigits ds) →
exponentBytes e₁ = exponentBytes e₂ → e₁ = e₂ := by
intro e₁ e₂ hv₁ hv₂ heq
cases e₁ with
| none =>
cases e₂ with
| none => rfl
| some value₂ =>
rcases value₂ with ⟨upper₂, sign₂, ds₂⟩
cases upper₂ <;> simp [exponentBytes] at heq
| some value₁ =>
rcases value₁ with ⟨upper₁, sign₁, ds₁⟩
cases e₂ with
| none => cases upper₁ <;> simp [exponentBytes] at heq
| some value₂ =>
rcases value₂ with ⟨upper₂, sign₂, ds₂⟩
cases upper₁ <;> cases upper₂
· have htail : signBytes sign₁ ++ digitBytes ds₁ =
signBytes sign₂ ++ digitBytes ds₂ := by
simpa [exponentBytes] using heq
have hs := sign_split sign₁ sign₂ (digitBytes ds₁) (digitBytes ds₂)
(digitBytes_signfree ds₁ hv₁) (digitBytes_signfree ds₂ hv₂) htail
have hd := digits_split ds₁ ds₂ [] [] hv₁ hv₂
(by simp [DigitFreeHead]) (by simp [DigitFreeHead]) (by simpa using hs.2)
simp [hs.1, hd.1]
· simp [exponentBytes] at heq
· simp [exponentBytes] at heq
· have htail : signBytes sign₁ ++ digitBytes ds₁ =
signBytes sign₂ ++ digitBytes ds₂ := by
simpa [exponentBytes] using heq
have hs := sign_split sign₁ sign₂ (digitBytes ds₁) (digitBytes ds₂)
(digitBytes_signfree ds₁ hv₁) (digitBytes_signfree ds₂ hv₂) htail
have hd := digits_split ds₁ ds₂ [] [] hv₁ hv₂
(by simp [DigitFreeHead]) (by simp [DigitFreeHead]) (by simpa using hs.2)
simp [hs.1, hd.1]
have exponentValidity_digits : ∀ (e : Option (Bool × Option Bool × List Nat)),
(match e with | none => True | some (_, _, ds) => ds ≠ [] ∧ AllDigits ds) →
(match e with | none => True | some (_, _, ds) => AllDigits ds) := by
intro e h
cases e with
| none => trivial
| some value =>
rcases value with ⟨upper, sign, ds⟩
exact h.2
have fracExp_inj : ∀ f₁ f₂ e₁ e₂,
(match f₁ with | none => True | some ds => AllDigits ds) →
(match f₂ with | none => True | some ds => AllDigits ds) →
(match e₁ with | none => True | some (_, _, ds) => AllDigits ds) →
(match e₂ with | none => True | some (_, _, ds) => AllDigits ds) →
fractionBytes f₁ ++ exponentBytes e₁ =
fractionBytes f₂ ++ exponentBytes e₂ →
f₁ = f₂ ∧ e₁ = e₂ := by
intro f₁ f₂ e₁ e₂ hf₁ hf₂ he₁ he₂ heq
cases f₁ with
| none =>
cases f₂ with
| none =>
have he : e₁ = e₂ := exponent_inj e₁ e₂ he₁ he₂ (by simpa [fractionBytes] using heq)
exact ⟨rfl, he⟩
| some ds₂ =>
cases e₁ with
| none => simp [fractionBytes, exponentBytes] at heq
| some value₁ =>
rcases value₁ with ⟨upper₁, sign₁, es₁⟩
cases upper₁ <;> simp [fractionBytes, exponentBytes] at heq
| some ds₁ =>
cases f₂ with
| none =>
cases e₂ with
| none => simp [fractionBytes, exponentBytes] at heq
| some value₂ =>
rcases value₂ with ⟨upper₂, sign₂, es₂⟩
cases upper₂ <;> simp [fractionBytes, exponentBytes] at heq
| some ds₂ =>
simp only [fractionBytes, List.cons_append, List.cons.injEq] at heq
have hd := digits_split ds₁ ds₂ (exponentBytes e₁) (exponentBytes e₂)
hf₁ hf₂ (exponentBytes_digitfree e₁) (exponentBytes_digitfree e₂) heq.2
have he := exponent_inj e₁ e₂ he₁ he₂ hd.2
exact ⟨by simp [hd.1], he⟩
have numeric_inj : ∀ x₁ x₂,
ValidNumeric x₁ → ValidNumeric x₂ →
RenderNumeric x₁ = RenderNumeric x₂ → x₁ = x₂ := by
rintro ⟨s₁, i₁, f₁, e₁⟩ ⟨s₂, i₂, f₂, e₂⟩ hv₁ hv₂ heq
simp only [ValidNumeric] at hv₁ hv₂
simp only [RenderNumeric] at heq
have hs := sign_split s₁ s₂
(digitBytes i₁ ++ fractionBytes f₁ ++ exponentBytes e₁)
(digitBytes i₂ ++ fractionBytes f₂ ++ exponentBytes e₂)
(numericBody_signfree i₁ f₁ e₁ hv₁.1 hv₁.2.2.1)
(numericBody_signfree i₂ f₂ e₂ hv₂.1 hv₂.2.2.1)
(by simpa [List.append_assoc] using heq)
have hi := digits_split i₁ i₂
(fractionBytes f₁ ++ exponentBytes e₁)
(fractionBytes f₂ ++ exponentBytes e₂)
hv₁.1 hv₂.1 (fracExp_digitfree f₁ e₁) (fracExp_digitfree f₂ e₂)
(by simpa [List.append_assoc] using hs.2)
have he₁ := exponentValidity_digits e₁ hv₁.2.2.2
have he₂ := exponentValidity_digits e₂ hv₂.2.2.2
have hf := fracExp_inj f₁ f₂ e₁ e₂ hv₁.2.1 hv₂.2.1 he₁ he₂ hi.2
cases hs.1
cases hi.1
cases hf.1
cases hf.2
rfl
have caseEq_largeHead : ∀ body lower lowers,
90 ≤ lower → CaseEq body (lower :: lowers) →
∃ actual rest, body = actual :: rest ∧ 58 ≤ actual := by
intro body lower lowers hlower hcase
cases hcase with
| cons hhead htail =>
refine ⟨_, _, rfl, ?_⟩
rcases hhead with hhead | hhead <;> omega
have specialBody_largeHead : ∀ body nan,
SpecialBody body nan → ∃ actual rest, body = actual :: rest ∧ 58 ≤ actual := by
intro body nan hbody
cases nan
· simp only [SpecialBody, Bool.false_eq_true, if_false] at hbody
rcases hbody with hshort | hlong
· exact caseEq_largeHead body 105 [110, 102] (by omega) hshort
· exact caseEq_largeHead body 105 [110, 102, 105, 110, 105, 116, 121] (by omega) hlong
· simp only [SpecialBody, if_true] at hbody
exact caseEq_largeHead body 110 [97, 110] (by omega) hbody
have specialBody_signfree : ∀ body nan,
SpecialBody body nan → SignFreeHead body := by
intro body nan hbody h t heq
rcases specialBody_largeHead body nan hbody with ⟨actual, rest, hshape, hlarge⟩
rw [hshape] at heq
simp only [List.cons.injEq] at heq
omega
have nan_inf_disjoint : ∀ body infTail,
CaseEq body [110, 97, 110] → CaseEq body (105 :: infTail) → False := by
intro body infTail hnan hinf
cases hnan with
| cons hnanHead hnanTail =>
cases hinf with
| cons hinfHead hinfTailProof =>
rcases hnanHead with hnanHead | hnanHead <;>
rcases hinfHead with hinfHead | hinfHead <;> omega
have special_inj : ∀ bs s₁ nan₁ s₂ nan₂,
SpecialLiteral bs s₁ nan₁ → SpecialLiteral bs s₂ nan₂ →
(s₁, nan₁) = (s₂, nan₂) := by
intro bs s₁ nan₁ s₂ nan₂ h₁ h₂
rcases h₁ with ⟨body₁, hbs₁, hbody₁⟩
rcases h₂ with ⟨body₂, hbs₂, hbody₂⟩
have heq : signBytes s₁ ++ body₁ = signBytes s₂ ++ body₂ := hbs₁.symm.trans hbs₂
have hs := sign_split s₁ s₂ body₁ body₂
(specialBody_signfree body₁ nan₁ hbody₁)
(specialBody_signfree body₂ nan₂ hbody₂) heq
cases hs.1
cases hs.2
cases nan₁ <;> cases nan₂
· rfl
· simp only [SpecialBody, Bool.false_eq_true, if_false] at hbody₁
simp only [SpecialBody, if_true] at hbody₂
rcases hbody₁ with hshort | hlong
· exact False.elim (nan_inf_disjoint body₁ [110, 102] hbody₂ hshort)
· exact False.elim
(nan_inf_disjoint body₁ [110, 102, 105, 110, 105, 116, 121] hbody₂ hlong)
· simp only [SpecialBody, if_true] at hbody₁
simp only [SpecialBody, Bool.false_eq_true, if_false] at hbody₂
rcases hbody₂ with hshort | hlong
· exact False.elim (nan_inf_disjoint body₁ [110, 102] hbody₁ hshort)
· exact False.elim
(nan_inf_disjoint body₁ [110, 102, 105, 110, 105, 116, 121] hbody₁ hlong)
· rfl
have numericBody_smallHead : ∀ i f e,
AllDigits i →
(i ≠ [] ∨ match f with | none => False | some ds => ds ≠ []) →
∃ actual rest,
digitBytes i ++ fractionBytes f ++ exponentBytes e = actual :: rest ∧ actual < 58 := by
intro i f e hi hnonempty
cases i with
| nil =>
simp only [ne_eq, not_true_eq_false, false_or] at hnonempty
cases f with
| none => simp at hnonempty
| some ds =>
refine ⟨46, digitBytes ds ++ exponentBytes e, ?_, by omega⟩
simp [digitBytes, fractionBytes]
| cons d ds =>
have hd : d < 10 := hi d (by simp)
refine ⟨48 + d, digitBytes ds ++ fractionBytes f ++ exponentBytes e, ?_, by omega⟩
simp [digitBytes]
have numeric_special_disjoint : ∀ x bs sign nan,
ValidNumeric x → RenderNumeric x = bs → SpecialLiteral bs sign nan → False := by
rintro ⟨lead, i, f, e⟩ bs sign nan hv hrender hspecial
simp only [ValidNumeric] at hv
simp only [RenderNumeric] at hrender
rcases hspecial with ⟨body, hbs, hbody⟩
have heq : signBytes lead ++ (digitBytes i ++ fractionBytes f ++ exponentBytes e) =
signBytes sign ++ body := by
rw [← hbs, ← hrender]
simp [List.append_assoc]
have hs := sign_split lead sign (digitBytes i ++ fractionBytes f ++ exponentBytes e) body
(numericBody_signfree i f e hv.1 hv.2.2.1) (specialBody_signfree body nan hbody) heq
rcases numericBody_smallHead i f e hv.1 hv.2.2.1 with ⟨nhead, ntail, hnshape, hnsmall⟩
rcases specialBody_largeHead body nan hbody with ⟨shead, stail, hsshape, hslarge⟩
rw [hnshape, hsshape] at hs
simp only [List.cons.injEq] at hs
omega
have classification_unique : ∀ bs c₁ c₂,
Classifies bs c₁ → Classifies bs c₂ → c₁ = c₂ := by
intro bs c₁ c₂ h₁ h₂
cases c₁ with
| none =>
cases c₂ with
| none => rfl
| some value₂ =>
cases value₂ with
| inl x₂ =>
exact False.elim (h₁.1 ⟨x₂, h₂⟩)
| inr special₂ =>
rcases special₂ with ⟨sign₂, nan₂⟩
exact False.elim (h₁.2 ⟨sign₂, nan₂, h₂⟩)
| some value₁ =>
cases c₂ with
| none =>
cases value₁ with
| inl x₁ =>
exact False.elim (h₂.1 ⟨x₁, h₁⟩)
| inr special₁ =>
rcases special₁ with ⟨sign₁, nan₁⟩
exact False.elim (h₂.2 ⟨sign₁, nan₁, h₁⟩)
| some value₂ =>
cases value₁ with
| inl x₁ =>
cases value₂ with
| inl x₂ =>
have hx := numeric_inj x₁ x₂ h₁.1 h₂.1 (h₁.2.trans h₂.2.symm)
cases hx
rfl
| inr special₂ =>
rcases special₂ with ⟨sign₂, nan₂⟩
exact False.elim (numeric_special_disjoint x₁ bs sign₂ nan₂ h₁.1 h₁.2 h₂)
| inr special₁ =>
rcases special₁ with ⟨sign₁, nan₁⟩
cases value₂ with
| inl x₂ =>
exact False.elim (numeric_special_disjoint x₂ bs sign₁ nan₁ h₂.1 h₂.2 h₁)
| inr special₂ =>
rcases special₂ with ⟨sign₂, nan₂⟩
have hs := special_inj bs sign₁ nan₁ sign₂ nan₂ h₁ h₂
cases hs
rfl
constructor
· intro bs c₁ c₂ _ h₁ h₂
change Classifies bs c₁ at h₁
change Classifies bs c₂ at h₂
exact classification_unique bs c₁ c₂ h₁ h₂
· intro bs x₁ x₂ _ h₁ h₂
change NumericLiteral bs x₁ at h₁
change NumericLiteral bs x₂ at h₂
exact numeric_inj x₁ x₂ h₁.1 h₂.1 (h₁.2.trans h₂.2.symm)
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
- DecimalGoalVocabularyDefault
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64
All 14 entries
- DecimalGoalVocabularyDefault
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64
- 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)
- Dec2flt_modelNumImpDec2fltLemireU64 · dec2flt/mod.rs:217 Program Rust
- Dec2flt_modelNumImpTraitsFloatExtU64 · traits.rs:339 Program Rust
- biased_fp_to_float · dec2flt/mod.rs:282 Program Rust
More program dependencies (159)
- 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
- pow10_fast_path · dec2flt/mod.rs:222 Program Rust
- from_u64_bits · traits.rs:341 Program Rust
- integer_decode · traits.rs:348 Program Rust
- Dec2flt_modelNumImpTraitsFloatU64 · traits.rs:309 Program Rust
- read_u64 · dec2flt/common.rs:18 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 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
- FloatExt · traits.rs:170 Program Rust
- from_u64 · dec2flt/mod.rs:263 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
- offset_from · dec2flt/common.rs:30 Program Rust
- write_u64 · dec2flt/common.rs:25 Program Rust
- Dec2flt_modelNumImpTraitsInt · traits.rs:51 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 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
- 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
- Int · traits.rs:27 Program Rust
- Dec2flt_modelNumImpTraitsCastIntoI16 · traits.rs:45 Program Rust
- ONE · traits.rs:53 Program Rust
- ZERO · traits.rs:52 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
- cast · traits.rs:46 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)
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 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
- 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_DIGITS · core/src/num/f64.rs:412 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
- from_bits · core/src/num/f64.rs:1269 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- as_bytes · core/src/str/mod.rs:498 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
- 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
- CoreMarkerCopy · core/src/marker.rs:57 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
- 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
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
- 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
Technical checking records
Local closure summary
{
"node": "ClassificationDeterminism",
"closure_version": "patch_c_v1",
"active_decl_hash": "078db0b83673f4ef3ebcc4985b44a6877bdee54b822aba44ac075394103d77d8",
"active_statement_hash": "0b7214ec43b11184b4c228f612ccb9f369937a0e283b6ad5f3b8b05448f06389",
"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-91",
"boundary_theorems": {},
"strict_theorem_deps": {},
"strict_definition_deps": {
"DecimalGoalVocabulary": "64f24e4e46904b6a",
"DecimalGoalVocabularyDefault": "512f8d0aea894250",
"DecimalLexeme": "bf0c609978369054"
}
}Prose assessment
{
"label": "Sound flag superseded by recorded Lean closure",
"assessment_status": "ReviewerPinnedFail",
"fingerprint_relation": "differs from current fingerprint",
"assessment_fingerprint": "sound-v2:a6c915e712aeb7161bf7af6ddd2eb0852c8f57139c20e732fa3d09ec07b01155",
"current_fingerprint": "sound-v2:96794f3e1efa4e96954c81f17dd7a1464271168cfed992d9567017bd6d1c784b",
"superseded_for_theorem_closure": true
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Fail",
"substantiveness_status": "Pass"
}