Aether Catalog definitions — MachineLearning_PosetTheory_TropicalNNBridge
DefinitionMachineLearning_PosetTheory_TropicalNNBridgeaether-catalogmachinelearning
Definition bundle for the Aether Catalog module MachineLearning.PosetTheory.TropicalNNBridge, transplanted by skeleton subtraction; supplies the types and constants the catalog's theorems import.
Definition code
-- Def bundle generated from MachineLearning/PosetTheory/TropicalNNBridge.lean by skeleton subtraction
import Mathlib
/-
# Tropical Geometry of ReLU Neural Networks
This file formalizes the bridge between ReLU neural network decision boundaries
and tropical algebraic geometry. The key insight is that ReLU(x) = max(0, x)
is the fundamental operation of the tropical (max-plus) semiring, so composing
ReLU layers computes tropical rational functions.
## Main Results
* `depth_width_asymmetry` — The exponential gap (w+1)^L ≥ L*w + 1 showing that
depth is strictly more powerful than width for creating activation regions.
* `relu_piecewise_linear_regions` — An L-layer width-w network has at most (w+1)^L
linear regions, with the bound being tight.
* `maslov_dequantization_lower` — Lower bound: max(a_i) ≤ ε * log(∑ exp(a_i/ε))
* `maslov_dequantization_upper` — Upper bound: ε * log(∑ exp(a_i/ε)) ≤ max(a_i) + ε * log(n)
* `tropical_bezout_bridge` — Tropical Bézout: the number of intersection points of
two tropical polynomials of degrees d₁, d₂ is at most d₁ * d₂.
## Mathematical Significance
The depth-width asymmetry theorem quantifies why deep networks are more expressive
than shallow ones: an L-layer network can create exponentially more linear regions
than a single layer with the same total number of neurons. The Maslov dequantization
provides the quantitative bridge between smooth (classical) and piecewise-linear
(tropical) geometry, with the gap ε * log(n) controlling approximation quality.
-/
open Finset BigOperators Real
/-! ## Section 1: Depth-Width Asymmetry
The fundamental combinatorial inequality underlying the expressiveness gap
between deep and shallow ReLU networks. -/
/-
!-- The key inequality (w+1)^L ≥ L*w + 1 is proved by induction on L.
Base case L=0: (w+1)^0 = 1 ≥ 1 = 0*w + 1.
Inductive step: (w+1)^(L+1) = (w+1)*(w+1)^L ≥ (w+1)*(Lw+1) = Lw² + Lw + w + 1 ≥ (L+1)w + 1.
The gap is Lw² which is ≥ 0. -- !--
**Depth-width asymmetry**: A ReLU network with `L` layers of width `w`
can create at least `L * w + 1` linear regions, as `(w + 1) ^ L ≥ L * w + 1`.
This shows depth creates exponentially more expressive power than width.
-/
/-
Strict version: for w ≥ 2 and L ≥ 2, the gap is truly exponential.
-/
/-! ## Section 2: Activation Region Counting
Each layer of a ReLU network with width w partitions its input space into
at most (w+1) regions (each neuron is either active or inactive, plus the
constraint that the resulting regions must be connected). Composing L layers
gives the product bound. -/
/-
The number of activation patterns for a single layer of width w is at most 2^w.
-/
/-
Each layer multiplies the region count by at most (w+1), so L layers give (w+1)^L.
This is the Zaslavsky-type bound for hyperplane arrangements.
-/
/-! ## Section 3: Maslov Dequantization
The Maslov dequantization connects the tropical max operation to the smooth
log-sum-exp function. For ε > 0 and reals a₁, ..., aₙ:
max(a₁, ..., aₙ) ≤ ε * log(∑ exp(aᵢ/ε)) ≤ max(a₁, ..., aₙ) + ε * log(n)
As ε → 0, the smooth approximation converges to the tropical max. -/
/-
!-- The lower bound follows because exp(max(aᵢ)/ε) ≤ ∑ exp(aᵢ/ε),
so max(aᵢ) ≤ ε * log(∑ exp(aᵢ/ε)).
The upper bound follows because each exp(aᵢ/ε) ≤ exp(max(aᵢ)/ε),
so ∑ exp(aᵢ/ε) ≤ n * exp(max(aᵢ)/ε), giving the ε*log(n) gap. -- !--
**Maslov dequantization lower bound** (two-element version):
max(a, b) ≤ ε * log(exp(a/ε) + exp(b/ε)) for ε > 0.
-/
/-
**Maslov dequantization upper bound** (two-element version):
ε * log(exp(a/ε) + exp(b/ε)) ≤ max(a, b) + ε * log 2 for ε > 0.
-/
/-! ## Section 4: Tropical Bézout Bridge
The classical Bézout theorem states that two algebraic curves of degrees d₁, d₂
have at most d₁ * d₂ intersection points. The tropical analog bounds the number
of "bend points" where two piecewise-linear functions (tropical polynomials)
intersect. For ReLU networks, this bounds the complexity of decision boundaries. -/
/-- A tropical polynomial in one variable is a piecewise-linear function
with integer slopes. Its "degree" is the total variation of slopes. -/
structure TropicalPoly1 where
/-- Breakpoints where the slope changes, in increasing order -/
breakpoints : List ℝ
/-- Slopes between breakpoints. Length = breakpoints.length + 1 -/
slopes : List ℤ
/-- The slopes list has length breakpoints.length + 1 -/
slopes_len : slopes.length = breakpoints.length + 1
/-- The tropical degree of a 1D tropical polynomial is the total slope variation. -/
noncomputable def TropicalPoly1.degree (p : TropicalPoly1) : ℕ :=
p.breakpoints.length
/-! ## Section 5: ReLU-Tropical Connection
ReLU(x) = max(0, x) is literally the tropical addition of 0 and x in the
max-plus semiring. This section formalizes this connection. -/
/-
Composing two ReLU operations: max(0, max(0, x) + b) = max(0, max(b, x + b))
-/
/-
Two-layer ReLU network region bound: composing two layers of widths w₁, w₂
gives at most (w₁+1)*(w₂+1) regions. Since (w₁+1)*(w₂+1) ≥ (w₁+w₂)+1,
depth is always at least as powerful as width.
-/
/-! ## Section 6: Sharp Depth Separation
The depth-width asymmetry becomes dramatic for specific parameter choices.
This section gives concrete quantitative examples. -/
/-
The ratio (w+1)^L / (Lw+1) grows exponentially in L for w ≥ 1.
-/