One of our research tools hunts for mathematical facts about fluid flow. It evolves candidate formulas for Navier-Stokes equations, then certifies the survivors with a Lean 4 proof. The evolutionary half edits symbolic expressions through two genetic operators, mutate and crossover. This note covers how that search crashed and why the fix went into the operators rather than into the hardware budget.

What crashed the evolutionary formula search?

There were 2 distinct crash modes:

Both failures came from the shape of the expressions the operators produced, not from the size of the machine they ran on.

Why wouldn't a bigger machine have fixed these crashes?

A recursion error reflects a call-depth limit in the interpreter. It does not reflect a shortage of RAM, so adding memory does nothing for it. For the memory crash, the fix took the opposite approach to buying headroom. It removed the inputs that triggered the crash rather than raising the ceiling they hit. Both crash modes traced back to two structural properties of the expressions, exponent size and nesting depth, so capping those properties was the direct remedy.

What exactly do the two guards check?

Every child an operator produces is checked before it is accepted:

A rejected child is discarded and the operator returns the parent instead. The same guard runs in both mutate and crossover, so neither path can introduce an oversized exponent or an over-deep tree into the population.

In the mutation path, the same rejection check also tests operation count against a limit of 40, labelled as bloat rejection. That limit sits alongside the two guards. It is a general size cap. The two structural guards described here are the ones that address the two crash modes.

Why is the depth check written without recursion?

The depth guard walks the expression tree with an explicit iterative stack. It makes no recursive calls. This choice is load-bearing. A depth check written as a recursive function would be exposed to the same RecursionError it exists to prevent, and it would be exposed at the exact moment a pathologically deep tree arrived. Measuring depth iteratively keeps the guard safe on the inputs it is meant to reject.

Why return the parent instead of raising an error?

Both mutate and crossover are wrapped in a broad exception handler. That handler catches MemoryError from giant powers and silently returns the parent unchanged. A failed edit therefore produces no new child and leaves the run alive. The error does not propagate and terminate the search.

The choice is deliberately quiet. The operator does not retry and does not report the failure. It falls back to an expression that was already in the population. One trade-off is worth watching in general: falling back to the parent can place duplicate expressions in the population, and whether that matters depends on how selection treats repeats.

What should you take from this for your own symbolic search?

The whole fix was two small constants, an iterative tree walk, and a fallback path. It did not involve more memory.