Aether Catalog definitions — Tropical_SATB_TropicalHypergraphCounterpoint
DefinitionTropical_SATB_TropicalHypergraphCounterpointaether-catalogtropical
Definition bundle for the Aether Catalog module Tropical.SATB.TropicalHypergraphCounterpoint, transplanted by skeleton subtraction; supplies the types and constants the catalog's theorems import.
Definition code
-- Def bundle generated from Tropical/SATB/TropicalHypergraphCounterpoint.lean by skeleton subtraction
import Mathlib
/-!
# Tropical Hypergraph Counterpoint for SATB
This module establishes an exact bridge between four-voice (SATB) counterpoint
legality and tropical optimization on weighted hypergraphs.
## Mathematical Content
We model SATB voice leading as a constrained dynamical system on `Fin 4 → ℤ`
and prove three main theorem packages:
### Theorem Package 1: Zero-Locus Characterization
Legal SATB transitions are exactly the zero locus of a nonnegative tropical
penalty functional assembled from six pairwise components (one per unordered
voice pair). This converts Boolean legality into tropical vanishing.
### Theorem Package 2: Shortest-Path Realization
Legal progressions (sequences of chords) are exactly zero-cost paths in the
induced weighted hypergraph. Since all edge weights are nonnegative, legal
paths are globally shortest among all paths with the same endpoints.
### Theorem Package 3: Pairwise Tensor Factorization
The total SATB cost factorizes as a double sum over voice pairs and time steps.
Legality of a full progression is determined entirely by pairwise legality at
each time step, establishing an exact structural decomposition of the 4-voice
problem into coupled 2-voice subproblems.
## Significance
This formalization proves that a high-arity symbolic constraint system (4-voice
counterpoint) admits exact tropical optimization with:
- certifiable legality detection via zero-locus testing,
- shortest-path semantics for legal progressions,
- nontrivial state-space compression via pairwise factorization.
-/
open Finset BigOperators
noncomputable section
/-! ## Core Definitions -/
/-- A voice is one of four SATB parts: Soprano (0), Alto (1), Tenor (2), Bass (3). -/
abbrev Voice := Fin 4
/-- A chord is an assignment of integer pitches to the four voices. -/
def Chord := Voice → ℤ
/-- The six unordered voice pairs `(i, j)` with `i < j`. -/
def unordVoicePairs : Finset (Fin 4 × Fin 4) :=
Finset.univ.filter (fun p => p.1 < p.2)
/-- The interval between two pitches. -/
def interval (a b : ℤ) : ℤ := b - a
/-! ## Pairwise Legality Predicates -/
/-- No parallel fifths between voices `i` and `j`:
If the interval between `v i` and `v j` is a perfect fifth (7 semitones),
then the interval between `w i` and `w j` must differ. -/
def NoParallelFifthsPair (i j : Voice) (v w : Chord) : Prop :=
interval (v i) (v j) = 7 → interval (w i) (w j) ≠ 7
/-- No voice crossing between voices `i` and `j` in chord `w`:
If `i < j` then voice `i` should be at least as high as voice `j`. -/
def NoCrossingPair (i j : Voice) (w : Chord) : Prop :=
i < j → w j ≤ w i
/-- Spacing constraint between voices `i` and `j` in chord `w`:
Adjacent upper voices should be within an octave (12 semitones). -/
def SpacingOKPair (i j : Voice) (w : Chord) : Prop :=
(i.val + 1 = j.val) → i.val < 3 → w i - w j ≤ 12
/-- Combined pairwise legality: all three rules hold for the pair `(i, j)`. -/
def PairLegal (i j : Voice) (v w : Chord) : Prop :=
NoParallelFifthsPair i j v w ∧ NoCrossingPair i j w ∧ SpacingOKPair i j w
instance (i j : Voice) (v w : Chord) : Decidable (NoParallelFifthsPair i j v w) :=
inferInstanceAs (Decidable (_ → _))
instance (i j : Voice) (w : Chord) : Decidable (NoCrossingPair i j w) :=
inferInstanceAs (Decidable (_ → _))
instance (i j : Voice) (w : Chord) : Decidable (SpacingOKPair i j w) :=
inferInstanceAs (Decidable (_ → _))
instance (i j : Voice) (v w : Chord) : Decidable (PairLegal i j v w) :=
inferInstanceAs (Decidable (_ ∧ _ ∧ _))
/-! ## Global Legality -/
/-- No parallel fifths between any pair of voices. -/
def NoParallelFifths (v w : Chord) : Prop :=
∀ ij ∈ unordVoicePairs, NoParallelFifthsPair ij.1 ij.2 v w
/-- No voice crossing in chord `w`. -/
def NoCrossing (w : Chord) : Prop :=
∀ ij ∈ unordVoicePairs, NoCrossingPair ij.1 ij.2 w
/-- All spacing constraints hold in chord `w`. -/
def SpacingOK (w : Chord) : Prop :=
∀ ij ∈ unordVoicePairs, SpacingOKPair ij.1 ij.2 w
/-- A transition from chord `v` to chord `w` is legal if no parallel fifths occur,
no voices cross in `w`, and all spacing constraints hold in `w`. -/
def LegalSATBStep (v w : Chord) : Prop :=
NoParallelFifths v w ∧ NoCrossing w ∧ SpacingOK w
/-! ## Pairwise Penalty Functions -/
/-- Parallel fifths penalty for a voice pair: 1 if violated, 0 if legal. -/
def parallelFifthPenalty_pair (i j : Voice) (v w : Chord) : ℝ :=
if NoParallelFifthsPair i j v w then 0 else 1
/-- Crossing penalty for a voice pair: 1 if violated, 0 if legal. -/
def crossingPenalty_pair (i j : Voice) (w : Chord) : ℝ :=
if NoCrossingPair i j w then 0 else 1
/-- Spacing penalty for a voice pair: 1 if violated, 0 if legal. -/
def spacingPenalty_pair (i j : Voice) (w : Chord) : ℝ :=
if SpacingOKPair i j w then 0 else 1
/-- Combined pairwise penalty: maximum of the three component penalties.
This is the tropical (max-plus) aggregation of constraints for a single pair. -/
def pairPenalty (i j : Voice) (v w : Chord) : ℝ :=
max (parallelFifthPenalty_pair i j v w)
(max (crossingPenalty_pair i j w) (spacingPenalty_pair i j w))
/-- Total penalty over all six voice pairs. -/
def totalPenalty6 (v w : Chord) : ℝ :=
∑ ij ∈ unordVoicePairs, pairPenalty ij.1 ij.2 v w
/-! ## Component Penalty Properties -/
/-! ## Pairwise Penalty Zero-Locus -/
/-! ## Theorem Package 1: Zero-Locus Characterization -/
/-! ## Theorem Package 2: Shortest-Path Realization -/
/-- The cost of a progression is the sum of transition penalties. -/
def ProgressionCost {n : ℕ} (σ : Fin (n + 1) → Chord) : ℝ :=
∑ k : Fin n, totalPenalty6 (σ k.castSucc) (σ k.succ)
/-- A progression is legal if every consecutive transition is legal. -/
def LegalProgression {n : ℕ} (σ : Fin (n + 1) → Chord) : Prop :=
∀ k : Fin n, LegalSATBStep (σ k.castSucc) (σ k.succ)
/-! ## Theorem Package 3: Pairwise Tensor Factorization -/
/-! ## Additional Results: Tropical Structure -/
end