Skip to content

Commit 70981dd

Browse files
committed
comment about quadratic complexity in whnfCore
1 parent 43c57be commit 70981dd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Lean/Meta/WHNF.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ private def whnfDelayedAssigned? (f' : Expr) (e : Expr) : MetaM (Option Expr) :=
585585
Assuming `zeta` is enabled, zeta reduce lets. Does not take `zetaUnused` into account.
586586
We put unused logic into `consumeUnusedLet`, since `expandLet` works with expressions with loose bound variables,
587587
and thus determining whether a let variable is used isn't an O(1) operation.
588+
589+
Note: since `expandLet` and `consumeUnusedLet` are separated like this, a consequence is that
590+
in the `+zeta -zetaHave +zetaUnused` configuration, then `whnfCore` has quadratic complexity
591+
when reducing a sequence of alternating `let`s and `have`s where the `let`s are used but the `have`s are unused.
588592
-/
589593
partial def expandLet (e : Expr) (vs : Array Expr) (zetaHave : Bool := true) : Expr :=
590594
if let .letE _ _ v b nondep := e then

0 commit comments

Comments
 (0)