P616_T1_CompatibleCompletion

Lean checked

Statement

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

Lemma · Compatible completion of actual normal observations

There exists a total abstract package C of AbstractComponents satisfying all DispatchContracts and NormalComponentRefinement. In particular the same package has the full-domain on-normal observation equations, bounded numeric normal equations, and unrestricted special, assembly and negation normal equations of that refinement. No unrestricted actual integer or slow termination is asserted.

Lean statement

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

import Tablet.DispatchContracts
import Tablet.P9_T1_NormalComponentRefinement
import Tablet.P13_T1_NumberHelperAcceptance
import Tablet.P13_T1_NumberHelperRejection
import Tablet.P13_T1_NumberHelperRecordBounds
import Tablet.P13_T1_NumberHelperAccumulatedValue
import Tablet.P13_T1_NativeCorrectOrDefer
import Tablet.IntegerCorrectOrDefer
import Tablet.P13_T1_SlowAccumulatedRounding
import Tablet.SpecialHelperInfinity
import Tablet.SpecialHelperNan
import Tablet.SpecialHelperRejection
import Tablet.AssemblyCorrespondence
import Tablet.ClassificationDeterminism
import Tablet.RoundingTotality
import Tablet.P616_T1_NegationWordLaw
import Tablet.P616_T1_ExactTransportApplicationsB

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P616_T1_CompatibleCompletion]
theorem P616_T1_CompatibleCompletion :
    exists C : P9_T1_AbstractComponents,
      DispatchContracts C ∧ P9_T1_NormalComponentRefinement C := 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

We construct one local data record, not a new model definition. In ActualDispatchOperations, each operation has one determinate outer Result. Select its enclosed value when that result is \texttt{ok}; failures and divergence are the other outer cases, not normally returned optional values. Define C.\mathrm{parseNumber} and C.\mathrm{native} by this selection, using None in every non-ok case. Define C.\mathrm{integer} the same way, using the deferral pair (m=0,p_{\rm biased}=-1) in every non-ok case. The two constant fields fit U64 and I32, respectively, by 0<2^{64} and -2^{31}\leq-1<2^{31}.
For special parsing and assembly use the normally observed value, and use None and the zero word respectively outside ok cases. In fact these defaults are unreachable on the required special and assembly domains, as proved below. For negation choose the normally observed word, with zero outside ok cases; NegationWordLaw excludes the latter case on every word.
Define the slow value as follows. If the actual slow call is ok of a pair, use that pair. Otherwise, on a source-valid body admitting a valid unsigned numeric lexeme x, choose a magnitude word w rounding its accumulated magnitude and use (m=w,p_{\rm biased}=0). Outside this required domain use the zero pair. The choice of w is justified: the accumulated formula in DecimalGoalVocabularyDefault is a nonnegative natural digit fold times a positive integer power of ten, so RoundingTotality supplies w. Every byte value is below 256, and ClassificationDeterminism makes the unsigned lexeme rendering that body unique: any two witnesses give two numeric classifications of exactly its byte map. Hence the chosen lexeme equals every witness to which the slow contract will subsequently be applied. Classical choice makes these pointwise choices simultaneous, giving total functions and thus a record of AbstractComponents.
We verify every field of DispatchContracts. On a nonempty source-valid unsigned numeric slice through A, NumberHelperAcceptance gives an actual ok Some value; selection therefore gives that same Some value, proving number_accept. On the corresponding non-numeric domain, NumberHelperRejection gives actual ok None, proving number_reject. If C.\mathrm{parseNumber}(b)=\mathrm{Some}(d) on the unrestricted nonempty source-valid domain, the None default is impossible. Thus actual parsing is ok Some d, and NumberHelperRecordBounds gives exactly negative false and mantissa below 10^{19}, without an A or grammar premise. On a valid unsigned rendering through A, the same normal equation and NumberHelperAccumulatedValue give either the exact record equality or its half-open interval, according to many_digits. The first assertion of ExactTransportApplicationsB supplies exact_transport on precisely its unsigned source-valid B domain.
For any source-valid special body and sign, decide whether it is an unsigned infinity, an unsigned NaN, or neither. In the first case SpecialHelperInfinity gives actual ok Some of the signed infinity; in the second SpecialHelperNan gives actual ok Some of a NaN; in the third SpecialHelperRejection gives actual ok None, using both negated keyword predicates. The actual Float instance in the operations record reduces to the same F64 instance in these three theorem statements. Thus selection proves the three special value laws and also an actual normal equation on every source-valid body. The cases are exhaustive by classical predicate case splitting; no unrestricted parsing termination is inferred from an on-normal law.
If C.\mathrm{native}(d)=\mathrm{Some}(f), its None default is again impossible, so the actual result is ok Some f. NativeCorrectOrDefer excludes its None alternative and supplies exactly many_digits false, the record magnitude rounding and its record sign, proving native_normal on every Decimal. For an integer input with a non-ok actual call the selected default has negative biased exponent, so integer_normal takes its deferral alternative. For an actual ok pair, IntegerCorrectOrDefer gives either deferral or an assembled rounding word. AssemblyCorrespondence supplies the normally observed assembly word for this unrestricted pair. The assembledWord definition in DecimalGoalVocabularyDefault gives the same explicit natural value to any two words assembling the pair; word extensionality therefore identifies the theorem's target with C.\mathrm{assemble} of that pair. Every magnitude target has value at most I=2047\,2^{52}=2^{63}-2^{52}<2^{63} by that same rounding definition. This supplies the additional clear-sign conclusion in integer_normal, without assuming any exponent range for arbitrary pairs.
On a source-valid unsigned numeric slow body, an actual ok pair is covered by SlowAccumulatedRounding. It gives an assembled rounding word; assembly totality and the same raw-word uniqueness identify it with C.\mathrm{assemble} of the selected pair. Its target bound by I gives a clear sign. In a non-ok case the chosen lexeme is the supplied one by the uniqueness proved above. The chosen w rounds its accumulated value and is clear-sign by the target bound. For (m=w,p_{\rm biased}=0), the raw assembly formula is w.\mathit{val}\mathbin{\mathrm{lor}}0=w.\mathit{val}: the I32-to-U64 cast of zero and its 52-bit shift are zero. AssemblyCorrespondence and word extensionality hence give C.\mathrm{assemble} of this pair equal to w. This proves slow_normal also on the non-ok case, but does not claim the concrete slow call becomes normal.
On every unrestricted pair, AssemblyCorrespondence supplies a normal assembly with exactly the required raw formula, so selection proves assembly_all. On every word, NegationWordLaw supplies normal actual negation and its value equation, proving negate_all. This completes every compatible contract field.
Finally verify NormalComponentRefinement for this same record. The number_normal, native_normal, integer_normal and slow_normal implications follow directly from the selection's ok case, at their stated domains; an assumed normal observation cannot take a non-ok default. For number_bounded, split whether an unsigned numeric rendering exists. On a nonempty source-valid A-bounded body, the acceptance or rejection theorem gives an actual normal value in either case, and selection gives exactly that value. The exhaustive special argument above gives special_all. AssemblyCorrespondence gives assembly_all, and the negation lemma gives negate_all, on their unrestricted domains. Thus both sets of fields hold for the same constructed record, proving the existential conjunction. No actual integer or slow success is used except as a legitimate premise of its existing on-normal theorem.

