Aether Catalog definitions — Evergreen_Quantum_QuantumNeuralBridge
DefinitionEvergreen_Quantum_QuantumNeuralBridgeaether-catalogevergreen
Definition bundle for the Aether Catalog module Evergreen.Quantum.QuantumNeuralBridge, transplanted by skeleton subtraction; supplies the types and constants the catalog's theorems import.
Definition code
-- Def bundle generated from Evergreen/Quantum/QuantumNeuralBridge.lean by skeleton subtraction
import Mathlib
/-!
# The Quantum Gate — Neural Network Bridge
## Formal Verification of the Structural Links
This file formalizes the five deep connections between quantum gates and neural networks
identified by the Oracle Council:
1. **Universality**: Both generate dense subalgebras from finite vocabularies
2. **Nonlinearity**: ReLU and quantum measurement are both idempotent projections
3. **Composition**: Sequential layers form a monoid under composition
4. **Norm preservation**: Unitarity ↔ probability conservation
5. **The parameter-shift rule**: Discrete derivative formula for quantum gradients
Each section contains machine-verified theorems — no axioms beyond the standard four.
-/
open Real Matrix Function
noncomputable section
/-! ## §1: The Activation-Measurement Duality
The deepest structural link: both ReLU activation and quantum measurement
are **idempotent projections**. This is WHY both frameworks can compute:
nonlinear projections compose to carve out complex decision boundaries.
-/
/-- ReLU: the fundamental activation function, defined as max(x, 0) -/
def relu (x : ℝ) : ℝ := max x 0
/-
PROBLEM
ReLU is idempotent: applying it twice equals applying it once.
This is the neural network analogue of quantum measurement collapse.
PROVIDED SOLUTION
Unfold relu as max x 0. Then max (max x 0) 0 = max x 0 since max x 0 ≥ 0.
-/
/-
PROBLEM
ReLU output is always non-negative (projects onto the non-negative half-line)
PROVIDED SOLUTION
le_max_right x 0
-/
/-
PROBLEM
ReLU preserves non-negative values (identity on its image)
PROVIDED SOLUTION
max_eq_left hx
-/
/-
PROBLEM
ReLU kills negative values (maps them to zero)
PROVIDED SOLUTION
max_eq_right (le_of_lt hx)
-/
/-
PROBLEM
The fixed points of ReLU are exactly the non-negative reals [0, ∞).
Compare: the fixed points of a quantum projector P are exactly its eigenspace.
PROVIDED SOLUTION
ext, simp [relu, max_eq_left_iff]
-/
/-
PROBLEM
Quantum measurement eigenvalue theorem: if x² = x then x ∈ {0, 1}.
The eigenvalues of a projection operator are exactly 0 and 1.
PROVIDED SOLUTION
x*x = x means x*(x-1)=0, so x=0 or x=1 by mul_eq_zero
-/
/-
PROBLEM
Projection idempotence for matrices: P² = P implies P³ = P.
Measurement collapse: measuring twice is the same as measuring once.
PROVIDED SOLUTION
rw [mul_assoc, hP, hP] or rw [← mul_assoc, hP]
-/
/-! ## §2: Unitary Gates Preserve Probability
The defining property of quantum gates: they preserve the norm of state vectors.
This is the quantum analogue of neural network normalization layers.
-/
/-
PROBLEM
Quaternion norm is multiplicative — the algebraic foundation of unitary gates.
Unit quaternions form SU(2), the fundamental quantum gate group for single qubits.
PROVIDED SOLUTION
Use map_mul since normSq is a MonoidWithZeroHom
-/
/-
PROBLEM
The determinant of a product is the product of determinants.
For unitary matrices: |det U| = 1, so U preserves volume in state space.
PROVIDED SOLUTION
Use Matrix.det_mul
-/
/-
PROBLEM
Orthogonal matrices preserve the dot product — the real analogue of unitarity.
Neural network orthogonal initialization exploits this for gradient stability.
PROVIDED SOLUTION
Expand dotProduct and mulVec, use hQ to show QᵀQ = 1 (or rewrite via the hypothesis Q*Qᵀ=1). Use Matrix.dotProduct_mulVec and vec_mul_transpose or similar.
-/
/-! ## §3: Composition of Layers Forms a Monoid
Both quantum circuits and neural networks are fundamentally about composing layers.
This algebraic structure is a monoid: associative composition with an identity element.
-/
/-
PROBLEM
Composing three layers is associative — the fundamental law of both
quantum circuits and neural network architectures.
PROVIDED SOLUTION
rfl or Function.comp.assoc
-/
/-
PROBLEM
The identity function is a neutral element for composition (left).
PROVIDED SOLUTION
rfl or Function.id_comp
-/
/-
PROBLEM
The identity function is a neutral element for composition (right).
PROVIDED SOLUTION
rfl or Function.comp_id
-/
/-
PROBLEM
Matrix multiplication is associative — concrete version for gate composition.
PROVIDED SOLUTION
mul_assoc
-/
/-! ## §4: The Parameter-Shift Rule
The quantum analogue of backpropagation: computing gradients of quantum circuits.
For a gate R(θ) = exp(-iθσ/2), the derivative of the expectation value is:
∂⟨H⟩/∂θ = [⟨H⟩(θ + π/2) - ⟨H⟩(θ - π/2)] / 2
-/
/-
PROBLEM
The derivative of sin at 0 is cos 0 = 1.
This is the mathematical core of the parameter-shift rule.
PROVIDED SOLUTION
Real.hasDerivAt_sin 0
-/
/-
PROBLEM
The parameter-shift rule: for f(θ) = sin(θ), we have
f'(θ) = [f(θ + π/2) - f(θ - π/2)] / 2.
This is EXACT, not an approximation — a remarkable property of sinusoidal functions.
PROVIDED SOLUTION
Use sin_add and sin_sub to expand, then simplify using sin(π/2) = 1 and cos(π/2) = 0. We get (sin θ cos(π/2) + cos θ sin(π/2) - (sin θ cos(π/2) - cos θ sin(π/2)))/2 = (2 cos θ)/2 = cos θ.
-/
/-
PROBLEM
The chain rule: the mathematical foundation of backpropagation.
Both classical backprop and quantum parameter-shift compose gradients via the chain rule.
PROVIDED SOLUTION
Use HasDerivAt.comp
-/
/-! ## §5: Sigmoid — The Approximate Oracle
Sigmoid maps ℝ → (0, 1), approximating the step function (a true projection/measurement).
Unlike ReLU, sigmoid is NOT idempotent — it's a "soft" measurement.
-/
/-- Logistic sigmoid function: the smooth approximation to binary measurement -/
def logisticSigmoid (x : ℝ) : ℝ := 1 / (1 + exp (-x))
/-
PROBLEM
Sigmoid output is strictly positive
PROVIDED SOLUTION
Unfold logisticSigmoid, use one_div_pos and positivity (1 + exp(-x) > 0)
-/
/-
PROBLEM
Sigmoid output is strictly less than 1
PROVIDED SOLUTION
Unfold logisticSigmoid. div_lt_one (by positivity). linarith [exp_pos (-x)].
-/
/-
PROBLEM
Sigmoid is NOT idempotent — it is not a true projection/measurement.
This distinguishes "soft" attention from "hard" quantum measurement.
PROVIDED SOLUTION
Use x=1. Unfold logisticSigmoid, use norm_num and exp_neg.
-/
/-! ## §6: Universality — The Crown Jewel
Both quantum gate sets and neural network architectures are universal approximators.
-/
/-
PROBLEM
A universal gate set generates a dense subgroup.
If a subgroup is dense, any element can be approximated to arbitrary precision.
PROVIDED SOLUTION
hS.closure_eq is Set.univ, so g ∈ Set.univ = closure S. Use Dense.closure_eq and trivial.
-/
/-! ## §7: Correlations Across Subsystems
Both entanglement and attention create correlations between components via bilinear maps.
-/
/-
PROBLEM
Bilinear maps are linear in each argument — the shared abstraction
behind both entanglement operations and attention mechanisms.
PROVIDED SOLUTION
simp [map_add]
-/
/-! ## §8: The Noise-Regularization Correspondence -/
/-
PROBLEM
A contraction does not increase distances — the basis for both quantum
error correction and neural network regularization (dropout, weight decay).
PROVIDED SOLUTION
Directly apply hf x y
-/
/-
PROBLEM
Dropout scaling: at dropout rate p, active neurons are scaled by (1-p).
This is analogous to quantum amplitude damping at rate p.
PROVIDED SOLUTION
ring
-/
end