amari-enumerative
Enumerative geometry for counting geometric configurations.
Overview
amari-enumerative provides tools for enumerative geometry, the mathematical discipline concerned with counting geometric objects satisfying given conditions. The crate implements intersection theory, Schubert calculus, Littlewood-Richardson coefficients, Gromov-Witten invariants, and tropical curve counting.
Features
- Intersection Theory: Chow rings, intersection multiplicities, Bézout's theorem
- Schubert Calculus: Computations on Grassmannians and flag varieties
- Littlewood-Richardson Coefficients: Complete LR coefficient computation via Young tableaux
- Gromov-Witten Theory: Curve counting and quantum cohomology
- Tropical Geometry: Tropical curve counting via correspondence theorems
- Tropical Schubert Calculus: Fast intersection counting using tropical methods
- Moduli Spaces: Computations on moduli spaces of curves
- Namespace/Capabilities: Geometric access control via Schubert calculus
- WDVV/Kontsevich Recursion: Genus-0 rational curve counting via WDVV equations
- Equivariant Localization: Atiyah-Bott fixed point formula on Grassmannians
- Matroid Theory: Uniform/Schubert matroids, duality, deletion, contraction, Tutte polynomials
- CSM Classes: Chern-Schwartz-MacPherson classes and Euler characteristics
- Operadic Composition: Compose namespaces along input/output interfaces
- Stability Conditions: Bridgeland-type stability and wall-crossing phenomena
- Phantom Types: Compile-time verification of mathematical properties
- GPU Acceleration: Optional GPU support for large computations
- Parallel Computation: Rayon-based parallelization for batch operations
Installation
Add to your Cargo.toml:
[]
= "0.19.0"
Feature Flags
[]
# Default features
= "0.19.0"
# With serialization
= { = "0.19.0", = ["serde"] }
# With GPU acceleration
= { = "0.19.0", = ["gpu"] }
# With parallel computation (Rayon)
= { = "0.19.0", = ["parallel"] }
# With tropical Schubert calculus
= { = "0.19.0", = ["tropical-schubert"] }
# For WASM targets
= { = "0.19.0", = ["wasm"] }
# All performance features
= { = "0.19.0", = ["parallel", "tropical-schubert"] }
Quick Start
use ;
// Create projective 2-space (P²)
let p2 = new;
// Define two curves by degree
let cubic = hypersurface; // Degree 3 curve
let quartic = hypersurface; // Degree 4 curve
// Compute intersection number using Bézout's theorem
let intersection = p2.intersect;
assert_eq!; // 3 × 4 = 12 points
Key Concepts
Schubert Calculus
Count linear subspaces satisfying incidence conditions:
use ;
// How many lines meet 4 general lines in projective 3-space?
// This is computed in Gr(2, 4) with 4 copies of σ_1
let mut calc = new; // Gr(2,4)
let sigma_1 = new.unwrap;
let classes = vec!;
let result = calc.multi_intersect;
assert_eq!; // Answer: 2 lines!
Littlewood-Richardson Coefficients
Compute structure constants for Schubert calculus:
use ;
// Compute c^ν_{λμ} - the LR coefficient
let lambda = new;
let mu = new;
let nu = new;
let coeff = lr_coefficient;
// Expand a Schubert product: σ_λ · σ_μ = Σ c^ν_{λμ} σ_ν
let products = schubert_product;
for in products
Namespace and Capabilities (Geometric Access Control)
Use enumerative geometry for access control:
use ;
// Create a namespace in Gr(2, 4)
let mut ns = full.unwrap;
// Grant capabilities (each is a Schubert condition)
let read = new.unwrap;
let write = new
.unwrap
.requires; // Dependency
ns.grant.unwrap;
ns.grant.unwrap;
// Count valid configurations
let count = ns.count_configurations;
// With 2 capabilities of codimension 1 each, we have dimension 2
Phantom Types for Compile-Time Verification
Zero-cost type markers for mathematical properties:
use ;
// These types encode mathematical properties at the type level:
// - ValidPartition: Partition has been validated (weakly decreasing, positive parts)
// - Semistandard: Tableau satisfies semistandard conditions
// - LatticeWord: Tableau satisfies lattice word (Yamanouchi) condition
// - Transverse: Intersection is transverse (codimensions sum to dimension)
// - FitsInBox: Partition fits in k × (n-k) Grassmannian box
Parallel Batch Operations
When the parallel feature is enabled:
use ;
// Compute many LR coefficients in parallel
let triples = vec!;
let coefficients = lr_coefficients_batch;
// Compute multiple Schubert intersections in parallel
let sigma_1 = new.unwrap;
let batches = vec!;
let results = multi_intersect_batch;
Tropical Schubert Calculus
Fast intersection counting using tropical methods (requires tropical-schubert feature):
use ;
let sigma_1 = new.unwrap;
let classes = vec!;
// Tropical methods give exact answers for many practical cases
let result = tropical_intersection_count;
assert_eq!;
// Check if conditions are satisfiable
let tropical_classes: = classes.iter
.map
.collect;
assert!;
Gromov-Witten Invariants
Count curves in algebraic varieties:
use ;
// Count rational curves of degree d in P²
let gw = new;
let count = gw.compute_with_insertions?;
WDVV/Kontsevich Curve Counting
Count rational curves via Kontsevich's recursion:
use WDVVEngine;
let mut engine = new;
// N_d = number of rational degree-d curves in P² through 3d-1 general points
assert_eq!; // 1 line through 2 points
assert_eq!; // 1 conic through 5 points
assert_eq!; // 12 cubics through 8 points
assert_eq!; // 620 quartics through 11 points
// Required points for dimension constraint: 3d + g - 1
let points = required_point_count; // 14 for degree 5 genus 0
// Table of all computed values
let table = engine.table; // [(1,1), (2,1), (3,12), (4,620), ...]
Equivariant Localization
Compute intersection numbers via the Atiyah-Bott fixed point formula:
use ;
// Create localizer for Gr(2,4) with standard torus weights
let localizer = new;
// Number of T-fixed points = C(n,k)
assert_eq!; // C(4,2) = 6
// Verify σ_1^4 = 2 via localization
let classes = vec!;
let result = localizer.localized_intersection;
assert!;
Matroid Theory
Work with uniform matroids, duality, and rank functions:
use Matroid;
// Create uniform matroid U_{2,4}: every 2-element subset is a basis
let m = uniform;
assert_eq!;
assert_eq!;
assert_eq!; // C(4,2)
// Matroid duality: rank of dual = n - k
let dual = m.dual;
assert_eq!; // 4 - 2
// Deletion and contraction
let deleted = m.delete;
let contracted = m.contract;
Stability Conditions & Wall-Crossing
Bridgeland-type stability and wall-crossing phenomena:
use ;
// Create stability condition on Gr(2,4) with trust level
let condition = new;
// Wall-crossing engine
let engine = new;
let walls = engine.compute_walls;
// Stable count changes at wall-crossing values
let count_before = engine.stable_count_at;
let count_after = engine.stable_count_at;
Tropical Curves
Use tropical geometry for curve counting:
use TropicalCurve;
let curve = new;
let count = curve.tropical_count?;
Modules
| Module | Description |
|---|---|
intersection |
Chow rings, intersection products, Bézout |
schubert |
Schubert calculus on Grassmannians |
littlewood_richardson |
LR coefficients, partitions, Young tableaux |
namespace |
Namespace/Capability types for geometric access control |
phantom |
Compile-time verification phantom types |
gromov_witten |
Curve counting, quantum cohomology |
tropical_curves |
Tropical geometry methods |
tropical_schubert |
Tropical Schubert calculus (feature-gated) |
moduli_space |
Moduli spaces of curves |
higher_genus |
Higher genus curve counting, DT/PT invariants |
geometric_algebra |
Integration with geometric algebra |
performance |
Optimized computation utilities |
wdvv |
WDVV/Kontsevich recursion for rational curve counts |
localization |
Equivariant localization on Grassmannians |
matroid |
Matroid theory: uniform, Schubert, duality, Tutte |
csm |
Chern-Schwartz-MacPherson classes |
operad |
Operadic composition of namespaces |
stability |
Bridgeland stability conditions and wall-crossing |
Mathematical Background
Littlewood-Richardson Rule
The LR coefficient c^ν_{λμ} counts semistandard Young tableaux of skew shape ν/λ with content μ satisfying the lattice word condition:
σ_λ · σ_μ = Σ_ν c^ν_{λμ} σ_ν
Chow Rings
The Chow ring A*(X) captures the intersection theory of a variety X:
A*(P^n) = Z[H] / (H^(n+1))
where H is the hyperplane class.
Schubert Cells
The Grassmannian Gr(k,n) has a cell decomposition by Schubert cells:
Gr(k,n) = ⊔ Ω_λ
indexed by partitions λ ⊂ (n-k)^k.
Gromov-Witten Theory
GW invariants count curves via:
⟨τ_a1(γ1),...,τ_an(γn)⟩_{g,β} = ∫_{[M̄_{g,n}(X,β)]^{vir}} ψ_1^{a1} ev_1*(γ1) ∧ ...
Classic Enumerative Problems
| Problem | Answer |
|---|---|
| Lines through 2 points | 1 |
| Conics through 5 points | 1 |
| Lines meeting 4 general lines in P³ | 2 |
| Rational cubics through 8 points in P² | 12 |
| Lines on a smooth cubic surface | 27 |
| Rational quartics through 11 points in P² | 620 |
| Rational quintics through 14 points in P² | 87,304 |
Performance
- Parallel Computation: Rayon-based parallelization for batch operations
- Tropical Acceleration: Fast counting via tropical correspondence
- GPU Acceleration: WebGPU for large intersection computations
- Sparse Matrices: Efficient representation of Schubert classes
- Batch Processing: Process multiple computations simultaneously
- Caching: LR coefficients and intersection numbers are cached
Contracts and Verification
The crate uses Creusot-style contracts documented in function signatures:
/// Compute LR coefficient c^ν_{λμ}
///
/// # Contract
/// ```text
/// requires: lambda, mu, nu are valid partitions
/// ensures: result >= 0
/// ensures: |nu| != |lambda| + |mu| => result == 0
/// ensures: !nu.contains(lambda) => result == 0
/// ```
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Part of Amari
This crate is part of the Amari mathematical computing library.