Reductions and Broadcasting #
Correctness lemmas for IR nodes whose primary behavior is broadcasting or reduction:
broadcastTo s₁ s₂(explicit broadcasting, used to keep elementwise ops simple),reduceSum axisandreduceMean axis(single-axis reductions),sum(full reduction to a scalar).
Each lemma matches the compiler control flow closely: we validate the parent structure and the
side-condition checks that buildFrom enforces, then construct the compiled forward closure and
show that it matches NN.IR.Graph.evalAt at the current node. We finish by appealing to the shared
buildFrom_denoteAllFrom_finish lemma for the tail of the graph.
Build note: reductions are among the more expensive op proofs because axes change shapes. Lean has to track both the input and output shapes, normalize the axis-side conditions, and then compare the compiled reduction with the IR denotation. Axis/shape arithmetic belongs in small lemmas so the semantic proof can read more like the compiler code.
Correctness lemma for .broadcastTo s₁ s₂ lowering.
Correctness lemma for .reduceSum axis lowering.
Correctness lemma for .reduceMean axis lowering.
Correctness lemma for .sum lowering (sum-reduction to scalar).