Program Rust
dec2flt
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
494 495 /// Converts a decimal string into a floating point number.496 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above497 pub fn dec2flt<498 F: Lemire499 + core::ops::Div<Output = F>500 + core::ops::Mul<Output = F>501 + core::ops::Neg<Output = F>,502 >(503 s: &str,504 ) -> Result<F, ParseFloatError> {505 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct506 // clause admits exactly the same instances and lets Charon resolve the507 // explicit, source-equivalent final negation.508 // The public function is now exactly the result projection of the single509 // instrumented implementation. No conversion step is duplicated, and510 // discarding the trace cannot affect Rust evaluation or the returned bits.511 dec2flt_with_trace::<F>(s).0512 }Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
def num.imp.dec2flt.dec2flt
{F : Type} {Clause0_Clause0_Clause0_Int : Type} (LemireInst :
num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
(coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
Result (core.result.Result F num.float_parse.ParseFloatError)
:= do
let (r, _) ←
num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
coreopsarithMulInst coreopsarithNegInst s
ok rOperations used here
Source details
| Declaration | num.imp.dec2flt.dec2flt |
|---|---|
| File | num/imp/../../dec2flt/mod.rs |
| Lines | 497:0–512:1 |
| Program version | Preparation 1 |