num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift

Lean checked

Definition and explanation

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

No paired prose available.

Lean definition

This module includes declarations linked to the Aeneas extraction. The source view pairs each matched declaration with its Rust input.

import Tablet.Assumptions
import Tablet.Preamble
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_trim
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
noncomputable section
namespace dec2flt_model

-- [TABLET NODE: num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift]
/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::{dec2flt_model::num::imp::dec2flt::decimal_seq::DecimalSeq}::left_shift]: loop body 0:
    Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 138:8-150:9 -/
@[rust_loop_body]
def num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body
  (shift : Std.Usize) (b : Bool) (a : Array Std.U8 768#usize)
  (read_index : Std.Usize) (write_index : Std.Usize) (n : Std.U64) :
  Result (ControlFlow (Bool × (Array Std.U8 768#usize) × Std.Usize ×
    Std.Usize × Std.U64) (Bool × (Array Std.U8 768#usize) × Std.Usize ×
    Std.U64))
  :=
-- BODY
do
  if read_index != 0#usize
  then
    let read_index1 ← read_index - 1#usize
    let write_index1 ← write_index - 1#usize
    let i ← Array.index_usize a read_index1
    let i1 ← lift (UScalar.cast .U64 i)
    let i2 ← i1 <<< shift
    let n1 ← n + i2
    let quotient ← n1 / 10#u64
    let i3 ← 10#u64 * quotient
    let remainder ← n1 - i3
    if write_index1 < num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
    then
      let i4 ← lift (UScalar.cast .U8 remainder)
      let a1 ← Array.update a write_index1 i4
      ok (cont (b, a1, read_index1, write_index1, quotient))
    else
      if remainder > 0#u64
      then ok (cont (true, a, read_index1, write_index1, quotient))
      else ok (cont (b, a, read_index1, write_index1, quotient))
  else ok (done (b, a, write_index, n))


/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::{dec2flt_model::num::imp::dec2flt::decimal_seq::DecimalSeq}::left_shift]: loop 0:
    Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 138:8-150:9 -/
@[rust_loop]
def num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0
  (b : Bool) (a : Array Std.U8 768#usize) (shift : Std.Usize)
  (read_index : Std.Usize) (write_index : Std.Usize) (n : Std.U64) :
  Result (Bool × (Array Std.U8 768#usize) × Std.Usize × Std.U64)
  := do
  loop
    (fun (b1, a1, read_index1, write_index1, n1) =>
      num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body shift b1 a1
      read_index1 write_index1 n1)
    (b, a, read_index, write_index, n)


/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::{dec2flt_model::num::imp::dec2flt::decimal_seq::DecimalSeq}::left_shift]: loop body 1:
    Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 152:8-162:9 -/
@[rust_loop_body]
def num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop1.body
  (b : Bool) (a : Array Std.U8 768#usize) (write_index : Std.Usize)
  (n : Std.U64) :
  Result (ControlFlow (Bool × (Array Std.U8 768#usize) × Std.Usize ×
    Std.U64) (Bool × (Array Std.U8 768#usize)))
  := do
  if n > 0#u64
  then
    let write_index1 ← write_index - 1#usize
    let quotient ← n / 10#u64
    let i ← 10#u64 * quotient
    let remainder ← n - i
    if write_index1 < num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
    then
      let i1 ← lift (UScalar.cast .U8 remainder)
      let a1 ← Array.update a write_index1 i1
      ok (cont (b, a1, write_index1, quotient))
    else
      if remainder > 0#u64
      then ok (cont (true, a, write_index1, quotient))
      else ok (cont (b, a, write_index1, quotient))
  else ok (done (b, a))


/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::{dec2flt_model::num::imp::dec2flt::decimal_seq::DecimalSeq}::left_shift]: loop 1:
    Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 152:8-162:9 -/
@[rust_loop]
def num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop1
  (b : Bool) (a : Array Std.U8 768#usize) (write_index : Std.Usize)
  (n : Std.U64) :
  Result (Bool × (Array Std.U8 768#usize))
  := do
  loop
    (fun (b1, a1, write_index1, n1) =>
      num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop1.body b1 a1
      write_index1 n1)
    (b, a, write_index, n)


/-- [dec2flt_model::num::imp::dec2flt::decimal_seq::{dec2flt_model::num::imp::dec2flt::decimal_seq::DecimalSeq}::left_shift]:
    Source: 'num/imp/../../dec2flt/decimal_seq.rs', lines 129:4-172:5 -/
def num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift
  (self : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize) :
  Result num.imp.dec2flt.decimal_seq.DecimalSeq
  := do
  if self.num_digits = 0#usize
  then ok self
  else
    let num_new_digits ←
      num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift self
        shift
    let write_index ← self.num_digits + num_new_digits
    let (b, a, write_index1, n) ←
      num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0 self.truncated
        self.digits shift self.num_digits write_index 0#u64
    let (b1, a1) ←
      num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop1 b a write_index1
        n
    let i ← self.num_digits + num_new_digits
    let i1 ←
      if i > num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
      then ok num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS
      else ok i
    let i2 ← lift (UScalar.hcast .I32 num_new_digits)
    let i3 ← self.decimal_point + i2
    num.imp.dec2flt.decimal_seq.DecimalSeq.trim
      { num_digits := i1, decimal_point := i3, truncated := b1, digits := a1 }
Preservation and explanation

Natural-language argument

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.

The authored explanation is included with the statement above.

Download Lean source · Download TeX source

Proof structure

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

Explore this dependency tree

Inspect related source (58)
More program dependencies (25)
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 7 entries
Technical checking records
Local closure summary
{
  "node": "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "08cc5cc63daac71e9d7bdb6f6d520eae72b3af4cbd4a73b88a1bf20aa9edf180",
  "active_statement_hash": "",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "d5c04ffa333d9b33b238a527f5beaa2be82e021d3e9c0bbe01b1310280f7f55a",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-23",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "b0286c42454b158d",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "39f6cb231ef80388",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_trim": "faa9fd92b8c29c14",
    "num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift": "b3efbd0e6b3fe061"
  }
}
Prose assessment
{
  "label": "Prose review has no verdict in this snapshot",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": null,
  "superseded_for_theorem_closure": false
}
Review verdicts
{}