Program Rust
dec2flt
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
502 503 /// Converts a decimal string into a floating point number.504 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above505 pub fn dec2flt<506 F: Lemire507 + core::ops::Div<Output = F>508 + core::ops::Mul<Output = F>509 + core::ops::Neg<Output = F>,510 >(511 s: &str,512 ) -> Result<F, ParseFloatError> {513 // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct514 // clause admits exactly the same instances and lets Charon resolve the515 // explicit, source-equivalent final negation.516 // The public function is now exactly the result projection of the single517 // instrumented implementation. No conversion step is duplicated, and518 // discarding the trace cannot affect Rust evaluation or the returned bits.519 dec2flt_with_trace::<F>(s).0520 }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 | 505:0–520:1 |
| Program version | Preparation 2 |