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: ShaperOS integration via geometric access control
- 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.18"
Feature Flags
[]
# Default features
= "0.18"
# With serialization
= { = "0.18", = ["serde"] }
# With GPU acceleration
= { = "0.18", = ["gpu"] }
# With parallel computation (Rayon)
= { = "0.18", = ["parallel"] }
# With tropical Schubert calculus
= { = "0.18", = ["tropical-schubert"] }
# For WASM targets
= { = "0.18", = ["wasm"] }
# All performance features
= { = "0.18", = ["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 (ShaperOS Integration)
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?;
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 ShaperOS |
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 |
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 |
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.