Program Rust
right_shift_loop0
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
178 let mut write_index = 0;179 let mut n = 0_u64;180 let mut all_zero = false;181 while (n >> shift) == 0 && !all_zero {182 if read_index < self.num_digits {183 n = (10 * n) + self.digits[read_index] as u64;184 read_index += 1;185 } else if n == 0 {186 // The source returns here from inside the loop. Recording the187 // condition and returning immediately after the loop executes188 // no intervening operation and preserves the unchanged value.189 all_zero = true;190 } else {191 while (n >> shift) == 0 {192 n *= 10;193 read_index += 1;194 }195 break;196 }197 }198 if all_zero {199 return;200 }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 | 181:8–197:9 |
| Program version | Revised program |