You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deffoldToNat (_ : Bool) (a : Expr) : Option Expr := do
let n ← getNumLit a
return mkRawNatLit n
defuintFoldToNatFns : List (Name × UnFoldFn) :=
numScalarTypes.foldl (fun r info => (info.toNatFn, foldToNat) :: r) []
It performs constant folding for UIntN.toNat using getNumLit, but getNumLit recognizes expressions like UIntN.ofNat M where M is larger than the bit size without performing modular reduction.
This results in a miscompilation / native_reduce proof of false:
This code is incorrect:
lean4/src/Lean/Compiler/ConstFolding.lean
Lines 50 to 53 in 8bbb015
lean4/src/Lean/Compiler/ConstFolding.lean
Lines 196 to 201 in 8bbb015
It performs constant folding for
UIntN.toNat
usinggetNumLit
, butgetNumLit
recognizes expressions likeUIntN.ofNat M
whereM
is larger than the bit size without performing modular reduction.This results in a miscompilation /
native_reduce
proof of false:Reported on Zulip.
The text was updated successfully, but these errors were encountered: