Aether Catalog definitions — Bridges_NeuralCoding_VSAlgebraCore
DefinitionBridges_NeuralCoding_VSAlgebraCoreaether-catalogbridges
Definition bundle for the Aether Catalog module Bridges.NeuralCoding.VSAlgebraCore, transplanted by skeleton subtraction; supplies the types and constants the catalog's theorems import.
Definition code
-- Def bundle generated from Bridges/NeuralCoding/VSAlgebraCore.lean by skeleton subtraction
import Mathlib
/-
VSAlgebra: Algebraic Foundations for Vector-Symbolic Architecture
Bridge: connects near-ring algebra, neural representation capacity,
and symbolic-numeric computation.
-/
open Finset BigOperators
namespace VSAlgebra
/-! ## Core Structure -/
@[ext] structure HDVec (α : Type*) (d : ℕ) where
coord : Fin d → α
namespace HDVec
variable {α : Type*} {d : ℕ}
instance [Inhabited α] : Inhabited (HDVec α d) := ⟨⟨fun _ => default⟩⟩
instance [Zero α] : Zero (HDVec α d) := ⟨⟨fun _ => 0⟩⟩
instance [One α] : One (HDVec α d) := ⟨⟨fun _ => 1⟩⟩
end HDVec
variable {α : Type*} {d : ℕ}
/-- Pointwise addition (superposition). -/
def vSuperpose [Add α] (v w : HDVec α d) : HDVec α d :=
⟨fun i => v.coord i + w.coord i⟩
/-- Pointwise multiplication (Hadamard binding). -/
def vBind [Mul α] (v w : HDVec α d) : HDVec α d :=
⟨fun i => v.coord i * w.coord i⟩
/-! ## Algebraic Properties -/
section Algebra
variable {α : Type*} {d : ℕ}
theorem vBind_comm [CommMonoid α] (v w : HDVec α d) :
vBind v w = vBind w v := by ext i; exact mul_comm _ _
theorem vBind_assoc [Monoid α] (u v w : HDVec α d) :
vBind (vBind u v) w = vBind u (vBind v w) := by ext i; exact mul_assoc _ _ _
theorem vBind_one_left [Monoid α] (v : HDVec α d) :
vBind (1 : HDVec α d) v = v := by ext i; exact one_mul _
theorem vBind_one_right [Monoid α] (v : HDVec α d) :
vBind v (1 : HDVec α d) = v := by ext i; exact mul_one _
end Algebra
/-! ## Bipolar (±1) Vectors -/
section Bipolar
variable {d : ℕ}
def IsBipolar (v : HDVec ℤ d) : Prop := ∀ i : Fin d, v.coord i = 1 ∨ v.coord i = -1
def IsBipolarR (v : HDVec ℝ d) : Prop := ∀ i : Fin d, v.coord i = 1 ∨ v.coord i = -1
end Bipolar
/-! ## Inner Product and Norm -/
section InnerProd
variable {d : ℕ}
def hdInnerProd (v w : HDVec ℝ d) : ℝ := ∑ i : Fin d, v.coord i * w.coord i
def hdNormSq (v : HDVec ℝ d) : ℝ := ∑ i : Fin d, v.coord i ^ 2
end InnerProd
/-! ## Cosine Similarity -/
section Cosine
variable {d : ℕ}
noncomputable def cosineSim (v w : HDVec ℝ d) : ℝ :=
hdInnerProd v w / (Real.sqrt (hdNormSq v) * Real.sqrt (hdNormSq w))
end Cosine
/-! ## Capacity Bounds -/
section Capacity
/-- Capacity bound: d/ε² symbols in d dimensions at error ε.
Application: certified_robustness and post_quantum_security. -/
noncomputable def capacityBound (d : ℕ) (ε : ℝ) : ℝ := (d : ℝ) / ε ^ 2
end Capacity
/-! ## Interference Analysis -/
section Interference
variable {d n : ℕ}
def interferenceSum (symbols : Fin n → HDVec ℝ d) (j : Fin n) : ℝ :=
∑ k : Fin n, if k = j then 0 else hdInnerProd (symbols j) (symbols k)
end Interference
/-! ## Compositional Depth -/
section CompDepth
variable {d : ℕ}
noncomputable def maxCompDepth (d : ℕ) : ℝ := Real.sqrt d
end CompDepth
/-! ## Approximate Near-Ring -/
section ApproxNR
end ApproxNR
/-! ## Group Embedding -/
section GroupEmbed
def embeddingNoise (G : Type*) [Group G] {d : ℕ} (φ : G → HDVec ℤ d) (g h : G) : ℕ :=
(Finset.univ.filter (fun i : Fin d =>
(vBind (φ g) (φ h)).coord i ≠ (φ (g * h)).coord i)).card
def IsPerfectHom (G : Type*) [Group G] {d : ℕ} (φ : G → HDVec ℤ d) : Prop :=
∀ g h : G, vBind (φ g) (φ h) = φ (g * h)
end GroupEmbed
/-! ## Permutation -/
section Perm
variable {α : Type*} {d : ℕ}
def vPermute (k : ℕ) (v : HDVec α d) (hd : 0 < d) : HDVec α d :=
⟨fun i => v.coord ⟨(i.val + k) % d, Nat.mod_lt _ hd⟩⟩
end Perm
/-! ## CommMonoid Instance -/
instance hdVecCommMonoid (d : ℕ) : CommMonoid (HDVec ℤ d) where
mul := vBind; mul_assoc := vBind_assoc; one := 1
one_mul := vBind_one_left; mul_one := vBind_one_right; mul_comm := vBind_comm
instance hdVecCommMonoidReal (d : ℕ) : CommMonoid (HDVec ℝ d) where
mul := vBind; mul_assoc := vBind_assoc; one := 1
one_mul := vBind_one_left; mul_one := vBind_one_right; mul_comm := vBind_comm
/-! ## Hamming Distance -/
section Hamming
variable {d : ℕ}
def hammingDist (v w : HDVec ℤ d) : ℕ :=
(Finset.univ.filter (fun i : Fin d => v.coord i ≠ w.coord i)).card
/-
Triangle inequality for Hamming distance.
-/
end Hamming
/-! ## Scaling Laws -/
end VSAlgebra