Let's open this black box a bit in order to understand what exactly is going on in the Apache SystemML optimizer. The first thing that the engine does is a compile step on the DSL. So first, syntax checking, then live variable analysis in order to determine which intermediate results are still needed, and finally a semantic check.