Lean proof


  classical
  let observed {α : Type} (r : Result (Option α)) : Option α :=
    match r with
    | .ok x => x
    | .fail _ => none
    | .div => none
  let observedPair {α : Type} (r : Result α) (fallback : α) : α :=
    match r with
    | .ok x => x
    | .fail _ => fallback
    | .div => fallback
  have observed_ok_some {α : Type} {r : Result (Option α)} {a : α}
      (h : r = .ok (some a)) : observed r = some a := by
    rw [h]
  have observed_ok_none {α : Type} {r : Result (Option α)}
      (h : r = .ok none) : observed r = none := by
    rw [h]
  have observedPair_ok {α : Type} {r : Result α} {fallback a : α}
      (h : r = .ok a) : observedPair r fallback = a := by
    rw [h]
  let defaultFp : num.imp.dec2flt.common.BiasedFp :=
    ⟨0#u64, (-1)#i32⟩
  let chooseSlow (body : Slice Std.U8) : num.imp.dec2flt.common.BiasedFp :=
    if h : ∃ x : DecimalLexeme, x.leadingSign = none ∧
        DecimalGoalVocabularyDefault.validNumeric x ∧
        DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body then
      let x := Classical.choose h
      let hx := Classical.choose_spec h
      let hn : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
        dsimp [DecimalGoalVocabularyDefault]
        positivity
      let w := Classical.choose (RoundingTotality
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
      have hw := Classical.choose_spec (RoundingTotality
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
      ⟨UScalar.ofNatCore w.val (by
        change w.val < 2 ^ 64
        have : w.val ≤ 2047 * 2 ^ 52 := by
          have hh := hw
          change 0 ≤ _ ∧ w.val ≤ 2047 * 2 ^ 52 ∧ _ at hh
          exact hh.2.1
        norm_num at this ⊢
        omega), 0#i32⟩
    else defaultFp
  let C : P9_T1_AbstractComponents := {
    parseNumber := fun body => observed (P9_T1_ActualDispatchOperations.parseNumber body)
    parseSpecial := fun body negative => observed
      (P9_T1_ActualDispatchOperations.parseSpecial body negative)
    native := fun d => observed (P9_T1_ActualDispatchOperations.native d)
    integer := fun q w => observedPair
      (P9_T1_ActualDispatchOperations.integer q w) defaultFp
    slow := fun body => observedPair
      (P9_T1_ActualDispatchOperations.slow body) (chooseSlow body)
    assemble := fun fp => Classical.choose (AssemblyCorrespondence fp)
    negate := fun f => Classical.choose (P616_T1_NegationWordLaw f)
  }
  refine ⟨C, ?_, ?_⟩
  · constructor
    · intro body x hsource hne hlen hsign hvalid hrender
      obtain ⟨d, hd⟩ := P13_T1_NumberHelperAcceptance body x hsource hne hlen hsign hvalid hrender
      refine ⟨d, ?_⟩
      change observed (P9_T1_ActualDispatchOperations.parseNumber body) = some d
      exact observed_ok_some hd
    · intro body hsource hne hlen hbad
      have hd := P13_T1_NumberHelperRejection body hsource hne hlen hbad
      change observed (P9_T1_ActualDispatchOperations.parseNumber body) = none
      exact observed_ok_none hd
    · intro body d hsource hne hparse
      simp only [C] at hparse
      cases hp : P9_T1_ActualDispatchOperations.parseNumber body with
      | fail e => simp [observed, hp] at hparse
      | div => simp [observed, hp] at hparse
      | ok r =>
        simp [observed, hp] at hparse
        cases hr : r with
        | none => simp [hr] at hparse
        | some d' =>
          have heq : d' = d := Option.some.inj (by simpa [hr] using hparse)
          subst d
          exact P13_T1_NumberHelperRecordBounds body d' hsource hne (by simpa [hp, hr])
    · intro body x d hsource hlen hsign hvalid hrender hparse
      simp only [C] at hparse
      cases hp : P9_T1_ActualDispatchOperations.parseNumber body with
      | fail e => simp [observed, hp] at hparse
      | div => simp [observed, hp] at hparse
      | ok r =>
        simp [observed, hp] at hparse
        cases hr : r with
        | none => simp [hr] at hparse
        | some d' =>
          have heq : d' = d := Option.some.inj (by simpa [hr] using hparse)
          subst d
          exact P13_T1_NumberHelperAccumulatedValue body x d' hsource hlen hsign hvalid hrender (by simpa [hp, hr])
    · intro body x hsource hlen hsign hvalid hrender target
      exact (P616_T1_ExactTransportApplicationsB.1 body x hsource hlen hsign hvalid hrender target)
    · intro body negative hsource hinf
      obtain ⟨f, hf, hvalue⟩ := SpecialHelperInfinity body negative hinf
      refine ⟨f, ?_, hvalue⟩
      change observed (P9_T1_ActualDispatchOperations.parseSpecial body negative) = some f
      exact observed_ok_some (by simpa [P9_T1_ActualDispatchOperations] using hf)
    · intro body negative hsource hnan
      obtain ⟨f, hf, hvalue⟩ := SpecialHelperNan body negative hnan
      refine ⟨f, ?_, hvalue⟩
      change observed (P9_T1_ActualDispatchOperations.parseSpecial body negative) = some f
      exact observed_ok_some (by simpa [P9_T1_ActualDispatchOperations] using hf)
    · intro body negative hsource hbad
      have hd := SpecialHelperRejection body negative hsource
        (fun hi => hbad ⟨false, hi⟩) (fun hn => hbad ⟨true, hn⟩)
      change observed (P9_T1_ActualDispatchOperations.parseSpecial body negative) = none
      exact observed_ok_none (by simpa [P9_T1_ActualDispatchOperations] using hd)
    · intro d f hnative
      simp only [C] at hnative
      cases hp : P9_T1_ActualDispatchOperations.native d with
      | fail e => simp [observed, hp] at hnative
      | div => simp [observed, hp] at hnative
      | ok r =>
        simp [observed, hp] at hnative
        cases hr : r with
        | none => simp [hr] at hnative
        | some f' =>
          have heq : f' = f := Option.some.inj (by simpa [hr] using hnative)
          subst f
          rcases P13_T1_NativeCorrectOrDefer d r (by simpa [hp] ) with hnone | ⟨f, magnitude, hret, hmany, hround, hsign⟩
          · simp [hr] at hnone
          · simp [hr] at hret
            subst f
            exact ⟨hmany, ⟨magnitude, hround, hsign⟩⟩
    · intro q w
      dsimp [C, observedPair]
      cases hp : P9_T1_ActualDispatchOperations.integer q w with
      | fail e => simp [hp, defaultFp]
      | div => simp [hp, defaultFp]
      | ok fp =>
        change (fp.p_biased.val < 0 ∨
          (DecimalGoalVocabularyDefault.roundsMagnitude
            ((w.val : Real) * (10 : Real) ^ q.val) (C.assemble fp) ∧
            (C.assemble fp).val < 2 ^ 63))
        rcases IntegerCorrectOrDefer q w fp (by simpa [P9_T1_ActualDispatchOperations] using hp) with hdefer | ⟨target, hassembled, hround⟩
        · exact Or.inl hdefer
        · have ha := AssemblyCorrespondence fp
          let f : F64 := Classical.choose ha
          have hword : DecimalGoalVocabularyDefault.assembledWord fp f :=
            Classical.choose_spec ha |>.2
          have hEq : C.assemble fp = f := by
            dsimp [C]
          have hval : target.val = f.val := by
            change target.val = Nat.lor fp.m.val
              (((fp.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hassembled
            change f.val = Nat.lor fp.m.val
              (((fp.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hword
            omega
          have htf : target = f := by
            apply UScalar.eq_of_val_eq
            exact hval
          rw [htf] at hround
          rw [hEq]
          refine Or.inr ⟨hround, ?_⟩
          have hr := hround
          change 0 ≤ ((w.val : Real) * (10 : Real) ^ q.val) ∧
            f.val ≤ 2047 * 2 ^ 52 ∧ _ at hr
          have hi : 2047 * 2 ^ 52 < 2 ^ 63 := by norm_num
          omega
    · intro body x hsource hsign hvalid hrender
      -- The actual observation is used when available; otherwise the selected
      -- canonical rounded fallback has exponent zero.
      change DecimalGoalVocabularyDefault.roundsMagnitude
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x)
          (C.assemble (observedPair
            (P9_T1_ActualDispatchOperations.slow body) (chooseSlow body))) ∧
        (C.assemble (observedPair
          (P9_T1_ActualDispatchOperations.slow body) (chooseSlow body))).val < 2 ^ 63
      cases hp : P9_T1_ActualDispatchOperations.slow body with
      | ok fp =>
        simp [observedPair, hp]
        obtain ⟨magnitude, hword, hround⟩ :=
          P13_T1_SlowAccumulatedRounding body x fp hsource hsign hvalid hrender hp
        have hEq : C.assemble fp = magnitude := by
          change Classical.choose (AssemblyCorrespondence fp) = magnitude
          let f := Classical.choose (AssemblyCorrespondence fp)
          have hassembled := Classical.choose_spec (AssemblyCorrespondence fp) |>.2
          have : f = magnitude := by
            unfold DecimalGoalVocabularyDefault at hword hassembled
            dsimp at hword hassembled
            apply UScalar.eq_of_val_eq
            exact hassembled.trans hword.symm
          exact this
        rw [hEq]
        have hclear := hround
        change 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x ∧
          magnitude.val ≤ 2047 * 2 ^ 52 ∧ _ at hclear
        exact ⟨hround, by omega⟩
      | fail e =>
        have hlex : ∃ y : DecimalLexeme, y.leadingSign = none ∧
            DecimalGoalVocabularyDefault.validNumeric y ∧
            DecimalGoalVocabularyDefault.renderNumeric y = DecimalGoalVocabularyDefault.bytes body :=
          ⟨x, hsign, hvalid, hrender⟩
        simp only [observedPair, hp]
        let y := Classical.choose hlex
        have hy := Classical.choose_spec hlex
        have hsame : y = x := by
          apply (ClassificationDeterminism.2 (DecimalGoalVocabularyDefault.bytes body))
          · intro b hb
            dsimp [DecimalGoalVocabularyDefault] at hb
            obtain ⟨byte, hmem, rfl⟩ := List.mem_map.mp hb
            exact byte.bv.isLt
          · exact ⟨hy.2.1, hy.2.2⟩
          · exact ⟨hvalid, hrender⟩
        subst y
        let hn : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
          dsimp [DecimalGoalVocabularyDefault]
          positivity
        let w := Classical.choose (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        have hw := Classical.choose_spec (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        let fp' := chooseSlow body
        have hassemble : C.assemble fp' = w := by
          have ha := AssemblyCorrespondence fp'
          let f := Classical.choose ha
          have hword := Classical.choose_spec ha |>.2
          have hv : f.val = w.val := by
            change f.val = Nat.lor fp'.m.val
              (((fp'.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hword
            simp only [fp', chooseSlow, dif_pos hlex] at hword
            have hpzero : (0#i32).val = 0 := by decide
            rw [hpzero] at hword
            norm_num at hword
            rw [hsame] at hword
            change f.val = w.val at hword
            exact hword
          have hf : f = w := by
            apply UScalar.eq_of_val_eq
            exact hv
          change Classical.choose (AssemblyCorrespondence fp') = w
          exact hf
        change DecimalGoalVocabularyDefault.roundsMagnitude
            (DecimalGoalVocabularyDefault.accumulatedMagnitude x) (C.assemble (chooseSlow body)) ∧
          (C.assemble (chooseSlow body)).val < 2 ^ 63
        rw [hassemble]
        have hr := hw
        change 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x ∧
          w.val ≤ 2047 * 2 ^ 52 ∧ _ at hr
        have hi : 2047 * 2 ^ 52 < 2 ^ 63 := by norm_num
        exact ⟨hw, by omega⟩
      | div =>
        have hlex : ∃ y : DecimalLexeme, y.leadingSign = none ∧
            DecimalGoalVocabularyDefault.validNumeric y ∧
            DecimalGoalVocabularyDefault.renderNumeric y = DecimalGoalVocabularyDefault.bytes body :=
          ⟨x, hsign, hvalid, hrender⟩
        simp only [observedPair, hp]
        let y := Classical.choose hlex
        have hy := Classical.choose_spec hlex
        have hsame : y = x := by
          apply (ClassificationDeterminism.2 (DecimalGoalVocabularyDefault.bytes body))
          · intro b hb
            dsimp [DecimalGoalVocabularyDefault] at hb
            obtain ⟨byte, hmem, rfl⟩ := List.mem_map.mp hb
            exact byte.bv.isLt
          · exact ⟨hy.2.1, hy.2.2⟩
          · exact ⟨hvalid, hrender⟩
        subst y
        let hn : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
          dsimp [DecimalGoalVocabularyDefault]
          positivity
        let w := Classical.choose (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        have hw := Classical.choose_spec (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        let fp' := chooseSlow body
        have hassemble : C.assemble fp' = w := by
          have ha := AssemblyCorrespondence fp'
          let f := Classical.choose ha
          have hword := Classical.choose_spec ha |>.2
          have hv : f.val = w.val := by
            change f.val = Nat.lor fp'.m.val
              (((fp'.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hword
            simp only [fp', chooseSlow, dif_pos hlex] at hword
            have hpzero : (0#i32).val = 0 := by decide
            rw [hpzero] at hword
            norm_num at hword
            rw [hsame] at hword
            change f.val = w.val at hword
            exact hword
          have hf : f = w := by
            apply UScalar.eq_of_val_eq
            exact hv
          change Classical.choose (AssemblyCorrespondence fp') = w
          exact hf
        change DecimalGoalVocabularyDefault.roundsMagnitude
            (DecimalGoalVocabularyDefault.accumulatedMagnitude x) (C.assemble (chooseSlow body)) ∧
          (C.assemble (chooseSlow body)).val < 2 ^ 63
        rw [hassemble]
        have hr := hw
        change 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x ∧
          w.val ≤ 2047 * 2 ^ 52 ∧ _ at hr
        have hi : 2047 * 2 ^ 52 < 2 ^ 63 := by norm_num
        exact ⟨hw, by omega⟩
    · intro fp
      exact Classical.choose_spec (AssemblyCorrespondence fp) |>.2
    · intro f
      exact Classical.choose_spec (P616_T1_NegationWordLaw f) |>.2
  · constructor
    · intro body out hsource hne hnormal
      simp only [C]
      cases hp : P9_T1_ActualDispatchOperations.parseNumber body with
      | ok r => simp [observed, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro body hsource hne hlen
      by_cases hnum : ∃ x : DecimalLexeme, x.leadingSign = none ∧
          DecimalGoalVocabularyDefault.validNumeric x ∧
          DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body
      · obtain ⟨x, hsign, hvalid, hrender⟩ := hnum
        obtain ⟨d, hd⟩ := P13_T1_NumberHelperAcceptance body x hsource hne hlen hsign hvalid hrender
        change P9_T1_ActualDispatchOperations.parseNumber body =
          ok (observed (P9_T1_ActualDispatchOperations.parseNumber body))
        rw [hd]
      · have hd := P13_T1_NumberHelperRejection body hsource hne hlen hnum
        change P9_T1_ActualDispatchOperations.parseNumber body =
          ok (observed (P9_T1_ActualDispatchOperations.parseNumber body))
        rw [hd]
    · intro body negative hsource
      by_cases hinf : DecimalGoalVocabularyDefault.specialLiteral
          (DecimalGoalVocabularyDefault.bytes body) none false
      · obtain ⟨f, hf, _⟩ := SpecialHelperInfinity body negative hinf
        change P9_T1_ActualDispatchOperations.parseSpecial body negative =
          ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative))
        have hf' : P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) :=
          by simpa [P9_T1_ActualDispatchOperations] using hf
        have ho := observed_ok_some (r := P9_T1_ActualDispatchOperations.parseSpecial body negative)
          (a := f) hf'
        calc
          P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) := hf'
          _ = ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative)) :=
            congrArg Result.ok ho.symm
      · by_cases hnan : DecimalGoalVocabularyDefault.specialLiteral
            (DecimalGoalVocabularyDefault.bytes body) none true
        · obtain ⟨f, hf, _⟩ := SpecialHelperNan body negative hnan
          change P9_T1_ActualDispatchOperations.parseSpecial body negative =
            ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative))
          have hf' : P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) :=
            by simpa [P9_T1_ActualDispatchOperations] using hf
          have ho := observed_ok_some (r := P9_T1_ActualDispatchOperations.parseSpecial body negative)
            (a := f) hf'
          calc
            P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) := hf'
            _ = ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative)) :=
              congrArg Result.ok ho.symm
        · have hf := SpecialHelperRejection body negative hsource hinf hnan
          change P9_T1_ActualDispatchOperations.parseSpecial body negative =
            ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative))
          have hf' : P9_T1_ActualDispatchOperations.parseSpecial body negative = ok none :=
            by simpa [P9_T1_ActualDispatchOperations] using hf
          have ho := observed_ok_none (r := P9_T1_ActualDispatchOperations.parseSpecial body negative) hf'
          calc
            P9_T1_ActualDispatchOperations.parseSpecial body negative = ok none := hf'
            _ = ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative)) :=
              congrArg Result.ok ho.symm
    · intro d out hnormal
      cases hp : P9_T1_ActualDispatchOperations.native d with
      | ok r => simp [C, observed, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro q w out hnormal
      cases hp : P9_T1_ActualDispatchOperations.integer q w with
      | ok fp => simp [C, observedPair, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro body x out hsource hsign hvalid hrender hnormal
      cases hp : P9_T1_ActualDispatchOperations.slow body with
      | ok fp => simp [C, observedPair, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro fp
      dsimp [C]
      exact Classical.choose_spec (AssemblyCorrespondence fp) |>.1
    · intro f
      dsimp [C]
      exact Classical.choose_spec (P616_T1_NegationWordLaw f) |>.1
end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DispatchContracts
import Tablet.P9_T1_NormalComponentRefinement
import Tablet.P13_T1_NumberHelperAcceptance
import Tablet.P13_T1_NumberHelperRejection
import Tablet.P13_T1_NumberHelperRecordBounds
import Tablet.P13_T1_NumberHelperAccumulatedValue
import Tablet.P13_T1_NativeCorrectOrDefer
import Tablet.IntegerCorrectOrDefer
import Tablet.P13_T1_SlowAccumulatedRounding
import Tablet.SpecialHelperInfinity
import Tablet.SpecialHelperNan
import Tablet.SpecialHelperRejection
import Tablet.AssemblyCorrespondence
import Tablet.ClassificationDeterminism
import Tablet.RoundingTotality
import Tablet.P616_T1_NegationWordLaw
import Tablet.P616_T1_ExactTransportApplicationsB

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P616_T1_CompatibleCompletion]
theorem P616_T1_CompatibleCompletion :
    exists C : P9_T1_AbstractComponents,
      DispatchContracts C ∧ P9_T1_NormalComponentRefinement C := by
-- BODY
  classical
  let observed {α : Type} (r : Result (Option α)) : Option α :=
    match r with
    | .ok x => x
    | .fail _ => none
    | .div => none
  let observedPair {α : Type} (r : Result α) (fallback : α) : α :=
    match r with
    | .ok x => x
    | .fail _ => fallback
    | .div => fallback
  have observed_ok_some {α : Type} {r : Result (Option α)} {a : α}
      (h : r = .ok (some a)) : observed r = some a := by
    rw [h]
  have observed_ok_none {α : Type} {r : Result (Option α)}
      (h : r = .ok none) : observed r = none := by
    rw [h]
  have observedPair_ok {α : Type} {r : Result α} {fallback a : α}
      (h : r = .ok a) : observedPair r fallback = a := by
    rw [h]
  let defaultFp : num.imp.dec2flt.common.BiasedFp :=
    ⟨0#u64, (-1)#i32⟩
  let chooseSlow (body : Slice Std.U8) : num.imp.dec2flt.common.BiasedFp :=
    if h : ∃ x : DecimalLexeme, x.leadingSign = none ∧
        DecimalGoalVocabularyDefault.validNumeric x ∧
        DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body then
      let x := Classical.choose h
      let hx := Classical.choose_spec h
      let hn : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
        dsimp [DecimalGoalVocabularyDefault]
        positivity
      let w := Classical.choose (RoundingTotality
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
      have hw := Classical.choose_spec (RoundingTotality
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
      ⟨UScalar.ofNatCore w.val (by
        change w.val < 2 ^ 64
        have : w.val ≤ 2047 * 2 ^ 52 := by
          have hh := hw
          change 0 ≤ _ ∧ w.val ≤ 2047 * 2 ^ 52 ∧ _ at hh
          exact hh.2.1
        norm_num at this ⊢
        omega), 0#i32⟩
    else defaultFp
  let C : P9_T1_AbstractComponents := {
    parseNumber := fun body => observed (P9_T1_ActualDispatchOperations.parseNumber body)
    parseSpecial := fun body negative => observed
      (P9_T1_ActualDispatchOperations.parseSpecial body negative)
    native := fun d => observed (P9_T1_ActualDispatchOperations.native d)
    integer := fun q w => observedPair
      (P9_T1_ActualDispatchOperations.integer q w) defaultFp
    slow := fun body => observedPair
      (P9_T1_ActualDispatchOperations.slow body) (chooseSlow body)
    assemble := fun fp => Classical.choose (AssemblyCorrespondence fp)
    negate := fun f => Classical.choose (P616_T1_NegationWordLaw f)
  }
  refine ⟨C, ?_, ?_⟩
  · constructor
    · intro body x hsource hne hlen hsign hvalid hrender
      obtain ⟨d, hd⟩ := P13_T1_NumberHelperAcceptance body x hsource hne hlen hsign hvalid hrender
      refine ⟨d, ?_⟩
      change observed (P9_T1_ActualDispatchOperations.parseNumber body) = some d
      exact observed_ok_some hd
    · intro body hsource hne hlen hbad
      have hd := P13_T1_NumberHelperRejection body hsource hne hlen hbad
      change observed (P9_T1_ActualDispatchOperations.parseNumber body) = none
      exact observed_ok_none hd
    · intro body d hsource hne hparse
      simp only [C] at hparse
      cases hp : P9_T1_ActualDispatchOperations.parseNumber body with
      | fail e => simp [observed, hp] at hparse
      | div => simp [observed, hp] at hparse
      | ok r =>
        simp [observed, hp] at hparse
        cases hr : r with
        | none => simp [hr] at hparse
        | some d' =>
          have heq : d' = d := Option.some.inj (by simpa [hr] using hparse)
          subst d
          exact P13_T1_NumberHelperRecordBounds body d' hsource hne (by simpa [hp, hr])
    · intro body x d hsource hlen hsign hvalid hrender hparse
      simp only [C] at hparse
      cases hp : P9_T1_ActualDispatchOperations.parseNumber body with
      | fail e => simp [observed, hp] at hparse
      | div => simp [observed, hp] at hparse
      | ok r =>
        simp [observed, hp] at hparse
        cases hr : r with
        | none => simp [hr] at hparse
        | some d' =>
          have heq : d' = d := Option.some.inj (by simpa [hr] using hparse)
          subst d
          exact P13_T1_NumberHelperAccumulatedValue body x d' hsource hlen hsign hvalid hrender (by simpa [hp, hr])
    · intro body x hsource hlen hsign hvalid hrender target
      exact (P616_T1_ExactTransportApplicationsB.1 body x hsource hlen hsign hvalid hrender target)
    · intro body negative hsource hinf
      obtain ⟨f, hf, hvalue⟩ := SpecialHelperInfinity body negative hinf
      refine ⟨f, ?_, hvalue⟩
      change observed (P9_T1_ActualDispatchOperations.parseSpecial body negative) = some f
      exact observed_ok_some (by simpa [P9_T1_ActualDispatchOperations] using hf)
    · intro body negative hsource hnan
      obtain ⟨f, hf, hvalue⟩ := SpecialHelperNan body negative hnan
      refine ⟨f, ?_, hvalue⟩
      change observed (P9_T1_ActualDispatchOperations.parseSpecial body negative) = some f
      exact observed_ok_some (by simpa [P9_T1_ActualDispatchOperations] using hf)
    · intro body negative hsource hbad
      have hd := SpecialHelperRejection body negative hsource
        (fun hi => hbad ⟨false, hi⟩) (fun hn => hbad ⟨true, hn⟩)
      change observed (P9_T1_ActualDispatchOperations.parseSpecial body negative) = none
      exact observed_ok_none (by simpa [P9_T1_ActualDispatchOperations] using hd)
    · intro d f hnative
      simp only [C] at hnative
      cases hp : P9_T1_ActualDispatchOperations.native d with
      | fail e => simp [observed, hp] at hnative
      | div => simp [observed, hp] at hnative
      | ok r =>
        simp [observed, hp] at hnative
        cases hr : r with
        | none => simp [hr] at hnative
        | some f' =>
          have heq : f' = f := Option.some.inj (by simpa [hr] using hnative)
          subst f
          rcases P13_T1_NativeCorrectOrDefer d r (by simpa [hp] ) with hnone | ⟨f, magnitude, hret, hmany, hround, hsign⟩
          · simp [hr] at hnone
          · simp [hr] at hret
            subst f
            exact ⟨hmany, ⟨magnitude, hround, hsign⟩⟩
    · intro q w
      dsimp [C, observedPair]
      cases hp : P9_T1_ActualDispatchOperations.integer q w with
      | fail e => simp [hp, defaultFp]
      | div => simp [hp, defaultFp]
      | ok fp =>
        change (fp.p_biased.val < 0 ∨
          (DecimalGoalVocabularyDefault.roundsMagnitude
            ((w.val : Real) * (10 : Real) ^ q.val) (C.assemble fp) ∧
            (C.assemble fp).val < 2 ^ 63))
        rcases IntegerCorrectOrDefer q w fp (by simpa [P9_T1_ActualDispatchOperations] using hp) with hdefer | ⟨target, hassembled, hround⟩
        · exact Or.inl hdefer
        · have ha := AssemblyCorrespondence fp
          let f : F64 := Classical.choose ha
          have hword : DecimalGoalVocabularyDefault.assembledWord fp f :=
            Classical.choose_spec ha |>.2
          have hEq : C.assemble fp = f := by
            dsimp [C]
          have hval : target.val = f.val := by
            change target.val = Nat.lor fp.m.val
              (((fp.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hassembled
            change f.val = Nat.lor fp.m.val
              (((fp.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hword
            omega
          have htf : target = f := by
            apply UScalar.eq_of_val_eq
            exact hval
          rw [htf] at hround
          rw [hEq]
          refine Or.inr ⟨hround, ?_⟩
          have hr := hround
          change 0 ≤ ((w.val : Real) * (10 : Real) ^ q.val) ∧
            f.val ≤ 2047 * 2 ^ 52 ∧ _ at hr
          have hi : 2047 * 2 ^ 52 < 2 ^ 63 := by norm_num
          omega
    · intro body x hsource hsign hvalid hrender
      -- The actual observation is used when available; otherwise the selected
      -- canonical rounded fallback has exponent zero.
      change DecimalGoalVocabularyDefault.roundsMagnitude
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x)
          (C.assemble (observedPair
            (P9_T1_ActualDispatchOperations.slow body) (chooseSlow body))) ∧
        (C.assemble (observedPair
          (P9_T1_ActualDispatchOperations.slow body) (chooseSlow body))).val < 2 ^ 63
      cases hp : P9_T1_ActualDispatchOperations.slow body with
      | ok fp =>
        simp [observedPair, hp]
        obtain ⟨magnitude, hword, hround⟩ :=
          P13_T1_SlowAccumulatedRounding body x fp hsource hsign hvalid hrender hp
        have hEq : C.assemble fp = magnitude := by
          change Classical.choose (AssemblyCorrespondence fp) = magnitude
          let f := Classical.choose (AssemblyCorrespondence fp)
          have hassembled := Classical.choose_spec (AssemblyCorrespondence fp) |>.2
          have : f = magnitude := by
            unfold DecimalGoalVocabularyDefault at hword hassembled
            dsimp at hword hassembled
            apply UScalar.eq_of_val_eq
            exact hassembled.trans hword.symm
          exact this
        rw [hEq]
        have hclear := hround
        change 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x ∧
          magnitude.val ≤ 2047 * 2 ^ 52 ∧ _ at hclear
        exact ⟨hround, by omega⟩
      | fail e =>
        have hlex : ∃ y : DecimalLexeme, y.leadingSign = none ∧
            DecimalGoalVocabularyDefault.validNumeric y ∧
            DecimalGoalVocabularyDefault.renderNumeric y = DecimalGoalVocabularyDefault.bytes body :=
          ⟨x, hsign, hvalid, hrender⟩
        simp only [observedPair, hp]
        let y := Classical.choose hlex
        have hy := Classical.choose_spec hlex
        have hsame : y = x := by
          apply (ClassificationDeterminism.2 (DecimalGoalVocabularyDefault.bytes body))
          · intro b hb
            dsimp [DecimalGoalVocabularyDefault] at hb
            obtain ⟨byte, hmem, rfl⟩ := List.mem_map.mp hb
            exact byte.bv.isLt
          · exact ⟨hy.2.1, hy.2.2⟩
          · exact ⟨hvalid, hrender⟩
        subst y
        let hn : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
          dsimp [DecimalGoalVocabularyDefault]
          positivity
        let w := Classical.choose (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        have hw := Classical.choose_spec (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        let fp' := chooseSlow body
        have hassemble : C.assemble fp' = w := by
          have ha := AssemblyCorrespondence fp'
          let f := Classical.choose ha
          have hword := Classical.choose_spec ha |>.2
          have hv : f.val = w.val := by
            change f.val = Nat.lor fp'.m.val
              (((fp'.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hword
            simp only [fp', chooseSlow, dif_pos hlex] at hword
            have hpzero : (0#i32).val = 0 := by decide
            rw [hpzero] at hword
            norm_num at hword
            rw [hsame] at hword
            change f.val = w.val at hword
            exact hword
          have hf : f = w := by
            apply UScalar.eq_of_val_eq
            exact hv
          change Classical.choose (AssemblyCorrespondence fp') = w
          exact hf
        change DecimalGoalVocabularyDefault.roundsMagnitude
            (DecimalGoalVocabularyDefault.accumulatedMagnitude x) (C.assemble (chooseSlow body)) ∧
          (C.assemble (chooseSlow body)).val < 2 ^ 63
        rw [hassemble]
        have hr := hw
        change 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x ∧
          w.val ≤ 2047 * 2 ^ 52 ∧ _ at hr
        have hi : 2047 * 2 ^ 52 < 2 ^ 63 := by norm_num
        exact ⟨hw, by omega⟩
      | div =>
        have hlex : ∃ y : DecimalLexeme, y.leadingSign = none ∧
            DecimalGoalVocabularyDefault.validNumeric y ∧
            DecimalGoalVocabularyDefault.renderNumeric y = DecimalGoalVocabularyDefault.bytes body :=
          ⟨x, hsign, hvalid, hrender⟩
        simp only [observedPair, hp]
        let y := Classical.choose hlex
        have hy := Classical.choose_spec hlex
        have hsame : y = x := by
          apply (ClassificationDeterminism.2 (DecimalGoalVocabularyDefault.bytes body))
          · intro b hb
            dsimp [DecimalGoalVocabularyDefault] at hb
            obtain ⟨byte, hmem, rfl⟩ := List.mem_map.mp hb
            exact byte.bv.isLt
          · exact ⟨hy.2.1, hy.2.2⟩
          · exact ⟨hvalid, hrender⟩
        subst y
        let hn : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x := by
          dsimp [DecimalGoalVocabularyDefault]
          positivity
        let w := Classical.choose (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        have hw := Classical.choose_spec (RoundingTotality
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) hn)
        let fp' := chooseSlow body
        have hassemble : C.assemble fp' = w := by
          have ha := AssemblyCorrespondence fp'
          let f := Classical.choose ha
          have hword := Classical.choose_spec ha |>.2
          have hv : f.val = w.val := by
            change f.val = Nat.lor fp'.m.val
              (((fp'.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)) at hword
            simp only [fp', chooseSlow, dif_pos hlex] at hword
            have hpzero : (0#i32).val = 0 := by decide
            rw [hpzero] at hword
            norm_num at hword
            rw [hsame] at hword
            change f.val = w.val at hword
            exact hword
          have hf : f = w := by
            apply UScalar.eq_of_val_eq
            exact hv
          change Classical.choose (AssemblyCorrespondence fp') = w
          exact hf
        change DecimalGoalVocabularyDefault.roundsMagnitude
            (DecimalGoalVocabularyDefault.accumulatedMagnitude x) (C.assemble (chooseSlow body)) ∧
          (C.assemble (chooseSlow body)).val < 2 ^ 63
        rw [hassemble]
        have hr := hw
        change 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x ∧
          w.val ≤ 2047 * 2 ^ 52 ∧ _ at hr
        have hi : 2047 * 2 ^ 52 < 2 ^ 63 := by norm_num
        exact ⟨hw, by omega⟩
    · intro fp
      exact Classical.choose_spec (AssemblyCorrespondence fp) |>.2
    · intro f
      exact Classical.choose_spec (P616_T1_NegationWordLaw f) |>.2
  · constructor
    · intro body out hsource hne hnormal
      simp only [C]
      cases hp : P9_T1_ActualDispatchOperations.parseNumber body with
      | ok r => simp [observed, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro body hsource hne hlen
      by_cases hnum : ∃ x : DecimalLexeme, x.leadingSign = none ∧
          DecimalGoalVocabularyDefault.validNumeric x ∧
          DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body
      · obtain ⟨x, hsign, hvalid, hrender⟩ := hnum
        obtain ⟨d, hd⟩ := P13_T1_NumberHelperAcceptance body x hsource hne hlen hsign hvalid hrender
        change P9_T1_ActualDispatchOperations.parseNumber body =
          ok (observed (P9_T1_ActualDispatchOperations.parseNumber body))
        rw [hd]
      · have hd := P13_T1_NumberHelperRejection body hsource hne hlen hnum
        change P9_T1_ActualDispatchOperations.parseNumber body =
          ok (observed (P9_T1_ActualDispatchOperations.parseNumber body))
        rw [hd]
    · intro body negative hsource
      by_cases hinf : DecimalGoalVocabularyDefault.specialLiteral
          (DecimalGoalVocabularyDefault.bytes body) none false
      · obtain ⟨f, hf, _⟩ := SpecialHelperInfinity body negative hinf
        change P9_T1_ActualDispatchOperations.parseSpecial body negative =
          ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative))
        have hf' : P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) :=
          by simpa [P9_T1_ActualDispatchOperations] using hf
        have ho := observed_ok_some (r := P9_T1_ActualDispatchOperations.parseSpecial body negative)
          (a := f) hf'
        calc
          P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) := hf'
          _ = ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative)) :=
            congrArg Result.ok ho.symm
      · by_cases hnan : DecimalGoalVocabularyDefault.specialLiteral
            (DecimalGoalVocabularyDefault.bytes body) none true
        · obtain ⟨f, hf, _⟩ := SpecialHelperNan body negative hnan
          change P9_T1_ActualDispatchOperations.parseSpecial body negative =
            ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative))
          have hf' : P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) :=
            by simpa [P9_T1_ActualDispatchOperations] using hf
          have ho := observed_ok_some (r := P9_T1_ActualDispatchOperations.parseSpecial body negative)
            (a := f) hf'
          calc
            P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (some f) := hf'
            _ = ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative)) :=
              congrArg Result.ok ho.symm
        · have hf := SpecialHelperRejection body negative hsource hinf hnan
          change P9_T1_ActualDispatchOperations.parseSpecial body negative =
            ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative))
          have hf' : P9_T1_ActualDispatchOperations.parseSpecial body negative = ok none :=
            by simpa [P9_T1_ActualDispatchOperations] using hf
          have ho := observed_ok_none (r := P9_T1_ActualDispatchOperations.parseSpecial body negative) hf'
          calc
            P9_T1_ActualDispatchOperations.parseSpecial body negative = ok none := hf'
            _ = ok (observed (P9_T1_ActualDispatchOperations.parseSpecial body negative)) :=
              congrArg Result.ok ho.symm
    · intro d out hnormal
      cases hp : P9_T1_ActualDispatchOperations.native d with
      | ok r => simp [C, observed, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro q w out hnormal
      cases hp : P9_T1_ActualDispatchOperations.integer q w with
      | ok fp => simp [C, observedPair, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro body x out hsource hsign hvalid hrender hnormal
      cases hp : P9_T1_ActualDispatchOperations.slow body with
      | ok fp => simp [C, observedPair, hp] at hnormal ⊢; exact hnormal.symm
      | fail e => simp [hp] at hnormal
      | div => simp [hp] at hnormal
    · intro fp
      dsimp [C]
      exact Classical.choose_spec (AssemblyCorrespondence fp) |>.1
    · intro f
      dsimp [C]
      exact Classical.choose_spec (P616_T1_NegationWordLaw f) |>.1
end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (199)
More program dependencies (157)
Standard-library dependencies (39)

Related source and models come from the extraction records and declared dependencies.

Proof assumptions and review

Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.

Transitive assumptions

This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.

Helper theorems included
All 331 entries
Technical checking records
Local closure summary
{
  "node": "P616_T1_CompatibleCompletion",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "b3614c96cede850d2ca41f1b80920c784e55e1f2da90bc3cf85660f9b7cc8287",
  "active_statement_hash": "89aabcd2d05eeed634668aad8e5198f0af7d2e606b9321f211e9f0a8fca4ac9e",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-202",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "AssemblyCorrespondence": "e3495a6647394e20",
    "ClassificationDeterminism": "1887cc51648312b8",
    "DecimalGoalVocabularyDefault": "94cb4c406f8efb78",
    "IntegerCorrectOrDefer": "f60d8456c59b0974",
    "P13_T1_NativeCorrectOrDefer": "bc7b08c927fd6202",
    "P13_T1_NumberHelperAcceptance": "aacd712e0369701d",
    "P13_T1_NumberHelperAccumulatedValue": "3a42b49277c1d6ef",
    "P13_T1_NumberHelperRecordBounds": "b96a9a092678dd07",
    "P13_T1_NumberHelperRejection": "77aedd7d8ab343e5",
    "P13_T1_SlowAccumulatedRounding": "bab075aca016051d",
    "P616_T1_ExactTransportApplicationsB": "8f8f27340cee5a3e",
    "P616_T1_NegationWordLaw": "6afa6508db03a2f5",
    "RoundingTotality": "909450e1d539dec0",
    "SpecialHelperInfinity": "4124e26dd85ce114",
    "SpecialHelperNan": "1abf1a568c158d53",
    "SpecialHelperRejection": "e1e229c5dd3ecf3c"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "91e42e6d78c02c8e",
    "DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
    "DecimalLexeme": "250be645520aec86",
    "DispatchContracts": "008abfbd503545bf",
    "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",
    "P9_T1_AbstractComponents": "0a7e8b7bdbce0180",
    "P9_T1_ActualDispatchOperations": "d8bf51ebbbf153ac",
    "P9_T1_DispatchOperations": "c43614ff2149ecf2",
    "P9_T1_NormalComponentRefinement": "4d420281ea4ed545",
    "Preamble": "5575719dcb1443eb",
    "SourceValidByteSlice": "3dc42716a6378d26",
    "num_imp_dec2flt_Lemire": "1923f90c53d323e6",
    "num_imp_dec2flt_biased_fp_to_float": "acdde060e8d35ca7",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "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_slow_parse_long_mantissa": "cd8af64c3688b60f",
    "num_imp_traits_FloatExt": "f996e5400649797d"
  }
}
Prose assessment
{
  "label": "Lean proof closed; predictive prose review no longer required",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": "sound-v2:dbe59ca074523433ca109ee000f67fdb1eec8cd330019f4b1184d5b6475276af",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}