P495_T1_RightShiftCanonical

Lean checked

Statement

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

Lemma · Canonical nonreset right-shift result

Let d have at most 768 retained cells, all decimal, with a positive leading digit and retained-list length equal to its count. Let k\le60 be a Usize shift. Suppose the actual right shift returns normally with d', whose count is nonzero. Define the retained value V(a) by the digit fold times 10^{a.\mathit{point}-a.\mathit{count}}. If X=V(d)+\eta, Y=V(d)+u, 0\le\eta<u, and the input sticky flag is true iff \eta>0, then d' has point at least -2047, count at most 768, decimal retained cells, positive leading digit, exact retained-list length, and a nonzero last retained cell. There are \eta',u' with X/2^k=V(d')+\eta', Y/2^k=V(d')+u', 0\le\eta'<u', and output sticky true iff \eta'>0. The input prefix need not be terminally trimmed.

Lean statement

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

import Tablet.P472_T1_DecimalSeqDyadicShiftSemantics
import Tablet.P472_T1_DecimalRightShiftPrefixLoopSemantics
import Tablet.P472_T1_DecimalRightShiftMainLoopSemantics
import Tablet.P472_T1_DecimalRightShiftFinalLoopSemantics
import Tablet.DecimalSeqTrimSemantics

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P495_T1_RightShiftCanonical]
theorem P495_T1_RightShiftCanonical (X Y : Real)
    (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize)
    (hshift : shift.val <= 60) (hcap : d.num_digits.val <= 768)
    (hdigits : forall b, b ∈ d.digits.val.take d.num_digits.val -> b.val < 10)
    (hhead : exists h tail,
      (d.digits.val.take d.num_digits.val).map (fun b => b.val) = h :: tail /\
      1 <= h /\ h < 10 /\ (h :: tail).length = d.num_digits.val)
    (hcall : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d')
    (hnonzero : d'.num_digits.val ≠ 0) :
    let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
      ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
        (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
    (exists eta u : Real, X = V d + eta /\ Y = V d + u /\
      0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta)) ->
    -2047 <= d'.decimal_point.val /\ d'.num_digits.val <= 768 /\
    (forall b, b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10) /\
    (exists h tail,
      (d'.digits.val.take d'.num_digits.val).map (fun b => b.val) = h :: tail /\
      1 <= h /\ h < 10 /\ (h :: tail).length = d'.num_digits.val) /\
    d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 /\
    (exists eta' u' : Real,
      X / (2 : Real) ^ shift.val = V d' + eta' /\
      Y / (2 : Real) ^ shift.val = V d' + u' /\
      0 <= eta' /\ eta' < u' /\ (d'.truncated = true <-> 0 < eta')) := 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

The positive input head makes its natural digit fold positive: starting with a positive digit, each update a\mapsto10a+z for z\ge0 remains positive. Multiplication by a positive power of ten gives V(d)>0. Apply the right-shift implication of DecimalSeqDyadicShiftSemantics to the given endpoint witnesses. Its reset alternative has output count zero and contradicts the hypothesis. Its other alternative supplies \eta',u', the first value equation, inequalities, sticky equivalence, and V(d')+u'=(V(d)+u)/2^k. Substituting Y=V(d)+u gives the other endpoint. This transports the fixed upper endpoint, not a new power-of-ten cutoff.
For shape, invert the successful binds in num imp dec2flt decimal seq DecimalSeq right shift. DecimalRightShiftPrefixLoopSemantics applies to the obtained actual prefix result: its positive-fold and digit hypotheses are the input facts just established. It leaves the record unchanged, returns all-zero false, and gives 1\le r\le n+k\le828 with B=2^k\le c<10B. The cast of r to I32 is therefore exact. The normal checked point update has value p-r+1. The reset threshold is -2047 by num imp dec2flt decimal seq DecimalSeq DECIMAL POINT RANGE. The reset arm would return count zero; hence it was not taken, and p-r+1\ge-2047.
The normal power/mask binds have exact values B and B-1, because k\le60<64. If r<n, apply DecimalRightShiftMainLoopSemantics to its actual main loop, using r\le n\le768, the retained digit bounds, and c<10B. Its written list is decimal, has length n-r, and occupies exactly the output cells below that length. Its remaining accumulator is below 10B. If r\ge n, the main guard is false initially, so the main loop returns the original array, write index zero, and c; its written list is empty. In both cases apply DecimalRightShiftFinalLoopSemantics to the actual final loop. It appends decimal cells, caps the written count at 768, and preserves the earlier written cells. Thus the pre-trim count is at most 768 and every cell below that count is decimal: split the index into the main written interval and the subsequent final-written interval.
Its FIRST output digit is positive. If r<n, the main loop's first iteration starts with B\le c<10B and write index zero, so it writes \lfloor c/B\rfloor\in[1,9] at zero. If r\ge n, its first output iteration instead belongs to the final loop, whose accumulator is c>0 and whose write index is zero; it writes the very same quotient in [1,9]. This assertion follows directly by expanding the two bodies in the right-shift model: arithmetic right shifts of U64 are division by B, the U8 cast is exact for a quotient below ten, and update zero is in bounds. In later main iterations the read index strictly exceeds the write index (r\ge1 initially and both advance once per iteration), so the unread digit is still the original digit. The next accumulator is 10(c\bmod B)+z<10B, justifying the quotient range at every write. The final loop has the same inequality with z=0. The main body advances its write index by one after each write. The final body does so only below 768; at capacity it keeps index 768 and suppresses every further write. Induction over these transitions shows that no later write returns to index zero. The preservation clauses of the two loop principals agree with this calculation. These operations preserve the positive first digit until trim, whether or not the storage cap is reached.
The final normal bind is trim on this pre-trim record. Apply DecimalSeqTrimSemantics, since its count is at most the array length 768. It leaves the array, point and flag unchanged, decreases count, and returns either count zero or a nonzero last retained cell. The given nonzero result excludes its zero alternative. Its retained prefix is a nonempty prefix of the decimal pre-trim list, so its first cell remains positive, all its members remain decimal, and its length is exactly its count. This proves all shape and point assertions. Together with the endpoint argument these prove the principal statement, without assuming terminal trimming before the shift.

Lean proof


  dsimp only
  intro hWitness
  rcases hWitness with ⟨eta, u, hX, hY, heta0, hetau, hsticky⟩
  have hVpos : 0 <
      ((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
        (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) := by
    rcases hhead with ⟨h, tail, hshape, hpositive, _, _⟩
    have hfoldNat : 0 <
        ((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
          (fun n z => 10 * n + z) (0 : Nat) := by
      rw [hshape]
      change 0 < (h :: tail).foldl (fun n z => 10 * n + z) 0
      have fold_ge : forall (zs : List Nat) (n : Nat),
          n <= zs.foldl (fun a z => 10 * a + z) n := by
        intro zs
        induction zs with
        | nil => intro n; simp
        | cons z zs ih =>
          intro n
          simp only [List.foldl_cons]
          have := ih (10 * n + z)
          omega
      have hmore : h <= tail.foldl (fun n z => 10 * n + z) h :=
        fold_ge tail h
      have hs : 0 < tail.foldl (fun n z => 10 * n + z) h :=
        lt_of_lt_of_le hpositive hmore
      simpa [List.foldl_cons] using hs
    have hfold : 0 <
        (((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
          (fun n z => 10 * n + z) 0 : Nat) := hfoldNat
    exact mul_pos (by exact_mod_cast hfold)
      (zpow_pos (by norm_num) _)
  have hprefixFacts : exists read acc,
      num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
        d shift 0#usize 0#u64 false = ok (d, read, acc, false) /\
      1 <= read.val /\ read.val <= d.num_digits.val + shift.val /\
      2 ^ shift.val <= acc.val /\ acc.val < 10 * 2 ^ shift.val := by
    have hcallAux := hcall
    unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallAux
    cases hloop0 : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
        d shift 0#usize 0#u64 false with
    | fail e => simp [hloop0] at hcallAux
    | div => simp [hloop0] at hcallAux
    | ok out0 =>
      rcases out0 with ⟨d0, read, acc, allZero⟩
      simp only [hloop0, bind_tc_ok] at hcallAux
      have hpref := P472_T1_DecimalRightShiftPrefixLoopSemantics
        d d0 shift read acc allZero hshift (by
          have hp10 : 0 < (10 : Real) ^
              (d.decimal_point.val - (d.num_digits.val : Int)) :=
            zpow_pos (by norm_num) _
          have hfoldReal : 0 <
              (((d.digits.val.take d.num_digits.val).map
                (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) := by
            by_contra hn
            have hnle :
                ((((d.digits.val.take d.num_digits.val).map
                  (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) <= 0 := by
              exact_mod_cast (le_of_not_gt hn)
            have hprod := mul_nonpos_of_nonpos_of_nonneg hnle (le_of_lt hp10)
            have hprod' :
                ((((d.digits.val.take d.num_digits.val).map
                  (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) *
                  (10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) <= 0 := by
              simpa [List.map_take] using hprod
            exact (not_le_of_gt hVpos) hprod'
          exact hfoldReal)
        hdigits (by simpa using hloop0)
      dsimp only at hpref
      rcases hpref with ⟨rfl, rfl, hreadpos, hBacc, hacc10, hphase⟩
      refine ⟨read, acc, (by simpa using hloop0), hreadpos, ?_, hBacc, hacc10⟩
      rcases hphase with hphase | hphase <;> omega
  rcases hprefixFacts with ⟨read, acc, hloop0, hreadpos, hreadBound,
    hBacc, hacc10⟩
  have hnormalRun : exists point negRange : Std.I32,
      point.val = d.decimal_point.val - (read.val : Int) + 1 /\
      ¬ point < negRange /\
      -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
        ok negRange /\
      (do
        let pow ← 1#u64 <<< shift
        let mask ← pow - 1#u64
        let (a, wi, n1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
            d.num_digits d.digits shift read 0#usize acc mask
        let (bc, a1, wi1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
            d.truncated a shift wi n1 mask
        num.imp.dec2flt.decimal_seq.DecimalSeq.trim
          { num_digits := wi1, decimal_point := point,
            truncated := bc, digits := a1 }) = ok d' := by
    let readI : Std.I32 := UScalar.hcast .I32 read
    let reset : num.imp.dec2flt.decimal_seq.DecimalSeq :=
      { num_digits := 0#usize, decimal_point := 0#i32,
        truncated := false, digits := d.digits }
    have hread828 : read.val <= 828 := by omega
    have hreadIVal : readI.val = (read.val : Int) := by
      have hs := UScalar.hcast_inBounds_spec .I32 read (by
        rw [IScalar.max_I32_eq]
        omega)
      simp only [lift, WP.spec_ok] at hs
      exact hs
    have hcallBody := hcall
    unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallBody
    rw [hloop0] at hcallBody
    simp only [bind_tc_ok] at hcallBody
    change (do
      let i ← lift (UScalar.hcast .I32 read)
      let i1 ← i - 1#i32
      let i2 ← d.decimal_point - i1
      let i3 ← -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
      if i2 < i3 then ok reset
      else
        let i4 ← 1#u64 <<< shift
        let mask ← i4 - 1#u64
        let (a, wi, n1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
            d.num_digits d.digits shift read 0#usize acc mask
        let (bc, a1, wi1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
            d.truncated a shift wi n1 mask
        num.imp.dec2flt.decimal_seq.DecimalSeq.trim
          { num_digits := wi1, decimal_point := i2,
            truncated := bc, digits := a1 }) = ok d' at hcallBody
    rw [show UScalar.hcast .I32 read = readI by rfl] at hcallBody
    simp only [lift, bind_tc_ok] at hcallBody
    cases hsub : readI - 1#i32 with
    | fail e => simp [hsub] at hcallBody
    | div => simp [hsub] at hcallBody
    | ok readMinus =>
      rw [hsub] at hcallBody
      simp only [bind_tc_ok] at hcallBody
      cases hpoint : d.decimal_point - readMinus with
      | fail e => simp [hpoint] at hcallBody
      | div => simp [hpoint] at hcallBody
      | ok point =>
        rw [hpoint] at hcallBody
        simp only [bind_tc_ok] at hcallBody
        have hsubVal : readMinus.val = readI.val - 1 := by
          have hs := IScalar.sub_equiv readI 1#i32
          rw [hsub] at hs
          exact hs.2.1
        have hpointVal : point.val =
            d.decimal_point.val - (read.val : Int) + 1 := by
          have hs := IScalar.sub_equiv d.decimal_point readMinus
          rw [hpoint, hsubVal, hreadIVal] at hs
          omega
        cases hnegRange : -.
            num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE with
        | fail e => simp [hnegRange] at hcallBody
        | div => simp [hnegRange] at hcallBody
        | ok negRange =>
          rw [hnegRange] at hcallBody
          simp only [bind_tc_ok] at hcallBody
          by_cases hreset : point < negRange
          · simp only [hreset, if_true] at hcallBody
            have hd' : d' = reset := by simpa using hcallBody.symm
            rw [hd'] at hnonzero
            simp [reset] at hnonzero
          · simp only [hreset, if_false] at hcallBody
            exact ⟨point, negRange, hpointVal, hreset, rfl, hcallBody⟩
  rcases hnormalRun with ⟨point, negRange, hpointVal, hnotReset,
    hnegRange, hrun⟩
  have hoperations : exists pow mask : Std.U64,
      exists a : Array Std.U8 768#usize,
      exists write : Std.Usize,
      exists acc1 : Std.U64,
      exists bc : Bool,
      exists a1 : Array Std.U8 768#usize,
      exists write1 : Std.Usize,
        1#u64 <<< shift = ok pow /\
        pow - 1#u64 = ok mask /\
        num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
          d.num_digits d.digits shift read 0#usize acc mask =
            ok (a, write, acc1) /\
        num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
          d.truncated a shift write acc1 mask = ok (bc, a1, write1) /\
        num.imp.dec2flt.decimal_seq.DecimalSeq.trim
          { num_digits := write1, decimal_point := point,
            truncated := bc, digits := a1 } = ok d' := by
    cases hpow : 1#u64 <<< shift with
    | fail e => simp [hpow] at hrun
    | div => simp [hpow] at hrun
    | ok pow =>
      rw [hpow] at hrun
      simp only [bind_tc_ok] at hrun
      cases hmask : pow - 1#u64 with
      | fail e => simp [hmask] at hrun
      | div => simp [hmask] at hrun
      | ok mask =>
        rw [hmask] at hrun
        simp only [bind_tc_ok] at hrun
        cases hloop1 :
            num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
              d.num_digits d.digits shift read 0#usize acc mask with
        | fail e => simp [hloop1] at hrun
        | div => simp [hloop1] at hrun
        | ok out1 =>
          rcases out1 with ⟨a, write, acc1⟩
          rw [hloop1] at hrun
          simp only [bind_tc_ok] at hrun
          change (do
            let (bc, a1, write1) ←
              num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
                d.truncated a shift write acc1 mask
            num.imp.dec2flt.decimal_seq.DecimalSeq.trim
              { num_digits := write1, decimal_point := point,
                truncated := bc, digits := a1 }) = ok d' at hrun
          cases hloop2 :
              num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
                d.truncated a shift write acc1 mask with
          | fail e => simp [hloop2] at hrun
          | div => simp [hloop2] at hrun
          | ok out2 =>
            rcases out2 with ⟨bc, a1, write1⟩
            rw [hloop2] at hrun
            simp only [bind_tc_ok] at hrun
            exact ⟨pow, mask, a, write, acc1, bc, a1, write1,
              rfl, hmask, hloop1, hloop2, hrun⟩
  rcases hoperations with ⟨pow, mask, a, write, acc1, bc, a1, write1,
    hpow, hmask, hloop1, hloop2, htrim⟩
  let F := fun ys : List Nat => ys.foldl (fun n z => 10 * n + z) 0
  let B := 2 ^ shift.val
  have hmain : d.num_digits.val <= 768 /\
      exists low : List Nat,
        low.length = d.num_digits.val - read.val /\
        (forall z, z ∈ low -> z < 10) /\
        write.val = d.num_digits.val - read.val /\
        acc1.val < 10 * B /\
        acc.val * 10 ^ (d.num_digits.val - read.val) +
            F ((d.digits.val.map (fun z => z.val)).take d.num_digits.val |>.drop read.val) =
          B * (10 * F low) + acc1.val /\
        (forall j, j < low.length ->
          (a.val.map (fun z : Std.U8 => z.val))[j]? = low[j]?) /\
        (forall j, j < 768 -> write.val <= j -> a.val[j]? = d.digits.val[j]?) /\
        (forall j, j < 768 -> d.num_digits.val <= j ->
          a.val[j]? = d.digits.val[j]?) := by
    by_cases hrlt : read.val < d.num_digits.val
    · have hm := P472_T1_DecimalRightShiftMainLoopSemantics
        d.digits a shift read d.num_digits write pow mask acc acc1
        hshift hreadpos (by omega) (by omega) hacc10 hdigits hpow hmask hloop1
      dsimp only at hm
      simpa [F, B, List.map_take] using hm
    · have hrge : d.num_digits.val <= read.val := by omega
      have hrWord : ¬ read < d.num_digits := by
        simpa [UScalar.lt_equiv] using hrlt
      have hdirect :
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
            d.num_digits d.digits shift read 0#usize acc mask =
            ok (d.digits, 0#usize, acc) := by
        unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
        rw [Aeneas.Std.loop.eq_1]
        simp [num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1.body,
          hrWord]
      rw [hdirect] at hloop1
      cases hloop1
      refine ⟨hcap, [], by simp [Nat.sub_eq_zero_of_le hrge], by simp,
        by simp [Nat.sub_eq_zero_of_le hrge], ?_, ?_, ?_, ?_⟩
      · simpa [B] using hacc10
      · have hdrop :
            ((d.digits.val.map (fun z => z.val)).take d.num_digits.val).drop
              read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
        simp [F, hdrop, Nat.sub_eq_zero_of_le hrge]
      · intro j hj
        simp at hj
      · constructor <;> intro j hj _ <;> rfl
  rcases hmain with ⟨hnumBound, low, hlowLen, hlowDigit, hwrite,
    hacc1Bound, hmainNum, hlowArray, hmainBelow, hmainAbove⟩
  have hfinal := P472_T1_DecimalRightShiftFinalLoopSemantics
    a a1 d.truncated bc shift write write1 pow mask acc1 hshift
    (by omega) (by simpa [B] using hacc1Bound) hpow hmask hloop2
  dsimp only at hfinal
  rcases hfinal with ⟨high, hhighDigit, hfinalNum, hwrite1,
    hhighArray, hbelow, houtside, hstickyFinal⟩
  have hcellDecimal : forall j, j < write1.val ->
      exists z : Nat, (a1.val.map (fun z : Std.U8 => z.val))[j]? = some z /\
        z < 10 := by
    intro j hj
    have hj768 : j < 768 := by omega
    by_cases hjwrite : j < write.val
    · have hjlow : j < low.length := by omega
      have hget : low[j]? = some low[j] :=
        getElem?_eq_some_iff.mpr ⟨hjlow, rfl⟩
      have hmem : low[j] ∈ low := List.getElem_mem hjlow
      have hz := hlowDigit _ hmem
      have hpreserve := hbelow j hj768 hjwrite
      have hmapPreserve :
          (a1.val.map (fun z : Std.U8 => z.val))[j]? =
            (a.val.map (fun z : Std.U8 => z.val))[j]? := by
        simp only [List.getElem?_map, hpreserve]
      rw [hmapPreserve, hlowArray j hjlow, hget]
      exact ⟨low[j], rfl, hz⟩
    · have hjge : write.val <= j := by omega
      have hjhigh : j - write.val < high.length := by
        rw [hwrite1] at hj
        have hmin : j < min (write.val + high.length) 768 := hj
        have : j < write.val + high.length :=
          lt_of_lt_of_le hmin (Nat.min_le_left _ _)
        omega
      have hdest : write.val + (j - write.val) = j := by omega
      have hstored := hhighArray (j - write.val) hjhigh (by omega)
      have hstored' :
          (a1.val.map (fun z : Std.U8 => z.val))[j]? =
            high[j - write.val]? := by
        simpa [hdest] using hstored
      have hget : high[j - write.val]? = some high[j - write.val] :=
        getElem?_eq_some_iff.mpr ⟨hjhigh, rfl⟩
      rw [hstored', hget]
      exact ⟨high[j - write.val],
        rfl, hhighDigit _ (List.getElem_mem hjhigh)⟩
  have foldFrom (ys : List Nat) (n : Nat) :
      ys.foldl (fun x z => 10 * x + z) n =
        n * 10 ^ ys.length + F ys := by
    induction ys generalizing n with
    | nil => simp [F]
    | cons y ys ih =>
      simp only [List.foldl_cons, List.length_cons]
      rw [ih, pow_succ]
      change (10 * n + y) * 10 ^ ys.length + F ys =
        n * (10 ^ ys.length * 10) +
          (y :: ys).foldl (fun x z => 10 * x + z) 0
      simp only [List.foldl_cons]
      rw [ih]
      ring
  have foldBound (ys : List Nat)
      (hd : forall z, z ∈ ys -> z < 10) : F ys < 10 ^ ys.length := by
    induction ys with
    | nil => simp [F]
    | cons y ys ih =>
      have hy : y < 10 := hd y (by simp)
      have hys : forall z, z ∈ ys -> z < 10 := by
        intro z hz
        exact hd z (by simp [hz])
      have hi := ih hys
      have hform : F (y :: ys) = y * 10 ^ ys.length + F ys := by
        simpa [F] using foldFrom ys y
      rw [hform, List.length_cons, pow_succ]
      have hm : y * 10 ^ ys.length <= 9 * 10 ^ ys.length :=
        Nat.mul_le_mul_right _ (by omega)
      calc
        y * 10 ^ ys.length + F ys <
            y * 10 ^ ys.length + 10 ^ ys.length := Nat.add_lt_add_left hi _
        _ <= 9 * 10 ^ ys.length + 10 ^ ys.length :=
          Nat.add_le_add_right hm _
        _ = 10 ^ ys.length * 10 := by ring
  have hlowLead : write.val > 0 ->
      exists z tail, low = z :: tail /\ 0 < z := by
    intro hwritePos
    cases low with
    | nil => simp at hlowLen; omega
    | cons z tail =>
      refine ⟨z, tail, rfl, ?_⟩
      by_contra hz
      have hz0 : z = 0 := by omega
      have hmpos : 0 < (z :: tail).length := by simp
      have hpowStep : 10 ^ (z :: tail).length =
          10 * 10 ^ ((z :: tail).length - 1) := by
        have heq : (z :: tail).length = ((z :: tail).length - 1) + 1 := by omega
        calc
          10 ^ (z :: tail).length =
              10 ^ (((z :: tail).length - 1) + 1) :=
            congrArg (fun n : Nat => 10 ^ n) heq
          _ = 10 ^ ((z :: tail).length - 1) * 10 := by rw [pow_succ]
          _ = _ := by ring
      have htailDigit : forall q, q ∈ tail -> q < 10 := by
        intro q hq
        exact hlowDigit q (by simp [hq])
      have htailBound := foldBound tail htailDigit
      have hflow : F (z :: tail) = F tail := by
        rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
          simpa [F] using foldFrom tail z, hz0]
        simp
      have hmainEq := hmainNum
      rw [← hlowLen] at hmainEq
      have haccLower : B <= acc.val := by simpa [B] using hBacc
      have hleftLower : B * 10 ^ (z :: tail).length <=
          acc.val * 10 ^ (z :: tail).length +
            F ((d.digits.val.map (fun q => q.val)).take d.num_digits.val |>.drop read.val) := by
        calc
          B * 10 ^ (z :: tail).length <=
              acc.val * 10 ^ (z :: tail).length :=
            Nat.mul_le_mul_right _ haccLower
          _ <= _ := Nat.le_add_right _ _
      rw [hmainEq] at hleftLower
      have hFlt : F (z :: tail) < 10 ^ ((z :: tail).length - 1) := by
        rw [hflow]
        have hlenTail : (z :: tail).length - 1 = tail.length := by simp
        simpa [hlenTail] using htailBound
      have htenF : 10 * F (z :: tail) <
          10 * 10 ^ ((z :: tail).length - 1) :=
        Nat.mul_lt_mul_of_pos_left hFlt (by norm_num)
      have hFplus : F (z :: tail) + 1 <=
          10 ^ ((z :: tail).length - 1) := Nat.succ_le_of_lt hFlt
      have htenFle : 10 * F (z :: tail) + 10 <=
          10 * 10 ^ ((z :: tail).length - 1) := by
        have := Nat.mul_le_mul_left 10 hFplus
        nlinarith
      have hBFle : B * (10 * F (z :: tail)) + 10 * B <=
          B * (10 * 10 ^ ((z :: tail).length - 1)) := by
        calc
          _ = B * (10 * F (z :: tail) + 10) := by ring
          _ <= _ := Nat.mul_le_mul_left B htenFle
      have hupper : B * (10 * F (z :: tail)) + acc1.val <
          B * 10 ^ (z :: tail).length := by
        calc
          _ < B * (10 * F (z :: tail)) + 10 * B :=
            Nat.add_lt_add_left hacc1Bound _
          _ <= _ := by rw [hpowStep]; exact hBFle
      omega
  have hhighLead : write.val = 0 ->
      exists z tail, high = z :: tail /\ 0 < z := by
    intro hwriteZero
    have hrge : d.num_digits.val <= read.val := by
      omega
    have hnlow : low.length = 0 := by omega
    have hlowNil : low = [] := List.eq_nil_of_length_eq_zero (by
      exact hnlow)
    have hdrop :
        ((d.digits.val.map (fun q => q.val)).take d.num_digits.val).drop
          read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
    have hmainEq := hmainNum
    rw [← hlowLen] at hmainEq
    simp [hlowNil, hdrop, F] at hmainEq
    have haccEq : acc.val = acc1.val := by omega
    have hacc1Lower : B <= acc1.val := by
      rw [← haccEq]
      simpa [B] using hBacc
    cases high with
    | nil =>
      simp [F] at hfinalNum
      have hBpos : 0 < B := by simp [B]
      omega
    | cons z tail =>
      refine ⟨z, tail, rfl, ?_⟩
      by_contra hz
      have hz0 : z = 0 := by omega
      have htailDigit : forall q, q ∈ tail -> q < 10 := by
        intro q hq
        exact hhighDigit q (by simp [hq])
      have htailBound := foldBound tail htailDigit
      have hflow : F (z :: tail) = F tail := by
        rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
          simpa [F] using foldFrom tail z, hz0]
        simp
      have hquotMul := Nat.mul_le_mul_right (10 ^ (z :: tail).length)
        hacc1Lower
      rw [hfinalNum] at hquotMul
      have hquot : 10 ^ (z :: tail).length <= 10 * F (z :: tail) :=
        Nat.le_of_mul_le_mul_left hquotMul (by positivity : 0 < B)
      have hpowStep : 10 ^ (z :: tail).length = 10 * 10 ^ tail.length := by
        simp only [List.length_cons, pow_succ]
        ring
      have hupper : 10 * F (z :: tail) < 10 ^ (z :: tail).length := by
        rw [hflow, hpowStep]
        exact Nat.mul_lt_mul_of_pos_left htailBound (by norm_num)
      omega
  have hfirst : exists z : Nat,
      (a1.val.map (fun b : Std.U8 => b.val))[0]? = some z /\
      1 <= z /\ z < 10 := by
    by_cases hwritePos : write.val > 0
    · obtain ⟨z, tail, hlowEq, hz⟩ := hlowLead hwritePos
      have hz10 : z < 10 := hlowDigit z (by simp [hlowEq])
      have hzeroGet : low[0]? = some z := by simp [hlowEq]
      have harrayMain := hlowArray 0 (by simp [hlowEq])
      have harrayPreserve := hbelow 0 (by omega) hwritePos
      have hmapPreserve :
          (a1.val.map (fun b : Std.U8 => b.val))[0]? =
            (a.val.map (fun b : Std.U8 => b.val))[0]? := by
        simp only [List.getElem?_map, harrayPreserve]
      rw [hmapPreserve, harrayMain, hzeroGet]
      exact ⟨z, rfl, hz, hz10⟩
    · have hwriteZero : write.val = 0 := by omega
      obtain ⟨z, tail, hhighEq, hz⟩ := hhighLead hwriteZero
      have hz10 : z < 10 := hhighDigit z (by simp [hhighEq])
      have harrayHigh := hhighArray 0 (by simp [hhighEq]) (by omega)
      have hzeroGet : high[0]? = some z := by simp [hhighEq]
      have harrayHigh' :
          (a1.val.map (fun b : Std.U8 => b.val))[0]? = some z := by
        simpa [hwriteZero] using harrayHigh.trans hzeroGet
      exact ⟨z, harrayHigh', hz, hz10⟩
  let pre : num.imp.dec2flt.decimal_seq.DecimalSeq :=
    { num_digits := write1, decimal_point := point,
      truncated := bc, digits := a1 }
  have hpreBound : pre.num_digits.val <= pre.digits.val.length := by
    simp [pre, a1.property]
    rw [hwrite1]
    exact Nat.min_le_right _ _
  have htrimSem := DecimalSeqTrimSemantics pre d' hpreBound htrim
  dsimp only at htrimSem
  rcases htrimSem with ⟨hdigitsEq, hpointEq, htruncatedEq, htrimCount,
    htrimZeros, htrimLast, htrimValue⟩
  have hwrite1Bound : write1.val <= 768 := by
    rw [hwrite1]
    exact Nat.min_le_right _ _
  have hcountBound : d'.num_digits.val <= 768 := by
    exact le_trans htrimCount hwrite1Bound
  have hlastNonzero :
      d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 := by
    rcases htrimLast with hzero | hlast
    · exact False.elim (hnonzero hzero)
    · simpa [pre, hdigitsEq] using hlast
  let negRangeFixed : Std.I32 := (-2047)#i32
  have hnegRangeFixed :
      -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
        ok negRangeFixed := by
    unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
    change IScalar.neg (2047#i32 : Std.I32) = _
    unfold IScalar.neg IScalar.tryMk IScalar.tryMkOpt
    norm_num [IScalar.check_bounds, IScalarTy.numBits, negRangeFixed]
  have hnegEq : negRange = negRangeFixed := by
    have heq := hnegRange.symm.trans hnegRangeFixed
    exact Result.ok.inj heq
  have hnegRangeVal : negRange.val = -2047 := by
    simp [negRangeFixed, hnegEq]
  have hpointLower : -2047 <= d'.decimal_point.val := by
    have hd'point : d'.decimal_point.val = point.val := by
      simpa [pre] using congrArg IScalar.val hpointEq
    rw [hd'point]
    have hnot : ¬ point.val < -2047 := by
      simpa [IScalar.lt_equiv, hnegRangeVal] using hnotReset
    omega
  have hretainedDigits : forall b,
      b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10 := by
    intro b hb
    rcases List.mem_iff_getElem.mp hb with ⟨j, hj, rfl⟩
    have hj768 : j < d'.num_digits.val := by
      simp only [List.length_take] at hj
      omega
    have hjwrite : j < write1.val := lt_of_lt_of_le hj768 htrimCount
    obtain ⟨z, hcell, hz⟩ := hcellDecimal j hjwrite
    have hjArr : j < d'.digits.val.length := by
      simp [hdigitsEq, pre, a1.property]
      omega
    have hcell' : (d'.digits.val.map (fun b : Std.U8 => b.val))[j]? = some z := by
      simpa [hdigitsEq, pre] using hcell
    have hval : d'.digits.val[j].val = z := by
      simpa [List.getElem?_map, List.getElem?_eq_getElem hjArr] using hcell'
    simpa [hval] using hz
  obtain ⟨first, hfirstCell, hfirstPos, hfirstLt⟩ := hfirst
  let retained : List Nat :=
    (d'.digits.val.take d'.num_digits.val).map (fun b => b.val)
  have hretainedLen : retained.length = d'.num_digits.val := by
    simp [retained, List.length_take, d'.digits.property]
    omega
  have hretainedFirst : retained[0]? = some first := by
    have hcountPos : 0 < d'.num_digits.val := Nat.pos_of_ne_zero hnonzero
    have hmapFirst :
        (d'.digits.val.map (fun b : Std.U8 => b.val))[0]? = some first := by
      simpa [hdigitsEq, pre] using hfirstCell
    simpa [retained, List.getElem?_map, hcountPos] using hmapFirst
  have hretainedHead : exists tail,
      retained = first :: tail /\ (first :: tail).length = d'.num_digits.val := by
    cases hlist : retained with
    | nil =>
      simp [hlist] at hretainedLen
      exact False.elim (hnonzero hretainedLen)
    | cons z tail =>
      have hfirstEq : z = first := by
        have heq : some z = some first := by simpa [hlist] using hretainedFirst
        exact Option.some.inj heq
      refine ⟨tail, ?_, ?_⟩
      · simpa [hlist, hfirstEq]
      · simpa [hlist, hfirstEq] using hretainedLen
  have hdyad := (P472_T1_DecimalSeqDyadicShiftSemantics).2
    d d' shift X eta u hshift hVpos hdigits hcall hX heta0 hetau hsticky
  rcases hdyad with hreset | ⟨eta', u', hX', heta'0, heta'u', hsticky', hY', _⟩
  · simp [hreset.1] at hnonzero
  · have hY' : Y / (2 : Real) ^ shift.val =
        ((((d'.digits.val.take d'.num_digits.val).map (fun b => b.val)).foldl
          (fun n z => 10 * n + z) 0 : Nat) : Real) *
          (10 : Real) ^ (d'.decimal_point.val - (d'.num_digits.val : Int)) + u' := by
      calc
        Y / (2 : Real) ^ shift.val =
            (((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
              (fun n z => 10 * n + z) 0 : Nat) : Real) *
              (10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) + u) /
              (2 : Real) ^ shift.val := by
                rw [hY]
        _ = _ := hY'.symm
    have hheadOut : exists first tail,
        (d'.digits.val.take d'.num_digits.val).map (fun b => b.val) =
          first :: tail /\
        1 <= first /\ first < 10 /\
        (first :: tail).length = d'.num_digits.val := by
      rcases hretainedHead with ⟨tail, hlist, hlen⟩
      exact ⟨first, tail, by simpa [retained] using hlist,
        hfirstPos, hfirstLt, by simpa using hlen⟩
    refine ⟨hpointLower, hcountBound, hretainedDigits, hheadOut,
      hlastNonzero, ?_⟩
    refine ⟨eta', u', ?_, hY', heta'0, heta'u', hsticky'⟩
    simpa using hX'

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.P472_T1_DecimalSeqDyadicShiftSemantics
import Tablet.P472_T1_DecimalRightShiftPrefixLoopSemantics
import Tablet.P472_T1_DecimalRightShiftMainLoopSemantics
import Tablet.P472_T1_DecimalRightShiftFinalLoopSemantics
import Tablet.DecimalSeqTrimSemantics

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P495_T1_RightShiftCanonical]
theorem P495_T1_RightShiftCanonical (X Y : Real)
    (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize)
    (hshift : shift.val <= 60) (hcap : d.num_digits.val <= 768)
    (hdigits : forall b, b ∈ d.digits.val.take d.num_digits.val -> b.val < 10)
    (hhead : exists h tail,
      (d.digits.val.take d.num_digits.val).map (fun b => b.val) = h :: tail /\
      1 <= h /\ h < 10 /\ (h :: tail).length = d.num_digits.val)
    (hcall : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d')
    (hnonzero : d'.num_digits.val ≠ 0) :
    let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
      ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
        (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
    (exists eta u : Real, X = V d + eta /\ Y = V d + u /\
      0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta)) ->
    -2047 <= d'.decimal_point.val /\ d'.num_digits.val <= 768 /\
    (forall b, b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10) /\
    (exists h tail,
      (d'.digits.val.take d'.num_digits.val).map (fun b => b.val) = h :: tail /\
      1 <= h /\ h < 10 /\ (h :: tail).length = d'.num_digits.val) /\
    d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 /\
    (exists eta' u' : Real,
      X / (2 : Real) ^ shift.val = V d' + eta' /\
      Y / (2 : Real) ^ shift.val = V d' + u' /\
      0 <= eta' /\ eta' < u' /\ (d'.truncated = true <-> 0 < eta')) := by
-- BODY
  dsimp only
  intro hWitness
  rcases hWitness with ⟨eta, u, hX, hY, heta0, hetau, hsticky⟩
  have hVpos : 0 <
      ((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
        (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) := by
    rcases hhead with ⟨h, tail, hshape, hpositive, _, _⟩
    have hfoldNat : 0 <
        ((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
          (fun n z => 10 * n + z) (0 : Nat) := by
      rw [hshape]
      change 0 < (h :: tail).foldl (fun n z => 10 * n + z) 0
      have fold_ge : forall (zs : List Nat) (n : Nat),
          n <= zs.foldl (fun a z => 10 * a + z) n := by
        intro zs
        induction zs with
        | nil => intro n; simp
        | cons z zs ih =>
          intro n
          simp only [List.foldl_cons]
          have := ih (10 * n + z)
          omega
      have hmore : h <= tail.foldl (fun n z => 10 * n + z) h :=
        fold_ge tail h
      have hs : 0 < tail.foldl (fun n z => 10 * n + z) h :=
        lt_of_lt_of_le hpositive hmore
      simpa [List.foldl_cons] using hs
    have hfold : 0 <
        (((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
          (fun n z => 10 * n + z) 0 : Nat) := hfoldNat
    exact mul_pos (by exact_mod_cast hfold)
      (zpow_pos (by norm_num) _)
  have hprefixFacts : exists read acc,
      num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
        d shift 0#usize 0#u64 false = ok (d, read, acc, false) /\
      1 <= read.val /\ read.val <= d.num_digits.val + shift.val /\
      2 ^ shift.val <= acc.val /\ acc.val < 10 * 2 ^ shift.val := by
    have hcallAux := hcall
    unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallAux
    cases hloop0 : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
        d shift 0#usize 0#u64 false with
    | fail e => simp [hloop0] at hcallAux
    | div => simp [hloop0] at hcallAux
    | ok out0 =>
      rcases out0 with ⟨d0, read, acc, allZero⟩
      simp only [hloop0, bind_tc_ok] at hcallAux
      have hpref := P472_T1_DecimalRightShiftPrefixLoopSemantics
        d d0 shift read acc allZero hshift (by
          have hp10 : 0 < (10 : Real) ^
              (d.decimal_point.val - (d.num_digits.val : Int)) :=
            zpow_pos (by norm_num) _
          have hfoldReal : 0 <
              (((d.digits.val.take d.num_digits.val).map
                (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) := by
            by_contra hn
            have hnle :
                ((((d.digits.val.take d.num_digits.val).map
                  (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) <= 0 := by
              exact_mod_cast (le_of_not_gt hn)
            have hprod := mul_nonpos_of_nonpos_of_nonneg hnle (le_of_lt hp10)
            have hprod' :
                ((((d.digits.val.take d.num_digits.val).map
                  (fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) *
                  (10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) <= 0 := by
              simpa [List.map_take] using hprod
            exact (not_le_of_gt hVpos) hprod'
          exact hfoldReal)
        hdigits (by simpa using hloop0)
      dsimp only at hpref
      rcases hpref with ⟨rfl, rfl, hreadpos, hBacc, hacc10, hphase⟩
      refine ⟨read, acc, (by simpa using hloop0), hreadpos, ?_, hBacc, hacc10⟩
      rcases hphase with hphase | hphase <;> omega
  rcases hprefixFacts with ⟨read, acc, hloop0, hreadpos, hreadBound,
    hBacc, hacc10⟩
  have hnormalRun : exists point negRange : Std.I32,
      point.val = d.decimal_point.val - (read.val : Int) + 1 /\
      ¬ point < negRange /\
      -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
        ok negRange /\
      (do
        let pow ← 1#u64 <<< shift
        let mask ← pow - 1#u64
        let (a, wi, n1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
            d.num_digits d.digits shift read 0#usize acc mask
        let (bc, a1, wi1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
            d.truncated a shift wi n1 mask
        num.imp.dec2flt.decimal_seq.DecimalSeq.trim
          { num_digits := wi1, decimal_point := point,
            truncated := bc, digits := a1 }) = ok d' := by
    let readI : Std.I32 := UScalar.hcast .I32 read
    let reset : num.imp.dec2flt.decimal_seq.DecimalSeq :=
      { num_digits := 0#usize, decimal_point := 0#i32,
        truncated := false, digits := d.digits }
    have hread828 : read.val <= 828 := by omega
    have hreadIVal : readI.val = (read.val : Int) := by
      have hs := UScalar.hcast_inBounds_spec .I32 read (by
        rw [IScalar.max_I32_eq]
        omega)
      simp only [lift, WP.spec_ok] at hs
      exact hs
    have hcallBody := hcall
    unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallBody
    rw [hloop0] at hcallBody
    simp only [bind_tc_ok] at hcallBody
    change (do
      let i ← lift (UScalar.hcast .I32 read)
      let i1 ← i - 1#i32
      let i2 ← d.decimal_point - i1
      let i3 ← -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
      if i2 < i3 then ok reset
      else
        let i4 ← 1#u64 <<< shift
        let mask ← i4 - 1#u64
        let (a, wi, n1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
            d.num_digits d.digits shift read 0#usize acc mask
        let (bc, a1, wi1) ←
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
            d.truncated a shift wi n1 mask
        num.imp.dec2flt.decimal_seq.DecimalSeq.trim
          { num_digits := wi1, decimal_point := i2,
            truncated := bc, digits := a1 }) = ok d' at hcallBody
    rw [show UScalar.hcast .I32 read = readI by rfl] at hcallBody
    simp only [lift, bind_tc_ok] at hcallBody
    cases hsub : readI - 1#i32 with
    | fail e => simp [hsub] at hcallBody
    | div => simp [hsub] at hcallBody
    | ok readMinus =>
      rw [hsub] at hcallBody
      simp only [bind_tc_ok] at hcallBody
      cases hpoint : d.decimal_point - readMinus with
      | fail e => simp [hpoint] at hcallBody
      | div => simp [hpoint] at hcallBody
      | ok point =>
        rw [hpoint] at hcallBody
        simp only [bind_tc_ok] at hcallBody
        have hsubVal : readMinus.val = readI.val - 1 := by
          have hs := IScalar.sub_equiv readI 1#i32
          rw [hsub] at hs
          exact hs.2.1
        have hpointVal : point.val =
            d.decimal_point.val - (read.val : Int) + 1 := by
          have hs := IScalar.sub_equiv d.decimal_point readMinus
          rw [hpoint, hsubVal, hreadIVal] at hs
          omega
        cases hnegRange : -.
            num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE with
        | fail e => simp [hnegRange] at hcallBody
        | div => simp [hnegRange] at hcallBody
        | ok negRange =>
          rw [hnegRange] at hcallBody
          simp only [bind_tc_ok] at hcallBody
          by_cases hreset : point < negRange
          · simp only [hreset, if_true] at hcallBody
            have hd' : d' = reset := by simpa using hcallBody.symm
            rw [hd'] at hnonzero
            simp [reset] at hnonzero
          · simp only [hreset, if_false] at hcallBody
            exact ⟨point, negRange, hpointVal, hreset, rfl, hcallBody⟩
  rcases hnormalRun with ⟨point, negRange, hpointVal, hnotReset,
    hnegRange, hrun⟩
  have hoperations : exists pow mask : Std.U64,
      exists a : Array Std.U8 768#usize,
      exists write : Std.Usize,
      exists acc1 : Std.U64,
      exists bc : Bool,
      exists a1 : Array Std.U8 768#usize,
      exists write1 : Std.Usize,
        1#u64 <<< shift = ok pow /\
        pow - 1#u64 = ok mask /\
        num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
          d.num_digits d.digits shift read 0#usize acc mask =
            ok (a, write, acc1) /\
        num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
          d.truncated a shift write acc1 mask = ok (bc, a1, write1) /\
        num.imp.dec2flt.decimal_seq.DecimalSeq.trim
          { num_digits := write1, decimal_point := point,
            truncated := bc, digits := a1 } = ok d' := by
    cases hpow : 1#u64 <<< shift with
    | fail e => simp [hpow] at hrun
    | div => simp [hpow] at hrun
    | ok pow =>
      rw [hpow] at hrun
      simp only [bind_tc_ok] at hrun
      cases hmask : pow - 1#u64 with
      | fail e => simp [hmask] at hrun
      | div => simp [hmask] at hrun
      | ok mask =>
        rw [hmask] at hrun
        simp only [bind_tc_ok] at hrun
        cases hloop1 :
            num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
              d.num_digits d.digits shift read 0#usize acc mask with
        | fail e => simp [hloop1] at hrun
        | div => simp [hloop1] at hrun
        | ok out1 =>
          rcases out1 with ⟨a, write, acc1⟩
          rw [hloop1] at hrun
          simp only [bind_tc_ok] at hrun
          change (do
            let (bc, a1, write1) ←
              num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
                d.truncated a shift write acc1 mask
            num.imp.dec2flt.decimal_seq.DecimalSeq.trim
              { num_digits := write1, decimal_point := point,
                truncated := bc, digits := a1 }) = ok d' at hrun
          cases hloop2 :
              num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
                d.truncated a shift write acc1 mask with
          | fail e => simp [hloop2] at hrun
          | div => simp [hloop2] at hrun
          | ok out2 =>
            rcases out2 with ⟨bc, a1, write1⟩
            rw [hloop2] at hrun
            simp only [bind_tc_ok] at hrun
            exact ⟨pow, mask, a, write, acc1, bc, a1, write1,
              rfl, hmask, hloop1, hloop2, hrun⟩
  rcases hoperations with ⟨pow, mask, a, write, acc1, bc, a1, write1,
    hpow, hmask, hloop1, hloop2, htrim⟩
  let F := fun ys : List Nat => ys.foldl (fun n z => 10 * n + z) 0
  let B := 2 ^ shift.val
  have hmain : d.num_digits.val <= 768 /\
      exists low : List Nat,
        low.length = d.num_digits.val - read.val /\
        (forall z, z ∈ low -> z < 10) /\
        write.val = d.num_digits.val - read.val /\
        acc1.val < 10 * B /\
        acc.val * 10 ^ (d.num_digits.val - read.val) +
            F ((d.digits.val.map (fun z => z.val)).take d.num_digits.val |>.drop read.val) =
          B * (10 * F low) + acc1.val /\
        (forall j, j < low.length ->
          (a.val.map (fun z : Std.U8 => z.val))[j]? = low[j]?) /\
        (forall j, j < 768 -> write.val <= j -> a.val[j]? = d.digits.val[j]?) /\
        (forall j, j < 768 -> d.num_digits.val <= j ->
          a.val[j]? = d.digits.val[j]?) := by
    by_cases hrlt : read.val < d.num_digits.val
    · have hm := P472_T1_DecimalRightShiftMainLoopSemantics
        d.digits a shift read d.num_digits write pow mask acc acc1
        hshift hreadpos (by omega) (by omega) hacc10 hdigits hpow hmask hloop1
      dsimp only at hm
      simpa [F, B, List.map_take] using hm
    · have hrge : d.num_digits.val <= read.val := by omega
      have hrWord : ¬ read < d.num_digits := by
        simpa [UScalar.lt_equiv] using hrlt
      have hdirect :
          num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
            d.num_digits d.digits shift read 0#usize acc mask =
            ok (d.digits, 0#usize, acc) := by
        unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
        rw [Aeneas.Std.loop.eq_1]
        simp [num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1.body,
          hrWord]
      rw [hdirect] at hloop1
      cases hloop1
      refine ⟨hcap, [], by simp [Nat.sub_eq_zero_of_le hrge], by simp,
        by simp [Nat.sub_eq_zero_of_le hrge], ?_, ?_, ?_, ?_⟩
      · simpa [B] using hacc10
      · have hdrop :
            ((d.digits.val.map (fun z => z.val)).take d.num_digits.val).drop
              read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
        simp [F, hdrop, Nat.sub_eq_zero_of_le hrge]
      · intro j hj
        simp at hj
      · constructor <;> intro j hj _ <;> rfl
  rcases hmain with ⟨hnumBound, low, hlowLen, hlowDigit, hwrite,
    hacc1Bound, hmainNum, hlowArray, hmainBelow, hmainAbove⟩
  have hfinal := P472_T1_DecimalRightShiftFinalLoopSemantics
    a a1 d.truncated bc shift write write1 pow mask acc1 hshift
    (by omega) (by simpa [B] using hacc1Bound) hpow hmask hloop2
  dsimp only at hfinal
  rcases hfinal with ⟨high, hhighDigit, hfinalNum, hwrite1,
    hhighArray, hbelow, houtside, hstickyFinal⟩
  have hcellDecimal : forall j, j < write1.val ->
      exists z : Nat, (a1.val.map (fun z : Std.U8 => z.val))[j]? = some z /\
        z < 10 := by
    intro j hj
    have hj768 : j < 768 := by omega
    by_cases hjwrite : j < write.val
    · have hjlow : j < low.length := by omega
      have hget : low[j]? = some low[j] :=
        getElem?_eq_some_iff.mpr ⟨hjlow, rfl⟩
      have hmem : low[j] ∈ low := List.getElem_mem hjlow
      have hz := hlowDigit _ hmem
      have hpreserve := hbelow j hj768 hjwrite
      have hmapPreserve :
          (a1.val.map (fun z : Std.U8 => z.val))[j]? =
            (a.val.map (fun z : Std.U8 => z.val))[j]? := by
        simp only [List.getElem?_map, hpreserve]
      rw [hmapPreserve, hlowArray j hjlow, hget]
      exact ⟨low[j], rfl, hz⟩
    · have hjge : write.val <= j := by omega
      have hjhigh : j - write.val < high.length := by
        rw [hwrite1] at hj
        have hmin : j < min (write.val + high.length) 768 := hj
        have : j < write.val + high.length :=
          lt_of_lt_of_le hmin (Nat.min_le_left _ _)
        omega
      have hdest : write.val + (j - write.val) = j := by omega
      have hstored := hhighArray (j - write.val) hjhigh (by omega)
      have hstored' :
          (a1.val.map (fun z : Std.U8 => z.val))[j]? =
            high[j - write.val]? := by
        simpa [hdest] using hstored
      have hget : high[j - write.val]? = some high[j - write.val] :=
        getElem?_eq_some_iff.mpr ⟨hjhigh, rfl⟩
      rw [hstored', hget]
      exact ⟨high[j - write.val],
        rfl, hhighDigit _ (List.getElem_mem hjhigh)⟩
  have foldFrom (ys : List Nat) (n : Nat) :
      ys.foldl (fun x z => 10 * x + z) n =
        n * 10 ^ ys.length + F ys := by
    induction ys generalizing n with
    | nil => simp [F]
    | cons y ys ih =>
      simp only [List.foldl_cons, List.length_cons]
      rw [ih, pow_succ]
      change (10 * n + y) * 10 ^ ys.length + F ys =
        n * (10 ^ ys.length * 10) +
          (y :: ys).foldl (fun x z => 10 * x + z) 0
      simp only [List.foldl_cons]
      rw [ih]
      ring
  have foldBound (ys : List Nat)
      (hd : forall z, z ∈ ys -> z < 10) : F ys < 10 ^ ys.length := by
    induction ys with
    | nil => simp [F]
    | cons y ys ih =>
      have hy : y < 10 := hd y (by simp)
      have hys : forall z, z ∈ ys -> z < 10 := by
        intro z hz
        exact hd z (by simp [hz])
      have hi := ih hys
      have hform : F (y :: ys) = y * 10 ^ ys.length + F ys := by
        simpa [F] using foldFrom ys y
      rw [hform, List.length_cons, pow_succ]
      have hm : y * 10 ^ ys.length <= 9 * 10 ^ ys.length :=
        Nat.mul_le_mul_right _ (by omega)
      calc
        y * 10 ^ ys.length + F ys <
            y * 10 ^ ys.length + 10 ^ ys.length := Nat.add_lt_add_left hi _
        _ <= 9 * 10 ^ ys.length + 10 ^ ys.length :=
          Nat.add_le_add_right hm _
        _ = 10 ^ ys.length * 10 := by ring
  have hlowLead : write.val > 0 ->
      exists z tail, low = z :: tail /\ 0 < z := by
    intro hwritePos
    cases low with
    | nil => simp at hlowLen; omega
    | cons z tail =>
      refine ⟨z, tail, rfl, ?_⟩
      by_contra hz
      have hz0 : z = 0 := by omega
      have hmpos : 0 < (z :: tail).length := by simp
      have hpowStep : 10 ^ (z :: tail).length =
          10 * 10 ^ ((z :: tail).length - 1) := by
        have heq : (z :: tail).length = ((z :: tail).length - 1) + 1 := by omega
        calc
          10 ^ (z :: tail).length =
              10 ^ (((z :: tail).length - 1) + 1) :=
            congrArg (fun n : Nat => 10 ^ n) heq
          _ = 10 ^ ((z :: tail).length - 1) * 10 := by rw [pow_succ]
          _ = _ := by ring
      have htailDigit : forall q, q ∈ tail -> q < 10 := by
        intro q hq
        exact hlowDigit q (by simp [hq])
      have htailBound := foldBound tail htailDigit
      have hflow : F (z :: tail) = F tail := by
        rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
          simpa [F] using foldFrom tail z, hz0]
        simp
      have hmainEq := hmainNum
      rw [← hlowLen] at hmainEq
      have haccLower : B <= acc.val := by simpa [B] using hBacc
      have hleftLower : B * 10 ^ (z :: tail).length <=
          acc.val * 10 ^ (z :: tail).length +
            F ((d.digits.val.map (fun q => q.val)).take d.num_digits.val |>.drop read.val) := by
        calc
          B * 10 ^ (z :: tail).length <=
              acc.val * 10 ^ (z :: tail).length :=
            Nat.mul_le_mul_right _ haccLower
          _ <= _ := Nat.le_add_right _ _
      rw [hmainEq] at hleftLower
      have hFlt : F (z :: tail) < 10 ^ ((z :: tail).length - 1) := by
        rw [hflow]
        have hlenTail : (z :: tail).length - 1 = tail.length := by simp
        simpa [hlenTail] using htailBound
      have htenF : 10 * F (z :: tail) <
          10 * 10 ^ ((z :: tail).length - 1) :=
        Nat.mul_lt_mul_of_pos_left hFlt (by norm_num)
      have hFplus : F (z :: tail) + 1 <=
          10 ^ ((z :: tail).length - 1) := Nat.succ_le_of_lt hFlt
      have htenFle : 10 * F (z :: tail) + 10 <=
          10 * 10 ^ ((z :: tail).length - 1) := by
        have := Nat.mul_le_mul_left 10 hFplus
        nlinarith
      have hBFle : B * (10 * F (z :: tail)) + 10 * B <=
          B * (10 * 10 ^ ((z :: tail).length - 1)) := by
        calc
          _ = B * (10 * F (z :: tail) + 10) := by ring
          _ <= _ := Nat.mul_le_mul_left B htenFle
      have hupper : B * (10 * F (z :: tail)) + acc1.val <
          B * 10 ^ (z :: tail).length := by
        calc
          _ < B * (10 * F (z :: tail)) + 10 * B :=
            Nat.add_lt_add_left hacc1Bound _
          _ <= _ := by rw [hpowStep]; exact hBFle
      omega
  have hhighLead : write.val = 0 ->
      exists z tail, high = z :: tail /\ 0 < z := by
    intro hwriteZero
    have hrge : d.num_digits.val <= read.val := by
      omega
    have hnlow : low.length = 0 := by omega
    have hlowNil : low = [] := List.eq_nil_of_length_eq_zero (by
      exact hnlow)
    have hdrop :
        ((d.digits.val.map (fun q => q.val)).take d.num_digits.val).drop
          read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
    have hmainEq := hmainNum
    rw [← hlowLen] at hmainEq
    simp [hlowNil, hdrop, F] at hmainEq
    have haccEq : acc.val = acc1.val := by omega
    have hacc1Lower : B <= acc1.val := by
      rw [← haccEq]
      simpa [B] using hBacc
    cases high with
    | nil =>
      simp [F] at hfinalNum
      have hBpos : 0 < B := by simp [B]
      omega
    | cons z tail =>
      refine ⟨z, tail, rfl, ?_⟩
      by_contra hz
      have hz0 : z = 0 := by omega
      have htailDigit : forall q, q ∈ tail -> q < 10 := by
        intro q hq
        exact hhighDigit q (by simp [hq])
      have htailBound := foldBound tail htailDigit
      have hflow : F (z :: tail) = F tail := by
        rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
          simpa [F] using foldFrom tail z, hz0]
        simp
      have hquotMul := Nat.mul_le_mul_right (10 ^ (z :: tail).length)
        hacc1Lower
      rw [hfinalNum] at hquotMul
      have hquot : 10 ^ (z :: tail).length <= 10 * F (z :: tail) :=
        Nat.le_of_mul_le_mul_left hquotMul (by positivity : 0 < B)
      have hpowStep : 10 ^ (z :: tail).length = 10 * 10 ^ tail.length := by
        simp only [List.length_cons, pow_succ]
        ring
      have hupper : 10 * F (z :: tail) < 10 ^ (z :: tail).length := by
        rw [hflow, hpowStep]
        exact Nat.mul_lt_mul_of_pos_left htailBound (by norm_num)
      omega
  have hfirst : exists z : Nat,
      (a1.val.map (fun b : Std.U8 => b.val))[0]? = some z /\
      1 <= z /\ z < 10 := by
    by_cases hwritePos : write.val > 0
    · obtain ⟨z, tail, hlowEq, hz⟩ := hlowLead hwritePos
      have hz10 : z < 10 := hlowDigit z (by simp [hlowEq])
      have hzeroGet : low[0]? = some z := by simp [hlowEq]
      have harrayMain := hlowArray 0 (by simp [hlowEq])
      have harrayPreserve := hbelow 0 (by omega) hwritePos
      have hmapPreserve :
          (a1.val.map (fun b : Std.U8 => b.val))[0]? =
            (a.val.map (fun b : Std.U8 => b.val))[0]? := by
        simp only [List.getElem?_map, harrayPreserve]
      rw [hmapPreserve, harrayMain, hzeroGet]
      exact ⟨z, rfl, hz, hz10⟩
    · have hwriteZero : write.val = 0 := by omega
      obtain ⟨z, tail, hhighEq, hz⟩ := hhighLead hwriteZero
      have hz10 : z < 10 := hhighDigit z (by simp [hhighEq])
      have harrayHigh := hhighArray 0 (by simp [hhighEq]) (by omega)
      have hzeroGet : high[0]? = some z := by simp [hhighEq]
      have harrayHigh' :
          (a1.val.map (fun b : Std.U8 => b.val))[0]? = some z := by
        simpa [hwriteZero] using harrayHigh.trans hzeroGet
      exact ⟨z, harrayHigh', hz, hz10⟩
  let pre : num.imp.dec2flt.decimal_seq.DecimalSeq :=
    { num_digits := write1, decimal_point := point,
      truncated := bc, digits := a1 }
  have hpreBound : pre.num_digits.val <= pre.digits.val.length := by
    simp [pre, a1.property]
    rw [hwrite1]
    exact Nat.min_le_right _ _
  have htrimSem := DecimalSeqTrimSemantics pre d' hpreBound htrim
  dsimp only at htrimSem
  rcases htrimSem with ⟨hdigitsEq, hpointEq, htruncatedEq, htrimCount,
    htrimZeros, htrimLast, htrimValue⟩
  have hwrite1Bound : write1.val <= 768 := by
    rw [hwrite1]
    exact Nat.min_le_right _ _
  have hcountBound : d'.num_digits.val <= 768 := by
    exact le_trans htrimCount hwrite1Bound
  have hlastNonzero :
      d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 := by
    rcases htrimLast with hzero | hlast
    · exact False.elim (hnonzero hzero)
    · simpa [pre, hdigitsEq] using hlast
  let negRangeFixed : Std.I32 := (-2047)#i32
  have hnegRangeFixed :
      -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
        ok negRangeFixed := by
    unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
    change IScalar.neg (2047#i32 : Std.I32) = _
    unfold IScalar.neg IScalar.tryMk IScalar.tryMkOpt
    norm_num [IScalar.check_bounds, IScalarTy.numBits, negRangeFixed]
  have hnegEq : negRange = negRangeFixed := by
    have heq := hnegRange.symm.trans hnegRangeFixed
    exact Result.ok.inj heq
  have hnegRangeVal : negRange.val = -2047 := by
    simp [negRangeFixed, hnegEq]
  have hpointLower : -2047 <= d'.decimal_point.val := by
    have hd'point : d'.decimal_point.val = point.val := by
      simpa [pre] using congrArg IScalar.val hpointEq
    rw [hd'point]
    have hnot : ¬ point.val < -2047 := by
      simpa [IScalar.lt_equiv, hnegRangeVal] using hnotReset
    omega
  have hretainedDigits : forall b,
      b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10 := by
    intro b hb
    rcases List.mem_iff_getElem.mp hb with ⟨j, hj, rfl⟩
    have hj768 : j < d'.num_digits.val := by
      simp only [List.length_take] at hj
      omega
    have hjwrite : j < write1.val := lt_of_lt_of_le hj768 htrimCount
    obtain ⟨z, hcell, hz⟩ := hcellDecimal j hjwrite
    have hjArr : j < d'.digits.val.length := by
      simp [hdigitsEq, pre, a1.property]
      omega
    have hcell' : (d'.digits.val.map (fun b : Std.U8 => b.val))[j]? = some z := by
      simpa [hdigitsEq, pre] using hcell
    have hval : d'.digits.val[j].val = z := by
      simpa [List.getElem?_map, List.getElem?_eq_getElem hjArr] using hcell'
    simpa [hval] using hz
  obtain ⟨first, hfirstCell, hfirstPos, hfirstLt⟩ := hfirst
  let retained : List Nat :=
    (d'.digits.val.take d'.num_digits.val).map (fun b => b.val)
  have hretainedLen : retained.length = d'.num_digits.val := by
    simp [retained, List.length_take, d'.digits.property]
    omega
  have hretainedFirst : retained[0]? = some first := by
    have hcountPos : 0 < d'.num_digits.val := Nat.pos_of_ne_zero hnonzero
    have hmapFirst :
        (d'.digits.val.map (fun b : Std.U8 => b.val))[0]? = some first := by
      simpa [hdigitsEq, pre] using hfirstCell
    simpa [retained, List.getElem?_map, hcountPos] using hmapFirst
  have hretainedHead : exists tail,
      retained = first :: tail /\ (first :: tail).length = d'.num_digits.val := by
    cases hlist : retained with
    | nil =>
      simp [hlist] at hretainedLen
      exact False.elim (hnonzero hretainedLen)
    | cons z tail =>
      have hfirstEq : z = first := by
        have heq : some z = some first := by simpa [hlist] using hretainedFirst
        exact Option.some.inj heq
      refine ⟨tail, ?_, ?_⟩
      · simpa [hlist, hfirstEq]
      · simpa [hlist, hfirstEq] using hretainedLen
  have hdyad := (P472_T1_DecimalSeqDyadicShiftSemantics).2
    d d' shift X eta u hshift hVpos hdigits hcall hX heta0 hetau hsticky
  rcases hdyad with hreset | ⟨eta', u', hX', heta'0, heta'u', hsticky', hY', _⟩
  · simp [hreset.1] at hnonzero
  · have hY' : Y / (2 : Real) ^ shift.val =
        ((((d'.digits.val.take d'.num_digits.val).map (fun b => b.val)).foldl
          (fun n z => 10 * n + z) 0 : Nat) : Real) *
          (10 : Real) ^ (d'.decimal_point.val - (d'.num_digits.val : Int)) + u' := by
      calc
        Y / (2 : Real) ^ shift.val =
            (((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
              (fun n z => 10 * n + z) 0 : Nat) : Real) *
              (10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) + u) /
              (2 : Real) ^ shift.val := by
                rw [hY]
        _ = _ := hY'.symm
    have hheadOut : exists first tail,
        (d'.digits.val.take d'.num_digits.val).map (fun b => b.val) =
          first :: tail /\
        1 <= first /\ first < 10 /\
        (first :: tail).length = d'.num_digits.val := by
      rcases hretainedHead with ⟨tail, hlist, hlen⟩
      exact ⟨first, tail, by simpa [retained] using hlist,
        hfirstPos, hfirstLt, by simpa using hlen⟩
    refine ⟨hpointLower, hcountBound, hretainedDigits, hheadOut,
      hlastNonzero, ?_⟩
    refine ⟨eta', u', ?_, hY', heta'0, heta'u', hsticky'⟩
    simpa using hX'

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 26 entries
Technical checking records
Local closure summary
{
  "node": "P495_T1_RightShiftCanonical",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "030775dab3e100ecff1ba6b20e8851f85ca7d32a369ba986975e6700ca53a3d7",
  "active_statement_hash": "874bacf5ca21d48a75e13ef9251a833d7e879811f45596b5fc1c99f4e1935723",
  "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": {
    "DecimalSeqTrimSemantics": "e4b2cbb62f7171af",
    "P472_T1_DecimalRightShiftFinalLoopSemantics": "79a214a5ee500eac",
    "P472_T1_DecimalRightShiftMainLoopSemantics": "647cdcc98ff47e21",
    "P472_T1_DecimalRightShiftPrefixLoopSemantics": "0d5cb25f18eedbfb",
    "P472_T1_DecimalSeqDyadicShiftSemantics": "9d844d655b9f8a27",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "01b84a7a35e5bcf4",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "5f4488c177675662"
  },
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "6799fe6525ddb761",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "0cc5155758bc976a",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "fd298e37d5ae4f86",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "4db7c37f5da1c6e0",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_trim": "faa9fd92b8c29c14"
  }
}
Prose assessment
{
  "label": "Recorded Sound: VerifierPass",
  "assessment_status": "VerifierPass",
  "fingerprint_relation": "matches current fingerprint",
  "assessment_fingerprint": "sound-v2:5e0c49d41b8e15850089ad6137f5149ef93e488aa433a65c4d9ac9e4fc437941",
  "current_fingerprint": "sound-v2:5e0c49d41b8e15850089ad6137f5149ef93e488aa433a65c4d9ac9e4fc437941",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Pass",
  "substantiveness_status": "Pass"
}