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
Currently, a let is always folded if the bound variable occurs at most once. But this is incorrect if the variable occurs under a lambda-abstraction, because the lambda may (and typically will) be passed to another function and called multiple times. This can duplicate the computation of the let-bound value, potentially even changing the asymptotic complexity.
Example:
f (lst1 lst2 : List Nat) : Bool :=
let s := sum lst2
in
all (x in lst1)
x > s;
The let-folding folds the s resulting in:
f (lst1 lst2 : List Nat) : Bool :=
all (x in lst1)
x > sum lst2;
The computation of sum lst2 was moved inside the loop.
The text was updated successfully, but these errors were encountered:
Currently, a
let
is always folded if the bound variable occurs at most once. But this is incorrect if the variable occurs under a lambda-abstraction, because the lambda may (and typically will) be passed to another function and called multiple times. This can duplicate the computation of the let-bound value, potentially even changing the asymptotic complexity.Example:
The let-folding folds the
s
resulting in:The computation of
sum lst2
was moved inside the loop.The text was updated successfully, but these errors were encountered: