DecimalLeftShiftFirstLoopSemantics

Lean checked

Statement

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

Helper · Exact semantics of the first decimal left-shift loop

Let a be a 768-cell array, let b be a Boolean, and let 0\le k\le60. Put n=\mathit{read} and w=\mathit{write}, assume n\le768 and n\le w, and suppose every entry in a[0:n] is below ten. Write
x=(a[0:n])\quad\hbox{and}\quad I=\operatorname{fold}_{10}(x).
If the extracted left_shift_loop0, started with Boolean b, array a, shift k, read index n, write index w, and zero carry, returns (b',a',q,c), then there is a list of natural digits e=(e_0,\ldots,e_{n-1}) such that
|e|=n,\qquad e_j<10,\qquad q+n=w,\qquad c<2^k,
and, on writing W=\operatorname{fold}_{10}(e),
2^k I=c10^n+W. \tag{1}
For every j<n with q+j<768, cell q+j of a' has value e_j. Every cell t<768 outside the half-open interval [q,w) is unchanged from a. Finally,
b'=\mathrm{true}\quad\Longleftrightarrow\quad b=\mathrm{true}\ \text{or}\ \exists j<n,\ 768\le q+j\ \text{and}\ e_j\ne0. \tag{2}

Lean statement

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

import Tablet.ResultLoopPartial
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: DecimalLeftShiftFirstLoopSemantics]
theorem DecimalLeftShiftFirstLoopSemantics
    (a a' : Array Std.U8 768#usize) (b b' : Bool)
    (shift read write q : Std.Usize) (carry : Std.U64)
    (hshift : shift.val <= 60)
    (hread : read.val <= 768)
    (hwrite : read.val <= write.val)
    (hdigit : forall z, z ∈ a.val.take read.val -> z.val < 10)
    (hloop :
      num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0
        b a shift read write 0#u64 = ok (b', a', q, carry)) :
    let xs := (a.val.take read.val).map (fun z => z.val)
    let I := xs.foldl (fun acc z => 10 * acc + z) 0
    exists outDigits : List Nat,
      outDigits.length = read.val /\
      (forall z, z ∈ outDigits -> z < 10) /\
      q.val + read.val = write.val /\
      carry.val < 2 ^ shift.val /\
      2 ^ shift.val * I =
        carry.val * 10 ^ read.val +
          outDigits.foldl (fun acc z => 10 * acc + z) 0 /\
      (forall j, j < outDigits.length -> q.val + j < 768 ->
        (a'.val.map (fun z => z.val))[q.val + j]? = outDigits[j]?) /\
      (forall j, j < 768 -> (j < q.val \/ write.val <= j) ->
        a'.val[j]? = a.val[j]?) /\
      (b' = true <-> b = true \/
        exists j, j < outDigits.length /\ 768 <= q.val + j /\
          outDigits[j]? ≠ some 0) := 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

This is an induction over the exact extracted loop in num imp dec2flt decimal seq DecimalSeq left shift, using the result-loop principle ResultLoopPartial. Put B=2^k, and for a current state (\beta,A,r,s,C) let u=n-r be the number of input cells already visited. The invariant supplies a digit list E and asserts
\begin{gathered} 0\le r\le n,\qquad s+(n-r)=w,\qquad C<B,\qquad |E|=n-r,\qquad (\forall z\in E,\ z<10), \tag{3}\\ B\operatorname{fold}_{10}(x[r:n]) =C10^{|E|}+\operatorname{fold}_{10}(E). \tag{4} \end{gathered}
For each j<|E| with s+j<768, the value in A[s+j] is E_j. Every physical cell outside [s,w) still equals its value in a, and
\beta=\mathrm{true}\quad\Longleftrightarrow\quad b=\mathrm{true}\ \text{or}\ \exists j<|E|,\ 768\le s+j\ \text{and}\ E_j\ne0. \tag{5}
At the initial state take E empty. Then (3) is immediate, (4) is 0=0, the array clauses have empty written interval, and (5) is the identity b=b.
Assume r>0. From n\le w and s+(n-r)=w one gets r\le s, so both unsigned decrements succeed and give r_1=r-1 and s_1=s-1. Moreover r_1<n\le768, hence the fixed array read at r_1 succeeds. This index is below the old write cursor s, so the unchanged-cell clause shows that the value read from the current array is the original digit d=x_{r_1}<10.
The body next casts d to U64 and computes its left shift. The cast is exact because d<10. Since k\le60,
d2^k\le9\cdot2^{60}<2^{64},
so the modeled U64 shift has natural value dB rather than a wrapped value. With C<B, the following checked addition is also exact:
T=C+dB<(B-1)+9B<10\cdot2^{60}<2^{64}. \tag{6}
The division by the nonzero word ten therefore returns Q=\lfloor T/10\rfloor. Its checked multiplication by ten is in range because 10Q\le T<2^{64}, and the subsequent checked subtraction returns
R=T-10Q=T\bmod10,\qquad 0\le R<10. \tag{7}
In particular the U8 cast of R is exact. Also T<10B, so Q<B; this is the new carry bound in (3).
Set E'=R::E. The base-ten fold identity
\operatorname{fold}_{10}(z::L) =z10^{|L|}+\operatorname{fold}_{10}(L) \tag{8}
applied to both the input suffix and E' combines (4) with T=10Q+R to give
B\operatorname{fold}_{10}(x[r_1:n]) =Q10^{|E'|}+\operatorname{fold}_{10}(E'). \tag{9}
Thus (3)--(4) are preserved, and both cursor equations advance by one.
It remains to check the two destination branches. If s_1<768, the array update succeeds and writes the exact U8 representation of R at s_1. This establishes the new j=0 retained-digit clause. Each old retained digit moves from offset j to offset j+1, but its physical index is unchanged because s_1+(j+1)=s+j. The only changed cell is s_1, so every cell outside [s_1,w) remains unchanged. Since this new destination is below 768, it contributes nothing to the omitted-digit disjunction in (5), and the Boolean itself is unchanged.
If instead s_1\ge768, the body performs no array update. The new retained-digit requirement has no j=0 physical case, while all old cases again use s_1+(j+1)=s+j; the unchanged-cell clause follows immediately. When R=0 the Boolean is unchanged and the new omitted digit is zero, so (5) is unchanged. When R>0 the body sets the Boolean to true, and the new witness j=0 satisfies 768\le s_1 and E'_0=R\ne0. Conversely, every omitted nonzero digit of E' is either this new head or, after subtracting one from its list index, an omitted nonzero digit already covered by (5). Hence (5) is preserved in both cap branches.
If r=0, the extracted body returns immediately with the current Boolean, array, write cursor, and carry. The invariant then has |E|=n and s+n=w; its input suffix is all of x, so (4) is exactly (1). Its array and Boolean clauses are exactly the two asserted postconditions. Applying ResultLoopPartial to the successful loop return proves the claim.

Lean proof


  dsimp only
  let xs := (a.val.take read.val).map (fun z => z.val)
  let F := fun ys : List Nat =>
    ys.foldl (fun acc z => 10 * acc + z) 0
  let B := 2 ^ shift.val
  have hBpos : 0 < B := by simp [B]
  have hBle : B <= 2 ^ 60 := by
    exact Nat.pow_le_pow_right (by omega) hshift
  have hxslen : xs.length = read.val := by
    simp [xs, hread, a.property]
  have hxdigit : forall z, z ∈ xs -> z < 10 := by
    intro z hz
    simp only [xs, List.mem_map] at hz
    rcases hz with ⟨u, hu, rfl⟩
    exact hdigit u hu
  have foldlFrom (ys : List Nat) (acc : Nat) :
      ys.foldl (fun n z => 10 * n + z) acc =
        acc * 10 ^ ys.length + F ys := by
    induction ys generalizing acc with
    | nil => simp [F]
    | cons y ys ih =>
      simp only [List.foldl_cons, List.length_cons]
      rw [ih, pow_succ]
      change (10 * acc + y) * 10 ^ ys.length + F ys =
        acc * (10 ^ ys.length * 10) +
          (y :: ys).foldl (fun n z => 10 * n + z) 0
      simp only [List.foldl_cons]
      rw [ih]
      ring
  let Inv := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
      Std.Usize × Std.U64) =>
    let (bc, ac, ri, wi, c) := x
    ri.val <= read.val /\
    wi.val + (read.val - ri.val) = write.val /\
    c.val < B /\
    exists outs : List Nat,
      outs.length = read.val - ri.val /\
      (forall z, z ∈ outs -> z < 10) /\
      B * F (xs.drop ri.val) = c.val * 10 ^ outs.length + F outs /\
      (forall j, j < outs.length -> wi.val + j < 768 ->
        (ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
      (forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
        ac.val[j]? = a.val[j]?) /\
      (bc = true <-> b = true \/
        exists j, j < outs.length /\ 768 <= wi.val + j /\
          outs[j]? ≠ some 0)
  let Post := fun (x : Bool × Array Std.U8 768#usize × Std.Usize × Std.U64) =>
    let (bc, ac, wi, c) := x
    exists outs : List Nat,
      outs.length = read.val /\
      (forall z, z ∈ outs -> z < 10) /\
      wi.val + read.val = write.val /\
      c.val < B /\
      B * F xs = c.val * 10 ^ read.val + F outs /\
      (forall j, j < outs.length -> wi.val + j < 768 ->
        (ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
      (forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
        ac.val[j]? = a.val[j]?) /\
      (bc = true <-> b = true \/
        exists j, j < outs.length /\ 768 <= wi.val + j /\
          outs[j]? ≠ some 0)
  let Body := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
      Std.Usize × Std.U64) =>
    let (bc, ac, ri, wi, c) := x
    num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body
      shift bc ac ri wi c
  have hp : Post (b', a', q, carry) := by
    refine ResultLoopPartial Inv Post Body ?_ (b, a, read, write, 0#u64)
      (b', a', q, carry) ?_ ?_
    · intro x hx r hr
      rcases x with ⟨bc, ac, ri, wi, c⟩
      simp only [Inv] at hx
      rcases hx with ⟨hri, hwi, hcB, outs, houtslen, houtsdigit,
        hnum, harr, houtside, hsticky⟩
      simp only [Body,
        num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body] at hr
      by_cases hri0 : ri.val = 0
      · have hriEq : ri = 0#usize := UScalar.eq_of_val_eq (by simpa using hri0)
        subst ri
        simp at hr
        subst r
        simp only [Post]
        refine ⟨outs, ?_, houtsdigit, ?_, hcB, ?_, harr, houtside, hsticky⟩
        · omega
        · omega
        · simpa [xs, F, houtslen] using hnum
      · have hripos : 0 < ri.val := by omega
        have hrine : ri != 0#usize := by
          simp only [bne_iff_ne]
          intro h
          apply hri0
          simpa [h]
        obtain ⟨ri1, hri1, hri1val⟩ := Aeneas.Std.WP.spec_imp_exists
          (UScalar.sub_spec (x := ri) (y := 1#usize) (by simpa using hripos))
        norm_num at hri1val
        have hriwi : ri.val <= wi.val := by omega
        have hwipos : 0 < wi.val := by omega
        obtain ⟨wi1, hwi1, hwi1val⟩ := Aeneas.Std.WP.spec_imp_exists
          (UScalar.sub_spec (x := wi) (y := 1#usize) (by simpa using hwipos))
        norm_num at hwi1val
        have hri1lt : ri1.val < ac.val.length := by
          rw [ac.property]
          norm_num
          omega
        obtain ⟨digit, hdigitRead, hdigitReadVal⟩ :=
          Aeneas.Std.WP.spec_imp_exists
            (Array.index_usize_spec ac ri1
              (by simpa [Array.length] using hri1lt))
        rw [hri1, hwi1] at hr
        simp only [hrine, if_true, bind_tc_ok] at hr
        rw [hdigitRead] at hr
        have hri1ltRead : ri1.val < read.val := by omega
        have hxdrop := List.drop_eq_getElem_cons
          (l := xs) (i := ri1.val) (by omega)
        have hriSucc : ri1.val + 1 = ri.val := by omega
        rw [hriSucc] at hxdrop
        have hxin : xs[ri1.val] < 10 := hxdigit _ (List.getElem_mem _)
        have hdigitVal : digit.val = xs[ri1.val] := by
          have hacOrig : ac.val[ri1.val]? = a.val[ri1.val]? := by
            apply houtside ri1.val (by omega)
            left
            omega
          have hacGet : ac.val[ri1.val]? = some digit :=
            getElem?_eq_some_iff.mpr ⟨hri1lt, hdigitReadVal.symm⟩
          have haGet : a.val[ri1.val]? = some digit := by
            rw [← hacOrig]
            exact hacGet
          have haBound : ri1.val < a.val.length := by
            have haLen : a.val.length = 768 := by simpa using a.property
            rw [haLen]
            omega
          have haVal : a.val[ri1.val]'haBound = digit := by
            have hsome := List.getElem?_eq_getElem haBound
            rw [haGet] at hsome
            exact Option.some.inj hsome.symm
          have hxsVal : xs[ri1.val]'(by omega) =
              (a.val[ri1.val]'haBound).val := by
            simp [xs]
          rw [hxsVal, haVal]
        have hdigitLt : digit.val < 10 := by omega
        let digit64 : Std.U64 := UScalar.cast .U64 digit
        have hdigit64 : digit64.val = digit.val := by
          simp [digit64, UScalar.cast_val_eq]
        simp only [bind_tc_ok, lift] at hr
        rw [show UScalar.cast .U64 digit = digit64 by rfl] at hr
        have hshiftSpec := UScalar.ShiftLeft_spec digit64 shift (2 ^ 64)
          (by norm_num [U64.numBits]; omega) (by norm_num [U64.size_eq])
        cases hshiftEq : digit64 <<< shift with
        | fail e => simp [hshiftEq] at hr
        | div => simp [hshiftEq] at hr
        | ok shifted =>
          rw [hshiftEq] at hshiftSpec
          have hshiftVal : shifted.val = digit.val * B := by
            have hmulLt : digit.val * B < 2 ^ 64 := by
              calc
                digit.val * B <= 9 * 2 ^ 60 := Nat.mul_le_mul (by omega) hBle
                _ < 2 ^ 64 := by norm_num
            have hs := hshiftSpec.1
            simp only [WP.spec_ok] at hs
            rw [Nat.shiftLeft_eq, hdigit64, Nat.mod_eq_of_lt (by
              simpa [B] using hmulLt)] at hs
            simpa [B] using hs
          simp only [hshiftEq, bind_tc_ok] at hr
          have haddBound : c.val + shifted.val <= U64.max := by
            rw [hshiftVal]
            have hdigitMul : digit.val * B <= 9 * B :=
              Nat.mul_le_mul_right B (by omega)
            have : c.val + digit.val * B < 2 ^ 64 := by
              calc
                c.val + digit.val * B < B + 9 * B := by omega
                _ = 10 * B := by ring
                _ <= 10 * 2 ^ 60 := Nat.mul_le_mul_left 10 hBle
                _ < 2 ^ 64 := by norm_num
            norm_num [U64.max, U64.numBits]
            omega
          obtain ⟨total, htotal, htotalVal⟩ := Aeneas.Std.WP.spec_imp_exists
            (U64.add_spec (x := c) (y := shifted) haddBound)
          rw [htotal] at hr
          simp only [bind_tc_ok] at hr
          obtain ⟨quotient, hquotient, hquotientVal⟩ :=
            Aeneas.Std.WP.spec_imp_exists
              (U64.div_spec total (y := 10#u64) (by norm_num))
          rw [hquotient] at hr
          simp only [bind_tc_ok] at hr
          have hmulBound : 10 * quotient.val <= U64.max := by
            rw [hquotientVal]
            have htotalLt : total.val < 2 ^ 64 := total.bv.isLt
            have hqle : 10 * (total.val / 10) <= total.val :=
              Nat.mul_div_le total.val 10
            norm_num [U64.max, U64.numBits] at htotalLt ⊢
            omega
          obtain ⟨tenq, htenq, htenqVal⟩ := Aeneas.Std.WP.spec_imp_exists
            (U64.mul_spec (x := 10#u64) (y := quotient) (by
              simpa [Nat.mul_comm] using hmulBound))
          rw [htenq] at hr
          simp only [bind_tc_ok] at hr
          have htenqLe : tenq.val <= total.val := by
            rw [htenqVal, hquotientVal]
            exact Nat.mul_div_le total.val 10
          obtain ⟨rem, hrem, hremVal⟩ := Aeneas.Std.WP.spec_imp_exists
            (U64.sub_spec (x := total) (y := tenq) htenqLe)
          rw [hrem] at hr
          simp only [bind_tc_ok] at hr
          have htotalFormula : total.val = c.val + digit.val * B := by
            rw [htotalVal, hshiftVal]
          have hquotientFormula : quotient.val = total.val / 10 := hquotientVal
          have hremFormula : rem.val = total.val % 10 := by
            have htenqFormula : tenq.val = 10 * (total.val / 10) := by
              rw [htenqVal, hquotientVal]
              norm_num
            have heuc := Nat.mod_add_div total.val 10
            rw [hremVal.1, htenqFormula]
            omega
          have hremLt : rem.val < 10 := by
            rw [hremFormula]
            exact Nat.mod_lt _ (by omega)
          have hquotientB : quotient.val < B := by
            rw [hquotientFormula]
            apply (Nat.div_lt_iff_lt_mul (by omega)).2
            rw [htotalFormula]
            have hdigitMul : digit.val * B <= 9 * B :=
              Nat.mul_le_mul_right B (by omega)
            omega
          let newOuts := rem.val :: outs
          have hnewlen : newOuts.length = read.val - ri1.val := by
            simp [newOuts, houtslen]
            omega
          have hnewdigit : forall z, z ∈ newOuts -> z < 10 := by
            intro z hz
            simp only [newOuts, List.mem_cons] at hz
            rcases hz with rfl | hz
            · exact hremLt
            · exact houtsdigit z hz
          have hinputStep : F (xs.drop ri1.val) =
              digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
            have hdropLen : (xs.drop ri.val).length = outs.length := by
              simp [hxslen, houtslen]
            calc
              F (xs.drop ri1.val) = F (xs[ri1.val] :: xs.drop ri.val) := by
                rw [hxdrop]
              _ = (xs.drop ri.val).foldl (fun n z => 10 * n + z)
                    xs[ri1.val] := by simp [F]
              _ = xs[ri1.val] * 10 ^ (xs.drop ri.val).length +
                    F (xs.drop ri.val) := foldlFrom _ _
              _ = digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
                    rw [hdigitVal, hdropLen]
          have houtStep : F newOuts = rem.val * 10 ^ outs.length + F outs := by
            simpa [newOuts, F] using foldlFrom outs rem.val
          have hnumNew : B * F (xs.drop ri1.val) =
              quotient.val * 10 ^ newOuts.length + F newOuts := by
            have heuc : total.val = 10 * quotient.val + rem.val := by
              rw [hquotientFormula, hremFormula]
              have hmoddiv := Nat.mod_add_div total.val 10
              omega
            have hlenSucc : read.val - ri1.val = outs.length + 1 := by
              rw [houtslen]
              omega
            calc
              B * F (xs.drop ri1.val) =
                  (c.val + digit.val * B) * 10 ^ outs.length + F outs := by
                    rw [hinputStep]
                    calc
                      B * (digit.val * 10 ^ outs.length + F (xs.drop ri.val)) =
                          digit.val * B * 10 ^ outs.length +
                            B * F (xs.drop ri.val) := by ring
                      _ = (c.val + digit.val * B) * 10 ^ outs.length +
                            F outs := by rw [hnum]; ring
              _ = total.val * 10 ^ outs.length + F outs := by
                    rw [htotalFormula]
              _ = (10 * quotient.val + rem.val) * 10 ^ outs.length + F outs := by
                    rw [heuc]
              _ = quotient.val * 10 ^ newOuts.length + F newOuts := by
                    rw [houtStep, hnewlen, hlenSucc, pow_succ]
                    ring
          by_cases hcap : wi1.val < 768
          · have hcastRem : (UScalar.cast .U8 rem).val = rem.val := by
              simp [UScalar.cast_val_eq, Nat.mod_eq_of_lt (by omega : rem.val < 256)]
            have hwibound : wi1.val < ac.val.length := by
              have hacLen : ac.val.length = 768 := by simpa using ac.property
              rw [hacLen]
              exact hcap
            obtain ⟨ac1, hac1, hac1Val⟩ := Aeneas.Std.WP.spec_imp_exists
              (Array.update_spec ac wi1 (UScalar.cast .U8 rem)
                (by simpa [Array.length] using hwibound))
            have hcapWord : wi1 <
                num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
              simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
                UScalar.lt_equiv] using hcap
            simp only [hcapWord, if_true] at hr
            rw [hac1] at hr
            simp only [bind_tc_ok] at hr
            cases hr
            simp only [Inv]
            refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
              hnumNew, ?_, ?_, ?_⟩
            · omega
            · omega
            · intro j hj hpos
              rw [hac1Val]
              simp only [Aeneas.Std.Array.set, List.map_set, List.getElem?_set]
              cases j with
              | zero => simpa [newOuts, hcastRem] using hcap
              | succ j =>
                  have hjold : j < outs.length := by
                    simp [newOuts] at hj
                    omega
                  have hidx : wi1.val + (j + 1) = wi.val + j := by omega
                  have hne : wi1.val ≠ wi.val + j := by omega
                  simp [newOuts, hidx, hne]
                  simpa using harr j hjold (by omega)
            · intro j hj houtsideNew
              rw [hac1Val]
              simp only [Aeneas.Std.Array.set, List.getElem?_set]
              have hne : wi1.val ≠ j := by omega
              simp [hne]
              apply houtside j hj
              omega
            · constructor
              · intro htrue
                have hold := hsticky.mp htrue
                rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
                · exact Or.inl hb
                · right
                  refine ⟨j + 1, ?_, ?_, ?_⟩
                  · simp [newOuts]
                    omega
                  · omega
                  · simpa [newOuts]
              · intro h
                apply hsticky.mpr
                rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
                · exact Or.inl hb
                · right
                  cases j with
                  | zero => omega
                  | succ j =>
                      refine ⟨j, ?_, ?_, ?_⟩
                      · simp [newOuts] at hj
                        omega
                      · omega
                      · simpa [newOuts] using hjnz
          · have hcapWord : ¬ wi1 <
                num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
              simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
                UScalar.lt_equiv] using hcap
            simp only [hcapWord, if_false] at hr
            by_cases hrem0 : rem.val = 0
            · have hremEq : rem = 0#u64 := UScalar.eq_of_val_eq (by simpa using hrem0)
              have hnotgt : ¬ rem > 0#u64 := by simp [hremEq]
              simp [hnotgt] at hr
              subst r
              simp only [Inv]
              refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
                hnumNew, ?_, ?_, ?_⟩
              · omega
              · omega
              · intro j hj hpos
                cases j with
                | zero => omega
                | succ j =>
                    have hjold : j < outs.length := by
                      simp [newOuts] at hj
                      omega
                    have hidx : wi1.val + (j + 1) = wi.val + j := by omega
                    simpa [newOuts, hidx] using harr j hjold (by omega)
              · intro j hj houtsideNew
                apply houtside j hj
                omega
              · constructor
                · intro htrue
                  have hold := hsticky.mp htrue
                  rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
                  · exact Or.inl hb
                  · right
                    refine ⟨j + 1, ?_, ?_, ?_⟩
                    · simp [newOuts]
                      omega
                    · omega
                    · simpa [newOuts]
                · intro h
                  apply hsticky.mpr
                  rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
                  · exact Or.inl hb
                  · right
                    cases j with
                    | zero => simp [newOuts, hrem0] at hjnz
                    | succ j =>
                        refine ⟨j, ?_, ?_, ?_⟩
                        · simp [newOuts] at hj
                          omega
                        · omega
                        · simpa [newOuts] using hjnz
            · have hgt : rem > 0#u64 := by
                change 0 < rem.val
                omega
              simp [hgt] at hr
              subst r
              simp only [Inv]
              refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
                hnumNew, ?_, ?_, ?_⟩
              · omega
              · omega
              · intro j hj hpos
                cases j with
                | zero => omega
                | succ j =>
                    have hjold : j < outs.length := by
                      simp [newOuts] at hj
                      omega
                    have hidx : wi1.val + (j + 1) = wi.val + j := by omega
                    simpa [newOuts, hidx] using harr j hjold (by omega)
              · intro j hj houtsideNew
                apply houtside j hj
                omega
              · constructor
                · intro _
                  right
                  refine ⟨0, by simp [newOuts], by omega, ?_⟩
                  simp [newOuts, hrem0]
                · exact fun _ => True.intro
    · simp only [Inv]
      refine ⟨le_rfl, by simp, ?_, [], by simp, ?_, ?_, ?_, ?_, ?_⟩
      · simpa [B] using hBpos
      · intro z hz
        simp at hz
      · have hxdropAll : xs.drop read.val = [] :=
          List.drop_eq_nil_of_le (by rw [hxslen])
        simp [F, hxdropAll]
      · intro j hj
        simp at hj
      · intro j hj houtside
        trivial
      · simp
    · simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0, Body]
        using hloop
  simpa [Post, B, F, xs] using hp

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.ResultLoopPartial
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: DecimalLeftShiftFirstLoopSemantics]
theorem DecimalLeftShiftFirstLoopSemantics
    (a a' : Array Std.U8 768#usize) (b b' : Bool)
    (shift read write q : Std.Usize) (carry : Std.U64)
    (hshift : shift.val <= 60)
    (hread : read.val <= 768)
    (hwrite : read.val <= write.val)
    (hdigit : forall z, z ∈ a.val.take read.val -> z.val < 10)
    (hloop :
      num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0
        b a shift read write 0#u64 = ok (b', a', q, carry)) :
    let xs := (a.val.take read.val).map (fun z => z.val)
    let I := xs.foldl (fun acc z => 10 * acc + z) 0
    exists outDigits : List Nat,
      outDigits.length = read.val /\
      (forall z, z ∈ outDigits -> z < 10) /\
      q.val + read.val = write.val /\
      carry.val < 2 ^ shift.val /\
      2 ^ shift.val * I =
        carry.val * 10 ^ read.val +
          outDigits.foldl (fun acc z => 10 * acc + z) 0 /\
      (forall j, j < outDigits.length -> q.val + j < 768 ->
        (a'.val.map (fun z => z.val))[q.val + j]? = outDigits[j]?) /\
      (forall j, j < 768 -> (j < q.val \/ write.val <= j) ->
        a'.val[j]? = a.val[j]?) /\
      (b' = true <-> b = true \/
        exists j, j < outDigits.length /\ 768 <= q.val + j /\
          outDigits[j]? ≠ some 0) := by
-- BODY
  dsimp only
  let xs := (a.val.take read.val).map (fun z => z.val)
  let F := fun ys : List Nat =>
    ys.foldl (fun acc z => 10 * acc + z) 0
  let B := 2 ^ shift.val
  have hBpos : 0 < B := by simp [B]
  have hBle : B <= 2 ^ 60 := by
    exact Nat.pow_le_pow_right (by omega) hshift
  have hxslen : xs.length = read.val := by
    simp [xs, hread, a.property]
  have hxdigit : forall z, z ∈ xs -> z < 10 := by
    intro z hz
    simp only [xs, List.mem_map] at hz
    rcases hz with ⟨u, hu, rfl⟩
    exact hdigit u hu
  have foldlFrom (ys : List Nat) (acc : Nat) :
      ys.foldl (fun n z => 10 * n + z) acc =
        acc * 10 ^ ys.length + F ys := by
    induction ys generalizing acc with
    | nil => simp [F]
    | cons y ys ih =>
      simp only [List.foldl_cons, List.length_cons]
      rw [ih, pow_succ]
      change (10 * acc + y) * 10 ^ ys.length + F ys =
        acc * (10 ^ ys.length * 10) +
          (y :: ys).foldl (fun n z => 10 * n + z) 0
      simp only [List.foldl_cons]
      rw [ih]
      ring
  let Inv := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
      Std.Usize × Std.U64) =>
    let (bc, ac, ri, wi, c) := x
    ri.val <= read.val /\
    wi.val + (read.val - ri.val) = write.val /\
    c.val < B /\
    exists outs : List Nat,
      outs.length = read.val - ri.val /\
      (forall z, z ∈ outs -> z < 10) /\
      B * F (xs.drop ri.val) = c.val * 10 ^ outs.length + F outs /\
      (forall j, j < outs.length -> wi.val + j < 768 ->
        (ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
      (forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
        ac.val[j]? = a.val[j]?) /\
      (bc = true <-> b = true \/
        exists j, j < outs.length /\ 768 <= wi.val + j /\
          outs[j]? ≠ some 0)
  let Post := fun (x : Bool × Array Std.U8 768#usize × Std.Usize × Std.U64) =>
    let (bc, ac, wi, c) := x
    exists outs : List Nat,
      outs.length = read.val /\
      (forall z, z ∈ outs -> z < 10) /\
      wi.val + read.val = write.val /\
      c.val < B /\
      B * F xs = c.val * 10 ^ read.val + F outs /\
      (forall j, j < outs.length -> wi.val + j < 768 ->
        (ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
      (forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
        ac.val[j]? = a.val[j]?) /\
      (bc = true <-> b = true \/
        exists j, j < outs.length /\ 768 <= wi.val + j /\
          outs[j]? ≠ some 0)
  let Body := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
      Std.Usize × Std.U64) =>
    let (bc, ac, ri, wi, c) := x
    num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body
      shift bc ac ri wi c
  have hp : Post (b', a', q, carry) := by
    refine ResultLoopPartial Inv Post Body ?_ (b, a, read, write, 0#u64)
      (b', a', q, carry) ?_ ?_
    · intro x hx r hr
      rcases x with ⟨bc, ac, ri, wi, c⟩
      simp only [Inv] at hx
      rcases hx with ⟨hri, hwi, hcB, outs, houtslen, houtsdigit,
        hnum, harr, houtside, hsticky⟩
      simp only [Body,
        num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body] at hr
      by_cases hri0 : ri.val = 0
      · have hriEq : ri = 0#usize := UScalar.eq_of_val_eq (by simpa using hri0)
        subst ri
        simp at hr
        subst r
        simp only [Post]
        refine ⟨outs, ?_, houtsdigit, ?_, hcB, ?_, harr, houtside, hsticky⟩
        · omega
        · omega
        · simpa [xs, F, houtslen] using hnum
      · have hripos : 0 < ri.val := by omega
        have hrine : ri != 0#usize := by
          simp only [bne_iff_ne]
          intro h
          apply hri0
          simpa [h]
        obtain ⟨ri1, hri1, hri1val⟩ := Aeneas.Std.WP.spec_imp_exists
          (UScalar.sub_spec (x := ri) (y := 1#usize) (by simpa using hripos))
        norm_num at hri1val
        have hriwi : ri.val <= wi.val := by omega
        have hwipos : 0 < wi.val := by omega
        obtain ⟨wi1, hwi1, hwi1val⟩ := Aeneas.Std.WP.spec_imp_exists
          (UScalar.sub_spec (x := wi) (y := 1#usize) (by simpa using hwipos))
        norm_num at hwi1val
        have hri1lt : ri1.val < ac.val.length := by
          rw [ac.property]
          norm_num
          omega
        obtain ⟨digit, hdigitRead, hdigitReadVal⟩ :=
          Aeneas.Std.WP.spec_imp_exists
            (Array.index_usize_spec ac ri1
              (by simpa [Array.length] using hri1lt))
        rw [hri1, hwi1] at hr
        simp only [hrine, if_true, bind_tc_ok] at hr
        rw [hdigitRead] at hr
        have hri1ltRead : ri1.val < read.val := by omega
        have hxdrop := List.drop_eq_getElem_cons
          (l := xs) (i := ri1.val) (by omega)
        have hriSucc : ri1.val + 1 = ri.val := by omega
        rw [hriSucc] at hxdrop
        have hxin : xs[ri1.val] < 10 := hxdigit _ (List.getElem_mem _)
        have hdigitVal : digit.val = xs[ri1.val] := by
          have hacOrig : ac.val[ri1.val]? = a.val[ri1.val]? := by
            apply houtside ri1.val (by omega)
            left
            omega
          have hacGet : ac.val[ri1.val]? = some digit :=
            getElem?_eq_some_iff.mpr ⟨hri1lt, hdigitReadVal.symm⟩
          have haGet : a.val[ri1.val]? = some digit := by
            rw [← hacOrig]
            exact hacGet
          have haBound : ri1.val < a.val.length := by
            have haLen : a.val.length = 768 := by simpa using a.property
            rw [haLen]
            omega
          have haVal : a.val[ri1.val]'haBound = digit := by
            have hsome := List.getElem?_eq_getElem haBound
            rw [haGet] at hsome
            exact Option.some.inj hsome.symm
          have hxsVal : xs[ri1.val]'(by omega) =
              (a.val[ri1.val]'haBound).val := by
            simp [xs]
          rw [hxsVal, haVal]
        have hdigitLt : digit.val < 10 := by omega
        let digit64 : Std.U64 := UScalar.cast .U64 digit
        have hdigit64 : digit64.val = digit.val := by
          simp [digit64, UScalar.cast_val_eq]
        simp only [bind_tc_ok, lift] at hr
        rw [show UScalar.cast .U64 digit = digit64 by rfl] at hr
        have hshiftSpec := UScalar.ShiftLeft_spec digit64 shift (2 ^ 64)
          (by norm_num [U64.numBits]; omega) (by norm_num [U64.size_eq])
        cases hshiftEq : digit64 <<< shift with
        | fail e => simp [hshiftEq] at hr
        | div => simp [hshiftEq] at hr
        | ok shifted =>
          rw [hshiftEq] at hshiftSpec
          have hshiftVal : shifted.val = digit.val * B := by
            have hmulLt : digit.val * B < 2 ^ 64 := by
              calc
                digit.val * B <= 9 * 2 ^ 60 := Nat.mul_le_mul (by omega) hBle
                _ < 2 ^ 64 := by norm_num
            have hs := hshiftSpec.1
            simp only [WP.spec_ok] at hs
            rw [Nat.shiftLeft_eq, hdigit64, Nat.mod_eq_of_lt (by
              simpa [B] using hmulLt)] at hs
            simpa [B] using hs
          simp only [hshiftEq, bind_tc_ok] at hr
          have haddBound : c.val + shifted.val <= U64.max := by
            rw [hshiftVal]
            have hdigitMul : digit.val * B <= 9 * B :=
              Nat.mul_le_mul_right B (by omega)
            have : c.val + digit.val * B < 2 ^ 64 := by
              calc
                c.val + digit.val * B < B + 9 * B := by omega
                _ = 10 * B := by ring
                _ <= 10 * 2 ^ 60 := Nat.mul_le_mul_left 10 hBle
                _ < 2 ^ 64 := by norm_num
            norm_num [U64.max, U64.numBits]
            omega
          obtain ⟨total, htotal, htotalVal⟩ := Aeneas.Std.WP.spec_imp_exists
            (U64.add_spec (x := c) (y := shifted) haddBound)
          rw [htotal] at hr
          simp only [bind_tc_ok] at hr
          obtain ⟨quotient, hquotient, hquotientVal⟩ :=
            Aeneas.Std.WP.spec_imp_exists
              (U64.div_spec total (y := 10#u64) (by norm_num))
          rw [hquotient] at hr
          simp only [bind_tc_ok] at hr
          have hmulBound : 10 * quotient.val <= U64.max := by
            rw [hquotientVal]
            have htotalLt : total.val < 2 ^ 64 := total.bv.isLt
            have hqle : 10 * (total.val / 10) <= total.val :=
              Nat.mul_div_le total.val 10
            norm_num [U64.max, U64.numBits] at htotalLt ⊢
            omega
          obtain ⟨tenq, htenq, htenqVal⟩ := Aeneas.Std.WP.spec_imp_exists
            (U64.mul_spec (x := 10#u64) (y := quotient) (by
              simpa [Nat.mul_comm] using hmulBound))
          rw [htenq] at hr
          simp only [bind_tc_ok] at hr
          have htenqLe : tenq.val <= total.val := by
            rw [htenqVal, hquotientVal]
            exact Nat.mul_div_le total.val 10
          obtain ⟨rem, hrem, hremVal⟩ := Aeneas.Std.WP.spec_imp_exists
            (U64.sub_spec (x := total) (y := tenq) htenqLe)
          rw [hrem] at hr
          simp only [bind_tc_ok] at hr
          have htotalFormula : total.val = c.val + digit.val * B := by
            rw [htotalVal, hshiftVal]
          have hquotientFormula : quotient.val = total.val / 10 := hquotientVal
          have hremFormula : rem.val = total.val % 10 := by
            have htenqFormula : tenq.val = 10 * (total.val / 10) := by
              rw [htenqVal, hquotientVal]
              norm_num
            have heuc := Nat.mod_add_div total.val 10
            rw [hremVal.1, htenqFormula]
            omega
          have hremLt : rem.val < 10 := by
            rw [hremFormula]
            exact Nat.mod_lt _ (by omega)
          have hquotientB : quotient.val < B := by
            rw [hquotientFormula]
            apply (Nat.div_lt_iff_lt_mul (by omega)).2
            rw [htotalFormula]
            have hdigitMul : digit.val * B <= 9 * B :=
              Nat.mul_le_mul_right B (by omega)
            omega
          let newOuts := rem.val :: outs
          have hnewlen : newOuts.length = read.val - ri1.val := by
            simp [newOuts, houtslen]
            omega
          have hnewdigit : forall z, z ∈ newOuts -> z < 10 := by
            intro z hz
            simp only [newOuts, List.mem_cons] at hz
            rcases hz with rfl | hz
            · exact hremLt
            · exact houtsdigit z hz
          have hinputStep : F (xs.drop ri1.val) =
              digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
            have hdropLen : (xs.drop ri.val).length = outs.length := by
              simp [hxslen, houtslen]
            calc
              F (xs.drop ri1.val) = F (xs[ri1.val] :: xs.drop ri.val) := by
                rw [hxdrop]
              _ = (xs.drop ri.val).foldl (fun n z => 10 * n + z)
                    xs[ri1.val] := by simp [F]
              _ = xs[ri1.val] * 10 ^ (xs.drop ri.val).length +
                    F (xs.drop ri.val) := foldlFrom _ _
              _ = digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
                    rw [hdigitVal, hdropLen]
          have houtStep : F newOuts = rem.val * 10 ^ outs.length + F outs := by
            simpa [newOuts, F] using foldlFrom outs rem.val
          have hnumNew : B * F (xs.drop ri1.val) =
              quotient.val * 10 ^ newOuts.length + F newOuts := by
            have heuc : total.val = 10 * quotient.val + rem.val := by
              rw [hquotientFormula, hremFormula]
              have hmoddiv := Nat.mod_add_div total.val 10
              omega
            have hlenSucc : read.val - ri1.val = outs.length + 1 := by
              rw [houtslen]
              omega
            calc
              B * F (xs.drop ri1.val) =
                  (c.val + digit.val * B) * 10 ^ outs.length + F outs := by
                    rw [hinputStep]
                    calc
                      B * (digit.val * 10 ^ outs.length + F (xs.drop ri.val)) =
                          digit.val * B * 10 ^ outs.length +
                            B * F (xs.drop ri.val) := by ring
                      _ = (c.val + digit.val * B) * 10 ^ outs.length +
                            F outs := by rw [hnum]; ring
              _ = total.val * 10 ^ outs.length + F outs := by
                    rw [htotalFormula]
              _ = (10 * quotient.val + rem.val) * 10 ^ outs.length + F outs := by
                    rw [heuc]
              _ = quotient.val * 10 ^ newOuts.length + F newOuts := by
                    rw [houtStep, hnewlen, hlenSucc, pow_succ]
                    ring
          by_cases hcap : wi1.val < 768
          · have hcastRem : (UScalar.cast .U8 rem).val = rem.val := by
              simp [UScalar.cast_val_eq, Nat.mod_eq_of_lt (by omega : rem.val < 256)]
            have hwibound : wi1.val < ac.val.length := by
              have hacLen : ac.val.length = 768 := by simpa using ac.property
              rw [hacLen]
              exact hcap
            obtain ⟨ac1, hac1, hac1Val⟩ := Aeneas.Std.WP.spec_imp_exists
              (Array.update_spec ac wi1 (UScalar.cast .U8 rem)
                (by simpa [Array.length] using hwibound))
            have hcapWord : wi1 <
                num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
              simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
                UScalar.lt_equiv] using hcap
            simp only [hcapWord, if_true] at hr
            rw [hac1] at hr
            simp only [bind_tc_ok] at hr
            cases hr
            simp only [Inv]
            refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
              hnumNew, ?_, ?_, ?_⟩
            · omega
            · omega
            · intro j hj hpos
              rw [hac1Val]
              simp only [Aeneas.Std.Array.set, List.map_set, List.getElem?_set]
              cases j with
              | zero => simpa [newOuts, hcastRem] using hcap
              | succ j =>
                  have hjold : j < outs.length := by
                    simp [newOuts] at hj
                    omega
                  have hidx : wi1.val + (j + 1) = wi.val + j := by omega
                  have hne : wi1.val ≠ wi.val + j := by omega
                  simp [newOuts, hidx, hne]
                  simpa using harr j hjold (by omega)
            · intro j hj houtsideNew
              rw [hac1Val]
              simp only [Aeneas.Std.Array.set, List.getElem?_set]
              have hne : wi1.val ≠ j := by omega
              simp [hne]
              apply houtside j hj
              omega
            · constructor
              · intro htrue
                have hold := hsticky.mp htrue
                rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
                · exact Or.inl hb
                · right
                  refine ⟨j + 1, ?_, ?_, ?_⟩
                  · simp [newOuts]
                    omega
                  · omega
                  · simpa [newOuts]
              · intro h
                apply hsticky.mpr
                rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
                · exact Or.inl hb
                · right
                  cases j with
                  | zero => omega
                  | succ j =>
                      refine ⟨j, ?_, ?_, ?_⟩
                      · simp [newOuts] at hj
                        omega
                      · omega
                      · simpa [newOuts] using hjnz
          · have hcapWord : ¬ wi1 <
                num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
              simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
                UScalar.lt_equiv] using hcap
            simp only [hcapWord, if_false] at hr
            by_cases hrem0 : rem.val = 0
            · have hremEq : rem = 0#u64 := UScalar.eq_of_val_eq (by simpa using hrem0)
              have hnotgt : ¬ rem > 0#u64 := by simp [hremEq]
              simp [hnotgt] at hr
              subst r
              simp only [Inv]
              refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
                hnumNew, ?_, ?_, ?_⟩
              · omega
              · omega
              · intro j hj hpos
                cases j with
                | zero => omega
                | succ j =>
                    have hjold : j < outs.length := by
                      simp [newOuts] at hj
                      omega
                    have hidx : wi1.val + (j + 1) = wi.val + j := by omega
                    simpa [newOuts, hidx] using harr j hjold (by omega)
              · intro j hj houtsideNew
                apply houtside j hj
                omega
              · constructor
                · intro htrue
                  have hold := hsticky.mp htrue
                  rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
                  · exact Or.inl hb
                  · right
                    refine ⟨j + 1, ?_, ?_, ?_⟩
                    · simp [newOuts]
                      omega
                    · omega
                    · simpa [newOuts]
                · intro h
                  apply hsticky.mpr
                  rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
                  · exact Or.inl hb
                  · right
                    cases j with
                    | zero => simp [newOuts, hrem0] at hjnz
                    | succ j =>
                        refine ⟨j, ?_, ?_, ?_⟩
                        · simp [newOuts] at hj
                          omega
                        · omega
                        · simpa [newOuts] using hjnz
            · have hgt : rem > 0#u64 := by
                change 0 < rem.val
                omega
              simp [hgt] at hr
              subst r
              simp only [Inv]
              refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
                hnumNew, ?_, ?_, ?_⟩
              · omega
              · omega
              · intro j hj hpos
                cases j with
                | zero => omega
                | succ j =>
                    have hjold : j < outs.length := by
                      simp [newOuts] at hj
                      omega
                    have hidx : wi1.val + (j + 1) = wi.val + j := by omega
                    simpa [newOuts, hidx] using harr j hjold (by omega)
              · intro j hj houtsideNew
                apply houtside j hj
                omega
              · constructor
                · intro _
                  right
                  refine ⟨0, by simp [newOuts], by omega, ?_⟩
                  simp [newOuts, hrem0]
                · exact fun _ => True.intro
    · simp only [Inv]
      refine ⟨le_rfl, by simp, ?_, [], by simp, ?_, ?_, ?_, ?_, ?_⟩
      · simpa [B] using hBpos
      · intro z hz
        simp at hz
      · have hxdropAll : xs.drop read.val = [] :=
          List.drop_eq_nil_of_le (by rw [hxslen])
        simp [F, hxdropAll]
      · intro j hj
        simp at hj
      · intro j hj houtside
        trivial
      · simp
    · simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0, Body]
        using hloop
  simpa [Post, B, F, xs] using hp

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (117)
More program dependencies (84)
Standard-library dependencies (30)

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 9 entries
Technical checking records
Local closure summary
{
  "node": "DecimalLeftShiftFirstLoopSemantics",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "d4fdaa787b1e8e70d79c7e349b33444996a24393fa53d306e48b90a0eb02bb9e",
  "active_statement_hash": "c13786246c0cff231a817b9b47bc015cb5d3c26d0640f03a9de1154756773aab",
  "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-181",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "ResultLoopPartial": "566d2aeb76ed9100",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "0eb6fb2627d0ff5c",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "0f3e5cc6a65d812e"
  },
  "strict_definition_deps": {
    "ResultLoopPartial": "1b58e96ad00b23c2",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "39f6cb231ef80388",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "57f9712103d3acf6"
  }
}
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:421dcbeac86cb84bb6c17f0b3afe7b5436d9a25ce45379ab916ce6ad8796a80b",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}