Source context

Program Rust

parse_long_mantissa_loop1

This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.

66         return result;67     }68     // Shift left toward (1/2 ... 1].69     while d.decimal_point <= 0 && loop_result.is_none() {70         let shift = if d.decimal_point == 0 {71             match d.digits[0] {72                 digit if digit >= 5 => break,73                 0 | 1 => 2,74                 _ => 1,75             }76         } else {77             get_shift((-d.decimal_point) as _)78         };79         d.left_shift(shift);80         if d.decimal_point > DecimalSeq::DECIMAL_POINT_RANGE {81             // This records the source's immediate `fp_inf` return.  Since the82             // guarded loop exits before the exponent update, moving the return83             // just below the loop preserves every state transition.84             loop_result = Some(fp_inf);85         } else {86             exp2 -= shift as i32;87         }88     }89     if let Some(result) = loop_result {90         return result;91     }

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

@[rust_loop]
def num.imp.dec2flt.slow.parse_long_mantissa_loop1
  {F : Type} {Clause0_Int : Type} (traitsFloatInst : num.imp.traits.Float F
  Clause0_Int) (fp_inf : num.imp.dec2flt.common.BiasedFp) (i : Std.Usize)
  (i1 : Std.I32) (b : Bool) (a : Array Std.U8 768#usize) (exp2 : Std.I32)
  (loop_result : Option num.imp.dec2flt.common.BiasedFp) :
  Result (Std.Usize × Std.I32 × Bool × (Array Std.U8 768#usize) × Std.I32
    × (Option num.imp.dec2flt.common.BiasedFp))
  := do
  loop
    (fun (i2, i3, b1, a1, exp21, loop_result1) =>
      num.imp.dec2flt.slow.parse_long_mantissa_loop1.body traitsFloatInst
      fp_inf i2 i3 b1 a1 exp21 loop_result1)
    (i, i1, b, a, exp2, loop_result)
Operations used here

BiasedFp · Program Rust

Float · Program Rust

body · Program Rust

Other extracted objects at this span

num.imp.dec2flt.slow.parse_long_mantissa_loop1.body

Source details
Declarationnum.imp.dec2flt.slow.parse_long_mantissa_loop1
Filenum/imp/../../dec2flt/slow.rs
Lines69:4–88:5
Program versionOriginal program