Symbolic simplificationof a neural network means expressing the network’s operations—especially with nonlinearities like ReLU—asexplicit symbolic expressionsusing algebra, logic, and piecewise definitions. It’s a way torewritethe network's behavior in a human-readable or analyzable form without evaluating it numerically.
This is especially useful when you want to:
Understand how a network transforms inputs,
Prove properties (e.g. safety, fairness),
Optimize or compress it,
Use it in symbolic solvers or formal verification.
Understand how a network transforms inputs,
Prove properties (e.g. safety, fairness),
Optimize or compress it,
Use it in symbolic solvers or formal verification.
What It Involves
For a feedforward ReLU network:
Unroll the layers:Write out every layer’s computation:z1=W1x+b1,a1=ReLU(z1=W1x+z1=W1x+b1,a1=ReLU(z1,z1=W1x+b1,a1=ReLU(z1=ReLU(z1=W1x+b1,a1=ReLU(z1)z_1 = W_1 x + b_1,\quad a_1 = \text{ReLU}(z_1)z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2x+z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2,z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=ReLU(z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2)z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=W2a1+z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2,z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=ReLU(z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2)z_2 = W_2 a_1 + b_2,\quad a_2 = \text{ReLU}(z_2)z2=W2a1+b2,a2=ReLU(z2=z2=W2a1+b2,a2=ReLU(z2z2=W2a1+b2,a2=ReLU(z2+z2=W2a1+b2,a2=ReLU(z2,z2=W2a1+b2,a2=ReLU(z2=ReLU(z2=W2a1+b2,a2=ReLU(z2)and so on.
Write out every layer’s computation:z1=W1x+b1,a1=ReLU(z1=W1x+z1=W1x+b1,a1=ReLU(z1,z1=W1x+b1,a1=ReLU(z1=ReLU(z1=W1x+b1,a1=ReLU(z1)z_1 = W_1 x + b_1,\quad a_1 = \text{ReLU}(z_1)z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2x+z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2,z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=ReLU(z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2)z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=W2a1+z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2,z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=ReLU(z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2)z_2 = W_2 a_1 + b_2,\quad a_2 = \text{ReLU}(z_2)z2=W2a1+b2,a2=ReLU(z2=z2=W2a1+b2,a2=ReLU(z2z2=W2a1+b2,a2=ReLU(z2+z2=W2a1+b2,a2=ReLU(z2,z2=W2a1+b2,a2=ReLU(z2=ReLU(z2=W2a1+b2,a2=ReLU(z2)and so on.
Substitute recursively:Replacea1a_1a1in the expression fora2a_2a2, and so on, until you have:f(x)=ReLU(W2⋅ReLU(W1x+b1)+b2)+b1)+b2)f(x) = \text{ReLU}(W_2 \cdot \text{ReLU}(W_1 x + b_1) + b_2)f(x)=ReLU(W2⋅ReLU(W1x+b1)+b2x+W1x+b1)+b2)+W1x+b1)+b2)
Replacea1a_1a1in the expression fora2a_2a2, and so on, until you have:f(x)=ReLU(W2⋅ReLU(W1x+b1)+b2)+b1)+b2)f(x) = \text{ReLU}(W_2 \cdot \text{ReLU}(W_1 x + b_1) + b_2)f(x)=ReLU(W2⋅ReLU(W1x+b1)+b2x+W1x+b1)+b2)+W1x+b1)+b2)
Apply symbolic logic to handle ReLUs:Because ReLU is piecewise:ReLU(x)=max(0,x)\text{ReLU}(x) = \max(0, x)ReLU(x)=max(0,x)You can represent this withcase distinctions:f(x)={W2(W1x+b1)+b2ifW1x+b1(W1x+W2(W1x+b1)+b2ifW1x+b1)+b2ifW1x+W2(W1x+b1)+b2ifW1x+b1>0…(other cases)f(x) = \begin{cases}
W_2(W_1x + b_1) + b_2 & \text{if } W_1x + b_1 > 0 \
\dots & \text{(other cases)}
\end{cases}f(x)={W2(W1x+b1)+b2(W2(W1x+b1)+b2x+W2(W1x+b1)+b2)+W2(W1x+b1)+b2…ifW1x+b1>0(other cases)You now have apiecewise symbolic functionwhere the cases depend on input conditions.
Because ReLU is piecewise:ReLU(x)=max(0,x)\text{ReLU}(x) = \max(0, x)ReLU(x)=max(0,x)
You can represent this withcase distinctions:f(x)={W2(W1x+b1)+b2ifW1x+b1(W1x+W2(W1x+b1)+b2ifW1x+b1)+b2ifW1x+W2(W1x+b1)+b2ifW1x+b1>0…(other cases)f(x) = \begin{cases}
W_2(W_1x + b_1) + b_2 & \text{if } W_1x + b_1 > 0 \
\dots & \text{(other cases)}
\end{cases}f(x)={W2(W1x+b1)+b2(W2(W1x+b1)+b2x+W2(W1x+b1)+b2)+W2(W1x+b1)+b2…ifW1x+b1>0(other cases)
Unroll the layers:
Write out every layer’s computation:z1=W1x+b1,a1=ReLU(z1=W1x+z1=W1x+b1,a1=ReLU(z1,z1=W1x+b1,a1=ReLU(z1=ReLU(z1=W1x+b1,a1=ReLU(z1)z_1 = W_1 x + b_1,\quad a_1 = \text{ReLU}(z_1)z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2x+z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2,z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=ReLU(z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2)z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=W2a1+z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2,z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2=ReLU(z1=W1x+b1,a1=ReLU(z1)z2=W2a1+b2,a2=ReLU(z2)z_2 = W_2 a_1 + b_2,\quad a_2 = \text{ReLU}(z_2)z2=W2a1+b2,a2=ReLU(z2=z2=W2a1+b2,a2=ReLU(z2z2=W2a1+b2,a2=ReLU(z2+z2=W2a1+b2,a2=ReLU(z2,z2=W2a1+b2,a2=ReLU(z2=ReLU(z2=W2a1+b2,a2=ReLU(z2)and so on.
Write out every layer’s computation:
and so on.
Substitute recursively:
Replacea1a_1a1in the expression fora2a_2a2, and so on, until you have:f(x)=ReLU(W2⋅ReLU(W1x+b1)+b2)+b1)+b2)f(x) = \text{ReLU}(W_2 \cdot \text{ReLU}(W_1 x + b_1) + b_2)f(x)=ReLU(W2⋅ReLU(W1x+b1)+b2x+W1x+b1)+b2)+W1x+b1)+b2)
Replacea1a_1a1in the expression fora2a_2a2, and so on, until you have:
Apply symbolic logic to handle ReLUs:
Because ReLU is piecewise:ReLU(x)=max(0,x)\text{ReLU}(x) = \max(0, x)ReLU(x)=max(0,x)
You can represent this withcase distinctions:f(x)={W2(W1x+b1)+b2ifW1x+b1(W1x+W2(W1x+b1)+b2ifW1x+b1)+b2ifW1x+W2(W1x+b1)+b2ifW1x+b1>0…(other cases)f(x) = \begin{cases}
W_2(W_1x + b_1) + b_2 & \text{if } W_1x + b_1 > 0 \
\dots & \text{(other cases)}
\end{cases}f(x)={W2(W1x+b1)+b2(W2(W1x+b1)+b2x+W2(W1x+b1)+b2)+W2(W1x+b1)+b2…ifW1x+b1>0(other cases)
Because ReLU is piecewise:
You can represent this withcase distinctions:
You now have apiecewise symbolic functionwhere the cases depend on input conditions.
Why It’s Powerful
You can deriveexact decision boundariesthe network is learning.
You can identifyredundant neuronsor dead ReLUs.
You can plug this intoSMT solversorsymbolic math tools(e.g. Z3, SymPy, ).
You can performinterval or constraint-based analysis(e.g., check that the output is bounded for all inputs in a range).
You can deriveexact decision boundariesthe network is learning.
You can identifyredundant neuronsor dead ReLUs.
You can plug this intoSMT solversorsymbolic math tools(e.g. Z3, SymPy, ).
You can performinterval or constraint-based analysis(e.g., check that the output is bounded for all inputs in a range).
When It’s Practical
Small to medium networks
ReLU (or other piecewise linear) activations
When inputs lie within abounded domain
In applications like:Adversarial robustnessExplainabilityNeural network verification (e.g., for autonomous vehicles)
Adversarial robustness
Explainability
Neural network verification (e.g., for autonomous vehicles)
Small to medium networks
ReLU (or other piecewise linear) activations
When inputs lie within abounded domain
In applications like:
Adversarial robustness
Explainability
Neural network verification (e.g., for autonomous vehicles)
Adversarial robustness
Explainability
Neural network verification (e.g., for autonomous vehicles)
Want a Concrete Example?
I can show you how to symbolically simplify a tiny ReLU network, like:
and write it as a piecewise function. Would you like that?