Program Rust
right_shift_loop0
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
177 let mut write_index = 0;178 let mut n = 0_u64;179 let mut all_zero = false;180 while (n >> shift) == 0 && !all_zero {181 if read_index < self.num_digits {182 n = (10 * n) + self.digits[read_index] as u64;183 read_index += 1;184 } else if n == 0 {185 // The source returns here from inside the loop. Recording the186 // condition and returning immediately after the loop executes187 // no intervening operation and preserves the unchanged value.188 all_zero = true;189 } else {190 while (n >> shift) == 0 {191 n *= 10;192 read_index += 1;193 }194 break;195 }196 }197 if all_zero {198 return;199 }Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop]
def num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
(self : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize)
(read_index : Std.Usize) (n : Std.U64) (all_zero : Bool) :
Result (num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize × Std.U64 ×
Bool)
:= do
loop
(fun (read_index1, n1, all_zero1) =>
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0.body self shift
read_index1 n1 all_zero1)
(read_index, n, all_zero)Other extracted objects at this span
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0.body
Source details
| Declaration | num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0 |
|---|---|
| File | num/imp/../../dec2flt/decimal_seq.rs |
| Lines | 180:8–196:9 |
| Program version | Original program |