use oxilean_kernel::{BinderInfo, Declaration, Environment, Expr, Level, Name};
use super::types::{
CartanSubalgebra, CartanSubalgebraData, DynkinDiagram, ExponentialMap, HeckeAlgebra,
InvariantTheory, KillingForm, LeviDecomposition, LieAlgebra, LieAlgebraElement, LieBracket,
LieGroup, LieGroupElement, LieGroupHom, LieRepresentation, NilpotentOrbit, NilpotentOrbitData,
QuantumGroup, Root, RootSystem, SolvableLieAlgebra, StructureConstants, VermaModule,
WeightLattice, WeylCharacterFormula,
};
pub fn app(f: Expr, a: Expr) -> Expr {
Expr::App(Box::new(f), Box::new(a))
}
pub fn app2(f: Expr, a: Expr, b: Expr) -> Expr {
app(app(f, a), b)
}
pub fn cst(s: &str) -> Expr {
Expr::Const(Name::str(s), vec![])
}
pub fn prop() -> Expr {
Expr::Sort(Level::zero())
}
pub fn type0() -> Expr {
Expr::Sort(Level::succ(Level::zero()))
}
pub fn pi(bi: BinderInfo, name: &str, dom: Expr, body: Expr) -> Expr {
Expr::Pi(bi, Name::str(name), Box::new(dom), Box::new(body))
}
pub fn arrow(a: Expr, b: Expr) -> Expr {
pi(BinderInfo::Default, "_", a, b)
}
pub fn nat_ty() -> Expr {
cst("Nat")
}
pub fn real_ty() -> Expr {
cst("Real")
}
pub fn bool_ty() -> Expr {
cst("Bool")
}
pub fn int_ty() -> Expr {
cst("Int")
}
pub fn lie_algebra_ty() -> Expr {
type0()
}
pub fn lie_bracket_ty() -> Expr {
arrow(type0(), arrow(type0(), type0()))
}
pub fn lie_algebra_element_ty() -> Expr {
arrow(type0(), type0())
}
pub fn cartan_subalgebra_ty() -> Expr {
arrow(type0(), type0())
}
pub fn structure_constants_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn lie_group_ty() -> Expr {
type0()
}
pub fn lie_group_element_ty() -> Expr {
arrow(type0(), type0())
}
pub fn exp_map_ty() -> Expr {
arrow(type0(), type0())
}
pub fn adjoint_rep_ty() -> Expr {
arrow(type0(), arrow(type0(), type0()))
}
pub fn root_system_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn root_ty() -> Expr {
arrow(type0(), type0())
}
pub fn dynkin_diagram_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn weight_lattice_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn lie_representation_ty() -> Expr {
arrow(type0(), arrow(nat_ty(), type0()))
}
pub fn weyl_character_formula_ty() -> Expr {
arrow(type0(), type0())
}
pub fn killing_form_ty() -> Expr {
arrow(type0(), type0())
}
pub fn jacobi_identity_ty() -> Expr {
let g = type0();
arrow(
g,
arrow(real_ty(), arrow(real_ty(), arrow(real_ty(), prop()))),
)
}
pub fn cartan_criterion_ty() -> Expr {
arrow(type0(), prop())
}
pub fn ado_theorem_ty() -> Expr {
arrow(type0(), arrow(nat_ty(), prop()))
}
pub fn lie_theorem_ty() -> Expr {
arrow(type0(), prop())
}
pub fn engel_theorem_ty() -> Expr {
arrow(type0(), prop())
}
pub fn weyl_theorem_ty() -> Expr {
arrow(type0(), arrow(type0(), prop()))
}
pub fn weyl_character_formula_ty_theorem() -> Expr {
arrow(type0(), arrow(type0(), real_ty()))
}
pub fn bch_formula_ty() -> Expr {
arrow(type0(), arrow(type0(), type0()))
}
pub fn killing_form_signature_ty() -> Expr {
arrow(type0(), arrow(int_ty(), prop()))
}
pub fn complete_reducibility_ty() -> Expr {
arrow(type0(), arrow(type0(), prop()))
}
pub fn character_ty() -> Expr {
arrow(type0(), arrow(type0(), type0()))
}
pub fn schur_lemma_ty() -> Expr {
arrow(type0(), arrow(type0(), prop()))
}
pub fn verma_module_ty() -> Expr {
arrow(type0(), type0())
}
pub fn bgg_category_o_ty() -> Expr {
arrow(type0(), type0())
}
pub fn bgg_resolution_ty() -> Expr {
arrow(type0(), arrow(nat_ty(), type0()))
}
pub fn kl_polynomial_ty() -> Expr {
arrow(type0(), arrow(type0(), arrow(nat_ty(), int_ty())))
}
pub fn canonical_basis_ty() -> Expr {
arrow(type0(), type0())
}
pub fn kl_conjecture_ty() -> Expr {
arrow(type0(), arrow(type0(), prop()))
}
pub fn quantum_group_ty() -> Expr {
arrow(real_ty(), arrow(type0(), type0()))
}
pub fn quantum_uea_ty() -> Expr {
arrow(real_ty(), arrow(type0(), type0()))
}
pub fn r_matrix_ty() -> Expr {
arrow(type0(), arrow(type0(), arrow(type0(), type0())))
}
pub fn hopf_algebra_ty() -> Expr {
arrow(type0(), type0())
}
pub fn drinfeld_jimbo_ty() -> Expr {
arrow(real_ty(), arrow(type0(), type0()))
}
pub fn affine_lie_algebra_ty() -> Expr {
arrow(type0(), type0())
}
pub fn kac_moody_algebra_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn generalized_cartan_matrix_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), int_ty()))
}
pub fn affine_level_ty() -> Expr {
arrow(type0(), int_ty())
}
pub fn integrable_hwm_ty() -> Expr {
arrow(type0(), arrow(nat_ty(), type0()))
}
pub fn virasoro_algebra_ty() -> Expr {
type0()
}
pub fn central_charge_ty() -> Expr {
arrow(type0(), real_ty())
}
pub fn virasoro_hw_module_ty() -> Expr {
arrow(real_ty(), arrow(real_ty(), type0()))
}
pub fn d_module_ty() -> Expr {
arrow(type0(), type0())
}
pub fn perverse_sheaf_ty() -> Expr {
arrow(type0(), type0())
}
pub fn bb_localization_ty() -> Expr {
arrow(type0(), prop())
}
pub fn intersection_cohomology_ty() -> Expr {
arrow(type0(), arrow(nat_ty(), type0()))
}
pub fn lie_superalgebra_ty() -> Expr {
arrow(type0(), type0())
}
pub fn super_lie_bracket_ty() -> Expr {
arrow(type0(), arrow(type0(), arrow(type0(), type0())))
}
pub fn lie_super_rep_ty() -> Expr {
arrow(type0(), arrow(type0(), type0()))
}
pub fn hecke_algebra_ty() -> Expr {
arrow(real_ty(), arrow(type0(), type0()))
}
pub fn hecke_module_ty() -> Expr {
arrow(type0(), type0())
}
pub fn crystal_basis_ty() -> Expr {
arrow(type0(), type0())
}
pub fn crystal_graph_ty() -> Expr {
arrow(type0(), type0())
}
pub fn crystal_operators_ty() -> Expr {
arrow(nat_ty(), arrow(type0(), type0()))
}
pub fn geometric_satake_ty() -> Expr {
arrow(type0(), prop())
}
pub fn langlands_dual_ty() -> Expr {
arrow(type0(), type0())
}
pub fn langlands_duality_ty() -> Expr {
arrow(type0(), prop())
}
pub fn nilpotent_orbit_ty() -> Expr {
arrow(type0(), type0())
}
pub fn springer_resolution_ty() -> Expr {
arrow(type0(), type0())
}
pub fn springer_correspondence_ty() -> Expr {
arrow(type0(), prop())
}
pub fn slodowy_slice_ty() -> Expr {
arrow(type0(), arrow(type0(), type0()))
}
pub fn kirillov_orbit_method_ty() -> Expr {
arrow(type0(), prop())
}
pub fn coadjoint_orbit_ty() -> Expr {
arrow(type0(), type0())
}
pub fn kks_symplectic_form_ty() -> Expr {
arrow(type0(), type0())
}
pub fn loop_group_ty() -> Expr {
arrow(type0(), type0())
}
pub fn central_extension_ty() -> Expr {
arrow(type0(), type0())
}
pub fn two_cocycle_ty() -> Expr {
arrow(type0(), arrow(type0(), arrow(type0(), type0())))
}
pub fn algebraic_group_ty() -> Expr {
type0()
}
pub fn borel_subgroup_ty() -> Expr {
arrow(type0(), type0())
}
pub fn flag_variety_ty() -> Expr {
arrow(type0(), type0())
}
pub fn schubert_variety_ty() -> Expr {
arrow(type0(), arrow(type0(), type0()))
}
pub fn algebraic_group_rep_ty() -> Expr {
arrow(type0(), arrow(nat_ty(), type0()))
}
pub fn build_lie_theory_env(env: &mut Environment) {
let axioms: &[(&str, Expr)] = &[
("LieAlgebra", lie_algebra_ty()),
("LieBracket", lie_bracket_ty()),
("LieAlgebraElement", lie_algebra_element_ty()),
("CartanSubalgebra", cartan_subalgebra_ty()),
("StructureConstants", structure_constants_ty()),
("LieGroup", lie_group_ty()),
("LieGroupElement", lie_group_element_ty()),
("ExponentialMap", exp_map_ty()),
("AdjointRep", adjoint_rep_ty()),
("RootSystem", root_system_ty()),
("Root", root_ty()),
("DynkinDiagram", dynkin_diagram_ty()),
("WeightLattice", weight_lattice_ty()),
("LieRepresentation", lie_representation_ty()),
("WeylCharacterFormula", weyl_character_formula_ty()),
("KillingForm", killing_form_ty()),
("AlgebraAn", arrow(nat_ty(), type0())),
("AlgebraBn", arrow(nat_ty(), type0())),
("AlgebraCn", arrow(nat_ty(), type0())),
("AlgebraDn", arrow(nat_ty(), type0())),
("AlgebraG2", type0()),
("AlgebraF4", type0()),
("AlgebraE6", type0()),
("AlgebraE7", type0()),
("AlgebraE8", type0()),
("GroupGL", arrow(nat_ty(), type0())),
("GroupSL", arrow(nat_ty(), type0())),
("GroupO", arrow(nat_ty(), type0())),
("GroupSO", arrow(nat_ty(), type0())),
("GroupU", arrow(nat_ty(), type0())),
("GroupSU", arrow(nat_ty(), type0())),
("GroupSp", arrow(nat_ty(), type0())),
("IsSimple", arrow(type0(), prop())),
("IsSemisimple", arrow(type0(), prop())),
("IsAbelian", arrow(type0(), prop())),
("IsNilpotent", arrow(type0(), prop())),
("IsSolvable", arrow(type0(), prop())),
("IsCompact", arrow(type0(), prop())),
("IsConnected", arrow(type0(), prop())),
("IsSimplyConnected", arrow(type0(), prop())),
("Rank", arrow(type0(), nat_ty())),
("Dimension", arrow(type0(), nat_ty())),
("HighestRoot", arrow(type0(), type0())),
("WeylGroup", arrow(type0(), type0())),
("WeylDimFormula", arrow(type0(), arrow(type0(), nat_ty()))),
("jacobi_identity", jacobi_identity_ty()),
("cartan_criterion", cartan_criterion_ty()),
("ado_theorem", ado_theorem_ty()),
("lie_theorem", lie_theorem_ty()),
("engel_theorem", engel_theorem_ty()),
("weyl_theorem", weyl_theorem_ty()),
(
"weyl_character_formula",
weyl_character_formula_ty_theorem(),
),
("bch_formula", bch_formula_ty()),
("killing_form_signature", killing_form_signature_ty()),
("LieGroupLieAlgebra", arrow(type0(), type0())),
("CenterOf", arrow(type0(), type0())),
("DerivedAlgebra", arrow(type0(), type0())),
(
"LowerCentralSeries",
arrow(type0(), arrow(nat_ty(), type0())),
),
(
"UpperCentralSeries",
arrow(type0(), arrow(nat_ty(), type0())),
),
("RootOfUnity", arrow(nat_ty(), type0())),
("CoxeterNumber", arrow(type0(), nat_ty())),
("DualCoxeterNumber", arrow(type0(), nat_ty())),
("CompleteReducibility", complete_reducibility_ty()),
("RepCharacter", character_ty()),
("SchurLemma", schur_lemma_ty()),
("VermaModule", verma_module_ty()),
("BggCategoryO", bgg_category_o_ty()),
("BggResolution", bgg_resolution_ty()),
("KLPolynomial", kl_polynomial_ty()),
("CanonicalBasis", canonical_basis_ty()),
("KLConjecture", kl_conjecture_ty()),
("QuantumGroup", quantum_group_ty()),
("QuantumUEA", quantum_uea_ty()),
("RMatrix", r_matrix_ty()),
("HopfAlgebra", hopf_algebra_ty()),
("DrinfeldJimbo", drinfeld_jimbo_ty()),
("AffineLieAlgebra", affine_lie_algebra_ty()),
("KacMoodyAlgebra", kac_moody_algebra_ty()),
("GeneralizedCartanMatrix", generalized_cartan_matrix_ty()),
("AffineLevel", affine_level_ty()),
("IntegrableHWM", integrable_hwm_ty()),
("VirasoroAlgebra", virasoro_algebra_ty()),
("CentralCharge", central_charge_ty()),
("VirasoroHWModule", virasoro_hw_module_ty()),
("DModule", d_module_ty()),
("PerverseSheaf", perverse_sheaf_ty()),
("BBLocalization", bb_localization_ty()),
("IntersectionCohomology", intersection_cohomology_ty()),
("LieSuperalgebra", lie_superalgebra_ty()),
("SuperLieBracket", super_lie_bracket_ty()),
("LieSuperRep", lie_super_rep_ty()),
("HeckeAlgebra", hecke_algebra_ty()),
("HeckeModule", hecke_module_ty()),
("CrystalBasis", crystal_basis_ty()),
("CrystalGraph", crystal_graph_ty()),
("CrystalOperators", crystal_operators_ty()),
("GeometricSatake", geometric_satake_ty()),
("LanglandsDual", langlands_dual_ty()),
("LanglandsDuality", langlands_duality_ty()),
("NilpotentOrbit", nilpotent_orbit_ty()),
("SpringerResolution", springer_resolution_ty()),
("SpringerCorrespondence", springer_correspondence_ty()),
("SlodowlySlice", slodowy_slice_ty()),
("KirillovOrbitMethod", kirillov_orbit_method_ty()),
("CoadjointOrbit", coadjoint_orbit_ty()),
("KKSSymplecticForm", kks_symplectic_form_ty()),
("LoopGroup", loop_group_ty()),
("CentralExtension", central_extension_ty()),
("TwoCocycle", two_cocycle_ty()),
("AlgebraicGroup", algebraic_group_ty()),
("BorelSubgroup", borel_subgroup_ty()),
("FlagVariety", flag_variety_ty()),
("SchubertVariety", schubert_variety_ty()),
("AlgebraicGroupRep", algebraic_group_rep_ty()),
];
for (name, ty) in axioms {
env.add(Declaration::Axiom {
name: Name::str(*name),
univ_params: vec![],
ty: ty.clone(),
})
.ok();
}
}
pub fn su2_generators() -> [Vec<Vec<f64>>; 3] {
let half = 0.5_f64;
let t1 = vec![vec![0.0, half], vec![-half, 0.0]];
let t2 = vec![vec![0.0, half], vec![half, 0.0]];
let t3 = vec![vec![half, 0.0], vec![0.0, -half]];
[t1, t2, t3]
}
pub fn so3_generators() -> [Vec<Vec<f64>>; 3] {
let l1 = vec![
vec![0.0, 0.0, 0.0],
vec![0.0, 0.0, -1.0],
vec![0.0, 1.0, 0.0],
];
let l2 = vec![
vec![0.0, 0.0, 1.0],
vec![0.0, 0.0, 0.0],
vec![-1.0, 0.0, 0.0],
];
let l3 = vec![
vec![0.0, -1.0, 0.0],
vec![1.0, 0.0, 0.0],
vec![0.0, 0.0, 0.0],
];
[l1, l2, l3]
}
pub fn weyl_character_formula_statement() -> &'static str {
"ch(V_λ) = Σ_{w ∈ W} sgn(w) e^{w(λ+ρ)} / Σ_{w ∈ W} sgn(w) e^{w(ρ)}, \
where ρ = (1/2) Σ_{α>0} α is the Weyl vector."
}
pub fn baker_campbell_hausdorff_series(terms: usize) -> Vec<String> {
let all_terms = vec![
"X".to_string(),
"Y".to_string(),
"(1/2)[X,Y]".to_string(),
"(1/12)[X,[X,Y]]".to_string(),
"-(1/12)[Y,[X,Y]]".to_string(),
"-(1/24)[Y,[X,[X,Y]]]".to_string(),
"(1/360)[X,[X,[X,[X,Y]]]]".to_string(),
"(1/360)[Y,[Y,[Y,[Y,X]]]]".to_string(),
"-(1/120)[Y,[X,[X,[X,Y]]]]".to_string(),
"-(1/120)[X,[Y,[Y,[Y,X]]]]".to_string(),
];
all_terms.into_iter().take(terms).collect()
}
pub fn su2_structure_constants() -> StructureConstants {
let mut sc = StructureConstants::new(3);
sc.algebra = "su(2)".to_string();
sc.f[0][1][2] = 1.0;
sc.f[1][2][0] = 1.0;
sc.f[2][0][1] = 1.0;
sc.f[1][0][2] = -1.0;
sc.f[2][1][0] = -1.0;
sc.f[0][2][1] = -1.0;
sc
}
pub fn su3_structure_constants() -> StructureConstants {
let mut sc = StructureConstants::new(8);
sc.algebra = "su(3)".to_string();
let mut set = |a: usize, b: usize, c: usize, v: f64| {
sc.f[a][b][c] = v;
sc.f[b][a][c] = -v;
};
set(0, 1, 2, 1.0);
set(0, 3, 6, 0.5);
set(0, 5, 4, 0.5);
set(1, 3, 5, 0.5);
set(1, 4, 6, 0.5);
set(2, 3, 4, 0.5);
set(2, 6, 5, 0.5);
let s3h = 3.0_f64.sqrt() / 2.0;
set(3, 4, 7, s3h);
set(5, 6, 7, s3h);
sc
}
pub fn cartan_criterion_statement() -> &'static str {
"Cartan's Criterion: A Lie algebra g is semisimple if and only if its \
Killing form B(X,Y) = Tr(ad X ∘ ad Y) is non-degenerate. \
Moreover g is solvable if and only if B(X,[Y,Z]) = 0 for all X ∈ g, \
Y,Z ∈ [g,g] (i.e. B vanishes on [g,g] × g)."
}
#[cfg(test)]
mod extended_lie_tests {
use super::*;
#[test]
fn test_cartan_subalgebra() {
let h = CartanSubalgebraData::semisimple("sl_3", 2);
assert!(h.is_abelian);
assert_eq!(h.rank, 2);
assert!(h.weight_space_description().contains("Cartan"));
}
#[test]
fn test_lie_group_hom() {
let adj = LieGroupHom::adjoint("G");
assert!(adj.lie_algebra_map().contains("d phi"));
}
#[test]
fn test_solvable() {
let heis = SolvableLieAlgebra::heisenberg();
assert!(heis.is_nilpotent);
assert!(!heis.is_abelian);
assert!(heis.lies_theorem_applies(true));
assert!(!heis.lies_theorem_applies(false));
}
#[test]
fn test_levi() {
let ld = LeviDecomposition::new("g", "rad(g)", "s");
assert!(ld.levi_is_semisimple());
assert!(ld.description().contains("Levi"));
}
#[test]
fn test_invariant_theory() {
let inv = InvariantTheory::sl_n_invariants(3);
assert_eq!(inv.num_invariants(), 2);
assert!(inv.chevalley_description().contains("freely"));
}
#[test]
fn test_nilpotent_orbit() {
let reg = NilpotentOrbitData::regular("sl_3", 6);
let zero = NilpotentOrbitData::zero("sl_3");
assert!(zero.in_closure_of(®));
assert!(!reg.in_closure_of(&zero));
}
}