use oxilean_kernel::{BinderInfo, Declaration, Environment, Expr, Level, Name};
use super::types::{
AdSCFTDictionary, CalabiyauHodge, Compactification, KnownCY3, MTheory, StrComplex,
StringConfiguration, Superstring, TopologicalString, VenezianoAmplitudeCalc,
VirasoroAlgebraExt, BPS,
};
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 app3(f: Expr, a: Expr, b: Expr, c: Expr) -> Expr {
app(app2(f, a, b), c)
}
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 real_ty() -> Expr {
cst("Real")
}
pub fn nat_ty() -> Expr {
cst("Nat")
}
pub fn int_ty() -> Expr {
cst("Int")
}
pub fn complex_ty() -> Expr {
cst("Complex")
}
pub fn list_ty(t: Expr) -> Expr {
app(cst("List"), t)
}
pub fn worldsheet_ty() -> Expr {
type0()
}
pub fn target_manifold_ty() -> Expr {
type0()
}
pub fn sigma_model_map_ty() -> Expr {
arrow(cst("Worldsheet"), cst("TargetManifold"))
}
pub fn sigma_model_action_ty() -> Expr {
arrow(arrow(cst("Worldsheet"), cst("TargetManifold")), real_ty())
}
pub fn metric_tensor_ty() -> Expr {
arrow(
cst("TargetManifold"),
arrow(cst("TangentVector"), arrow(cst("TangentVector"), real_ty())),
)
}
pub fn worldsheet_metric_ty() -> Expr {
arrow(cst("Worldsheet"), cst("SymmetricTensor2"))
}
pub fn nambu_goto_action_ty() -> Expr {
arrow(arrow(cst("Worldsheet"), cst("TargetManifold")), real_ty())
}
pub fn string_tension_ty() -> Expr {
real_ty()
}
pub fn induced_metric_ty() -> Expr {
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(cst("Worldsheet"), cst("SymmetricTensor2")),
)
}
pub fn nambu_goto_equivalence_ty() -> Expr {
prop()
}
pub fn polyakov_action_ty() -> Expr {
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(arrow(cst("Worldsheet"), cst("SymmetricTensor2")), real_ty()),
)
}
pub fn weyl_invariance_ty() -> Expr {
arrow(
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(arrow(cst("Worldsheet"), cst("SymmetricTensor2")), real_ty()),
),
prop(),
)
}
pub fn diff_invariance_ty() -> Expr {
arrow(
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(arrow(cst("Worldsheet"), cst("SymmetricTensor2")), real_ty()),
),
prop(),
)
}
pub fn conformal_gauge_ty() -> Expr {
arrow(real_ty(), arrow(cst("Worldsheet"), cst("SymmetricTensor2")))
}
pub fn cft_state_ty() -> Expr {
type0()
}
pub fn primary_field_ty() -> Expr {
arrow(
real_ty(),
arrow(real_ty(), arrow(complex_ty(), cst("CFTState"))),
)
}
pub fn conformal_weight_ty() -> Expr {
arrow(real_ty(), arrow(real_ty(), type0()))
}
pub fn conformal_transformation_ty() -> Expr {
arrow(complex_ty(), complex_ty())
}
pub fn stress_energy_tensor_ty() -> Expr {
arrow(complex_ty(), cst("CFTState"))
}
pub fn central_charge_ty() -> Expr {
real_ty()
}
pub fn critical_dimension_ty() -> Expr {
nat_ty()
}
pub fn ope_coefficient_ty() -> Expr {
arrow(
arrow(complex_ty(), cst("CFTState")),
arrow(
arrow(complex_ty(), cst("CFTState")),
arrow(arrow(complex_ty(), cst("CFTState")), real_ty()),
),
)
}
pub fn ope_expansion_ty() -> Expr {
arrow(
arrow(complex_ty(), cst("CFTState")),
arrow(
arrow(complex_ty(), cst("CFTState")),
arrow(complex_ty(), arrow(complex_ty(), cst("CFTState"))),
),
)
}
pub fn ttbar_ope_ty() -> Expr {
prop()
}
pub fn ope_associativity_ty() -> Expr {
prop()
}
pub fn virasoro_generator_ty() -> Expr {
arrow(int_ty(), arrow(cst("CFTState"), cst("CFTState")))
}
pub fn virasoro_commutator_ty() -> Expr {
prop()
}
pub fn l0_eigenvalue_ty() -> Expr {
arrow(cst("CFTState"), real_ty())
}
pub fn physical_state_condition_ty() -> Expr {
arrow(cst("CFTState"), prop())
}
pub fn null_state_ty() -> Expr {
arrow(cst("CFTState"), prop())
}
pub fn character_function_ty() -> Expr {
arrow(real_ty(), complex_ty())
}
pub fn modular_invariance_ty() -> Expr {
arrow(arrow(real_ty(), complex_ty()), prop())
}
pub fn vertex_algebra_ty() -> Expr {
type0()
}
pub fn vertex_operator_ty() -> Expr {
arrow(
cst("VertexAlgebra"),
arrow(
complex_ty(),
arrow(cst("VertexAlgebra"), cst("VertexAlgebra")),
),
)
}
pub fn translation_operator_ty() -> Expr {
arrow(cst("VertexAlgebra"), cst("VertexAlgebra"))
}
pub fn vacuum_vector_ty() -> Expr {
cst("VertexAlgebra")
}
pub fn locality_axiom_ty() -> Expr {
arrow(cst("VertexAlgebra"), prop())
}
pub fn va_creativity_ty() -> Expr {
arrow(cst("VertexAlgebra"), prop())
}
pub fn conformal_vertex_algebra_ty() -> Expr {
arrow(cst("VertexAlgebra"), arrow(real_ty(), prop()))
}
pub fn worldsheet_cft_ty() -> Expr {
type0()
}
pub fn mode_expansion_ty() -> Expr {
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(int_ty(), complex_ty()),
)
}
pub fn oscillator_mode_ty() -> Expr {
arrow(int_ty(), arrow(cst("CFTState"), cst("CFTState")))
}
pub fn oscillator_commutator_ty() -> Expr {
prop()
}
pub fn mass_shell_condition_ty() -> Expr {
arrow(cst("CFTState"), arrow(real_ty(), prop()))
}
pub fn tachyonic_ground_state_ty() -> Expr {
cst("CFTState")
}
pub fn massless_vector_state_ty() -> Expr {
cst("CFTState")
}
pub fn t_duality_ty() -> Expr {
arrow(cst("TargetManifold"), cst("TargetManifold"))
}
pub fn t_dual_radius_ty() -> Expr {
arrow(real_ty(), real_ty())
}
pub fn t_duality_involution_ty() -> Expr {
prop()
}
pub fn winding_number_ty() -> Expr {
arrow(arrow(cst("Worldsheet"), cst("TargetManifold")), int_ty())
}
pub fn momentum_winding_duality_ty() -> Expr {
prop()
}
pub fn t_duality_mass_spectrum_ty() -> Expr {
arrow(real_ty(), arrow(int_ty(), arrow(int_ty(), real_ty())))
}
pub fn d_brane_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn brane_embedding_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), cst("TargetManifold"))
}
pub fn dirichlet_bc_ty() -> Expr {
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(arrow(nat_ty(), type0()), prop()),
)
}
pub fn neumann_bc_ty() -> Expr {
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(arrow(nat_ty(), type0()), prop()),
)
}
pub fn dbi_action_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), real_ty())
}
pub fn worldvolume_gauge_field_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(cst("Worldvolume"), cst("LieAlgebra")),
)
}
pub fn brane_charge_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), int_ty())
}
pub fn brane_intersection_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), prop())),
)
}
pub fn calabi_yau_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn holomorphic_form_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), type0())
}
pub fn kahler_form_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), type0())
}
pub fn hodge_diamond_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(nat_ty(), arrow(nat_ty(), nat_ty())),
)
}
pub fn ricci_flat_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), prop())
}
pub fn cy_topological_data_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), nat_ty()))
}
pub fn euler_characteristic_cy_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), int_ty())
}
pub fn mirror_manifold_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), type0()))
}
pub fn mirror_symmetry_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(arrow(nat_ty(), type0()), prop()),
)
}
pub fn hodge_number_exchange_ty() -> Expr {
prop()
}
pub fn gromov_witten_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), int_ty()))
}
pub fn period_integrals_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(cst("Cycle"), complex_ty()))
}
pub fn picard_fuchs_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), prop())
}
pub fn string_duality_ty() -> Expr {
arrow(cst("TargetManifold"), arrow(cst("TargetManifold"), prop()))
}
pub fn build_string_theory_env() -> Environment {
let mut env = Environment::new();
let axioms: &[(&str, Expr)] = &[
("Worldsheet", worldsheet_ty()),
("TargetManifold", target_manifold_ty()),
("TangentVector", type0()),
("SymmetricTensor2", type0()),
("CFTState", cft_state_ty()),
("VertexAlgebra", vertex_algebra_ty()),
("Worldvolume", type0()),
("LieAlgebra", type0()),
("Cycle", type0()),
("SigmaModelMap", sigma_model_map_ty()),
("SigmaModelAction", sigma_model_action_ty()),
("MetricTensor", metric_tensor_ty()),
("WorldsheetMetric", worldsheet_metric_ty()),
("NambuGotoAction", nambu_goto_action_ty()),
("StringTension", string_tension_ty()),
("InducedMetric", induced_metric_ty()),
("nambu_goto_equivalence", nambu_goto_equivalence_ty()),
("PolyakovAction", polyakov_action_ty()),
("weyl_invariance", weyl_invariance_ty()),
("diff_invariance", diff_invariance_ty()),
("ConformalGauge", conformal_gauge_ty()),
("PrimaryField", primary_field_ty()),
("ConformalWeight", conformal_weight_ty()),
("ConformalTransformation", conformal_transformation_ty()),
("StressEnergyTensor", stress_energy_tensor_ty()),
("CentralCharge", central_charge_ty()),
("CriticalDimension", critical_dimension_ty()),
("OPECoefficient", ope_coefficient_ty()),
("OPEExpansion", ope_expansion_ty()),
("ttbar_ope", ttbar_ope_ty()),
("ope_associativity", ope_associativity_ty()),
("VirasoroGenerator", virasoro_generator_ty()),
("virasoro_commutator", virasoro_commutator_ty()),
("L0Eigenvalue", l0_eigenvalue_ty()),
("PhysicalStateCondition", physical_state_condition_ty()),
("NullState", null_state_ty()),
("CharacterFunction", character_function_ty()),
("modular_invariance", modular_invariance_ty()),
("VertexOperator", vertex_operator_ty()),
("TranslationOperator", translation_operator_ty()),
("VacuumVector", vacuum_vector_ty()),
("locality_axiom", locality_axiom_ty()),
("va_creativity", va_creativity_ty()),
("ConformalVertexAlgebra", conformal_vertex_algebra_ty()),
("WorldsheetCFT", worldsheet_cft_ty()),
("ModeExpansion", mode_expansion_ty()),
("OscillatorMode", oscillator_mode_ty()),
("oscillator_commutator", oscillator_commutator_ty()),
("MassShellCondition", mass_shell_condition_ty()),
("TachyonicGroundState", tachyonic_ground_state_ty()),
("MasslessVectorState", massless_vector_state_ty()),
("TDuality", t_duality_ty()),
("TDualRadius", t_dual_radius_ty()),
("t_duality_involution", t_duality_involution_ty()),
("WindingNumber", winding_number_ty()),
("momentum_winding_duality", momentum_winding_duality_ty()),
("TDualityMassSpectrum", t_duality_mass_spectrum_ty()),
("DBrane", d_brane_ty()),
("BraneEmbedding", brane_embedding_ty()),
("DirichletBC", dirichlet_bc_ty()),
("NeumannBC", neumann_bc_ty()),
("DBIAction", dbi_action_ty()),
("WorldvolumeGaugeField", worldvolume_gauge_field_ty()),
("BraneCharge", brane_charge_ty()),
("BraneIntersection", brane_intersection_ty()),
("CalabiYauManifold", calabi_yau_ty()),
("HolomorphicForm", holomorphic_form_ty()),
("KahlerForm", kahler_form_ty()),
("HodgeDiamond", hodge_diamond_ty()),
("ricci_flat", ricci_flat_ty()),
("CYTopologicalData", cy_topological_data_ty()),
("EulerCharacteristicCY", euler_characteristic_cy_ty()),
("MirrorManifold", mirror_manifold_ty()),
("mirror_symmetry", mirror_symmetry_ty()),
("hodge_number_exchange", hodge_number_exchange_ty()),
("GromovWittenInvariant", gromov_witten_ty()),
("PeriodIntegrals", period_integrals_ty()),
("picard_fuchs_equation", picard_fuchs_ty()),
("string_duality", string_duality_ty()),
("AlphaPrime", real_ty()),
("StringLength", real_ty()),
("PlanckLength", real_ty()),
("StringCoupling", real_ty()),
];
for (name, ty) in axioms {
env.add(Declaration::Axiom {
name: Name::str(*name),
univ_params: vec![],
ty: ty.clone(),
})
.ok();
}
env
}
pub fn virasoro_commutator_residual(m: i64, n: i64, lm: f64, ln: f64, l_mpn: f64, c: f64) -> f64 {
#[allow(clippy::eq_op)]
let commutator = lm * ln - ln * lm;
let rhs_algebraic = ((m - n) as f64) * l_mpn;
let central = if m + n == 0 {
c / 12.0 * (m as f64) * ((m * m - 1) as f64)
} else {
0.0
};
commutator - rhs_algebraic - central
}
pub fn t_dual_radius(alpha_prime: f64, radius: f64) -> f64 {
alpha_prime / radius
}
pub fn string_mass_sq(n: i64, w: i64, n_level: u64, radius: f64, alpha_prime: f64) -> f64 {
let momentum_term = (n as f64 / radius).powi(2);
let winding_term = (w as f64 * radius / alpha_prime).powi(2);
let oscillator_term = 2.0 / alpha_prime * (n_level as f64 - 1.0);
momentum_term + winding_term + oscillator_term
}
pub fn cy3_euler_characteristic(h11: i64, h21: i64) -> i64 {
2 * (h11 - h21)
}
pub fn is_mirror_pair(h11_a: u64, h21_a: u64, h11_b: u64, h21_b: u64) -> bool {
h11_a == h21_b && h21_a == h11_b
}
pub fn free_boson_ope_coefficient(z: StrComplex, w: StrComplex, alpha_prime: f64) -> StrComplex {
let dz = StrComplex {
re: z.re - w.re,
im: z.im - w.im,
};
let dz_sq = dz.mul(&dz);
let norm_sq = dz_sq.abs_sq();
if norm_sq < 1e-30 {
return StrComplex::new(f64::INFINITY, 0.0);
}
let coeff = -alpha_prime / 2.0;
StrComplex {
re: coeff * dz_sq.re / norm_sq,
im: coeff * (-dz_sq.im) / norm_sq,
}
}
pub fn stress_tensor_ope_leading(c: f64) -> f64 {
c / 2.0
}
pub fn cylinder_to_plane(sigma: f64, tau: f64) -> StrComplex {
let r = tau.exp();
StrComplex {
re: r * sigma.cos(),
im: r * sigma.sin(),
}
}
pub fn plane_to_cylinder(z: StrComplex) -> (f64, f64) {
let tau = z.abs().ln();
let sigma = z.im.atan2(z.re);
(sigma, tau)
}
#[cfg(test)]
mod tests {
use super::*;
use std::f64::consts::PI;
#[test]
fn test_build_env_succeeds() {
let env = build_string_theory_env();
let _ = env;
}
#[test]
fn test_t_dual_radius_involution() {
let alpha_prime = 1.0;
let r = 2.0;
let r_dual = t_dual_radius(alpha_prime, r);
let r_double_dual = t_dual_radius(alpha_prime, r_dual);
assert!(
(r_double_dual - r).abs() < 1e-14,
"T-duality should be an involution: R̃̃ = R"
);
}
#[test]
fn test_t_duality_self_dual_radius() {
let alpha_prime: f64 = 2.0;
let r_self_dual = alpha_prime.sqrt();
let r_dual = t_dual_radius(alpha_prime, r_self_dual);
assert!(
(r_dual - r_self_dual).abs() < 1e-14,
"Self-dual radius should satisfy R = √α'"
);
}
#[test]
fn test_string_mass_spectrum_tachyon() {
let alpha_prime = 1.0;
let m_sq = string_mass_sq(0, 0, 0, 1.0, alpha_prime);
assert!(
(m_sq - (-2.0)).abs() < 1e-12,
"Tachyon M² should be -2/α' = -2; got {m_sq}"
);
}
#[test]
fn test_string_mass_massless_state() {
let alpha_prime = 1.0;
let m_sq = string_mass_sq(0, 0, 1, 1.0, alpha_prime);
assert!(
m_sq.abs() < 1e-12,
"Massless state should have M² = 0; got {m_sq}"
);
}
#[test]
fn test_cy3_euler_characteristic_quintic() {
let quintic = KnownCY3::quintic();
let chi = quintic.euler_characteristic();
assert_eq!(chi, -200, "Quintic CY3 should have χ = -200");
}
#[test]
fn test_mirror_symmetry_quintic() {
let quintic = KnownCY3::quintic();
let mirror = KnownCY3::mirror_quintic();
assert!(
is_mirror_pair(quintic.h11, quintic.h21, mirror.h11, mirror.h21),
"Quintic and mirror quintic should be a mirror pair"
);
assert_eq!(
quintic.euler_characteristic(),
-mirror.euler_characteristic()
);
}
#[test]
fn test_cylinder_plane_round_trip() {
let sigma = 1.2;
let tau = 0.5;
let z = cylinder_to_plane(sigma, tau);
let (s2, t2) = plane_to_cylinder(z);
let ds = (s2 - sigma).abs();
let dt = (t2 - tau).abs();
assert!(
dt < 1e-12,
"tau round-trip failed: got {t2}, expected {tau}"
);
assert!(
ds < 1e-12 || (ds - 2.0 * PI).abs() < 1e-12,
"sigma round-trip failed: got {s2}, expected {sigma}"
);
}
#[test]
fn test_nambu_goto_action_straight_string() {
let tension = 1.0 / (2.0 * PI);
let n = 100;
let d_sigma = 2.0 * PI / n as f64;
let string = StringConfiguration::straight(4, n, d_sigma);
let action = string.nambu_goto_action(tension);
let expected_length = (n - 1) as f64 * d_sigma;
assert!(
(action - (-tension * expected_length)).abs() < 1e-10,
"Straight string action incorrect: got {action}"
);
}
}
pub fn worldsheet_cft_central_charge_ty() -> Expr {
real_ty()
}
pub fn ope_algebra_ty() -> Expr {
arrow(cst("WorldsheetCFT"), type0())
}
pub fn stress_tensor_tt_ope_ty() -> Expr {
arrow(cst("WorldsheetCFT"), prop())
}
pub fn primary_field_ope_ty() -> Expr {
arrow(cst("WorldsheetCFT"), arrow(real_ty(), prop()))
}
pub fn descendant_field_ty() -> Expr {
arrow(cst("CFTState"), arrow(nat_ty(), cst("CFTState")))
}
pub fn conformal_block_ty() -> Expr {
arrow(
cst("CFTState"),
arrow(
cst("CFTState"),
arrow(
cst("CFTState"),
arrow(cst("CFTState"), arrow(complex_ty(), real_ty())),
),
),
)
}
pub fn crossing_symmetry_ty() -> Expr {
arrow(cst("WorldsheetCFT"), prop())
}
pub fn veneziano_amplitude_ty() -> Expr {
arrow(real_ty(), arrow(real_ty(), arrow(real_ty(), real_ty())))
}
pub fn virasoro_shapiro_amplitude_ty() -> Expr {
arrow(real_ty(), arrow(real_ty(), real_ty()))
}
pub fn superstring_vertex_operator_ty() -> Expr {
arrow(
cst("SuperstringType"),
arrow(int_ty(), arrow(complex_ty(), cst("CFTState"))),
)
}
pub fn superstring_amplitude_ty() -> Expr {
arrow(
cst("SuperstringType"),
arrow(nat_ty(), arrow(nat_ty(), real_ty())),
)
}
pub fn regge_trajectory_ty() -> Expr {
arrow(real_ty(), arrow(real_ty(), real_ty()))
}
pub fn superstring_mass_spectrum_ty() -> Expr {
arrow(cst("SuperstringType"), arrow(nat_ty(), real_ty()))
}
pub fn rr_charge_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), real_ty())
}
pub fn d_brane_worldvolume_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(nat_ty(), cst("TargetManifold")),
)
}
pub fn open_string_endpoint_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(cst("Worldsheet"), prop()))
}
pub fn brane_antibrane_annihilation_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(arrow(nat_ty(), type0()), prop()),
)
}
pub fn k_theory_charge_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), int_ty())
}
pub fn t_duality_group_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn winding_mode_ty() -> Expr {
arrow(
arrow(cst("Worldsheet"), cst("TargetManifold")),
arrow(int_ty(), real_ty()),
)
}
pub fn momentum_mode_ty() -> Expr {
arrow(int_ty(), arrow(real_ty(), real_ty()))
}
pub fn t_duality_invariant_spectrum_ty() -> Expr {
prop()
}
pub fn buscher_rules_ty() -> Expr {
prop()
}
pub fn mirror_syz_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(arrow(nat_ty(), type0()), prop()),
)
}
pub fn s_duality_ty() -> Expr {
arrow(
cst("SuperstringType"),
arrow(cst("SuperstringType"), prop()),
)
}
pub fn montonen_olive_duality_ty() -> Expr {
prop()
}
pub fn sl2z_action_ty() -> Expr {
arrow(real_ty(), arrow(complex_ty(), complex_ty()))
}
pub fn sl2z_duality_ty() -> Expr {
prop()
}
pub fn s_duality_bps_spectrum_ty() -> Expr {
prop()
}
pub fn holographic_principle_ty() -> Expr {
prop()
}
pub fn maldacena_conjecture_ty() -> Expr {
prop()
}
pub fn holographic_dictionary_ty() -> Expr {
arrow(real_ty(), arrow(real_ty(), real_ty()))
}
pub fn wilson_loop_ads_ty() -> Expr {
arrow(real_ty(), real_ty())
}
pub fn holographic_entanglement_ty() -> Expr {
arrow(real_ty(), real_ty())
}
pub fn ads_radius_duality_ty() -> Expr {
arrow(real_ty(), arrow(real_ty(), real_ty()))
}
pub fn cy_moduli_space_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), type0())
}
pub fn kahler_moduli_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), real_ty()))
}
pub fn complex_structure_moduli_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), complex_ty()))
}
pub fn special_geometry_ty() -> Expr {
arrow(type0(), prop())
}
pub fn gopakumar_vafa_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), int_ty()))
}
pub fn m_theory_dimension_ty() -> Expr {
nat_ty()
}
pub fn m_theory_supergravity_ty() -> Expr {
type0()
}
pub fn m2_brane_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn m5_brane_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn m_theory_compactification_ty() -> Expr {
arrow(type0(), arrow(nat_ty(), cst("TargetManifold")))
}
pub fn m_theory_duality_web_ty() -> Expr {
prop()
}
pub fn horava_molten_ty() -> Expr {
prop()
}
pub fn string_field_theory_ty() -> Expr {
type0()
}
pub fn brst_cohomology_ty() -> Expr {
arrow(cst("StringFieldTheory"), type0())
}
pub fn string_vertex_ty() -> Expr {
arrow(
cst("StringField"),
arrow(cst("StringField"), arrow(cst("StringField"), real_ty())),
)
}
pub fn star_product_ty() -> Expr {
arrow(
cst("StringField"),
arrow(cst("StringField"), cst("StringField")),
)
}
pub fn witten_sft_action_ty() -> Expr {
arrow(cst("StringField"), real_ty())
}
pub fn tachyon_condensation_ty() -> Expr {
arrow(cst("StringField"), prop())
}
pub fn a_model_twist_ty() -> Expr {
arrow(cst("WorldsheetCFT"), type0())
}
pub fn b_model_twist_ty() -> Expr {
arrow(cst("WorldsheetCFT"), type0())
}
pub fn gromov_witten_potential_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), real_ty())
}
pub fn b_model_free_energy_ty() -> Expr {
arrow(arrow(nat_ty(), type0()), real_ty())
}
pub fn holomorphic_anomaly_equation_ty() -> Expr {
prop()
}
pub fn topological_amplitude_ty() -> Expr {
arrow(nat_ty(), real_ty())
}
pub fn swampland_distance_conjecture_ty() -> Expr {
prop()
}
pub fn de_sitter_conjecture_ty() -> Expr {
prop()
}
pub fn weak_gravity_conjecture_ty() -> Expr {
prop()
}
pub fn swampland_consistency_ty() -> Expr {
prop()
}
pub fn landscape_vs_swampland_ty() -> Expr {
prop()
}
pub fn matrix_model_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn bfss_model_ty() -> Expr {
type0()
}
pub fn non_perturbative_correction_ty() -> Expr {
arrow(real_ty(), real_ty())
}
pub fn d_instanton_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn string_duality_bound_state_ty() -> Expr {
arrow(
arrow(nat_ty(), type0()),
arrow(arrow(nat_ty(), type0()), arrow(nat_ty(), type0())),
)
}
pub fn matrix_string_theory_ty() -> Expr {
prop()
}
pub fn build_string_theory_ext_env(env: &mut Environment) {
let axioms: &[(&str, Expr)] = &[
("SuperstringType", type0()),
("StringField", type0()),
("StringFieldTheory", type0()),
(
"WorldsheetCFT_CentralCharge",
worldsheet_cft_central_charge_ty(),
),
("OPEAlgebra", ope_algebra_ty()),
("stress_tensor_tt_ope", stress_tensor_tt_ope_ty()),
("primary_field_ope", primary_field_ope_ty()),
("DescendantField", descendant_field_ty()),
("ConformalBlock", conformal_block_ty()),
("crossing_symmetry", crossing_symmetry_ty()),
("VenezianoAmplitude", veneziano_amplitude_ty()),
("VirasoroShapiroAmplitude", virasoro_shapiro_amplitude_ty()),
(
"SuperstringVertexOperator",
superstring_vertex_operator_ty(),
),
("SuperstringAmplitude", superstring_amplitude_ty()),
("ReggeTrajectory", regge_trajectory_ty()),
("SuperstringMassSpectrum", superstring_mass_spectrum_ty()),
("RRCharge", rr_charge_ty()),
("DBraneWorldvolume", d_brane_worldvolume_ty()),
("OpenStringEndpoint", open_string_endpoint_ty()),
(
"brane_antibrane_annihilation",
brane_antibrane_annihilation_ty(),
),
("KTheoryCharge", k_theory_charge_ty()),
("TDualityGroup", t_duality_group_ty()),
("WindingMode", winding_mode_ty()),
("MomentumMode", momentum_mode_ty()),
(
"t_duality_invariant_spectrum",
t_duality_invariant_spectrum_ty(),
),
("buscher_rules", buscher_rules_ty()),
("mirror_syz", mirror_syz_ty()),
("s_duality", s_duality_ty()),
("montonen_olive_duality", montonen_olive_duality_ty()),
("SL2Z_Action", sl2z_action_ty()),
("sl2z_duality", sl2z_duality_ty()),
("s_duality_bps_spectrum", s_duality_bps_spectrum_ty()),
("holographic_principle", holographic_principle_ty()),
("maldacena_conjecture", maldacena_conjecture_ty()),
("HolographicDictionary", holographic_dictionary_ty()),
("WilsonLoopAdS", wilson_loop_ads_ty()),
("HolographicEntanglement", holographic_entanglement_ty()),
("AdSRadiusDuality", ads_radius_duality_ty()),
("CYModuliSpace", cy_moduli_space_ty()),
("KahlerModuli", kahler_moduli_ty()),
("ComplexStructureModuli", complex_structure_moduli_ty()),
("special_geometry", special_geometry_ty()),
("GopakumarVafa", gopakumar_vafa_ty()),
("MTheoryDimension", m_theory_dimension_ty()),
("MTheorySupergravity", m_theory_supergravity_ty()),
("M2Brane", m2_brane_ty()),
("M5Brane", m5_brane_ty()),
("MTheoryCompactification", m_theory_compactification_ty()),
("m_theory_duality_web", m_theory_duality_web_ty()),
("horava_molten", horava_molten_ty()),
("BRSTCohomology", brst_cohomology_ty()),
("StringVertex", string_vertex_ty()),
("StarProduct", star_product_ty()),
("WittenSFTAction", witten_sft_action_ty()),
("tachyon_condensation", tachyon_condensation_ty()),
("AModelTwist", a_model_twist_ty()),
("BModelTwist", b_model_twist_ty()),
("GromovWittenPotential", gromov_witten_potential_ty()),
("BModelFreeEnergy", b_model_free_energy_ty()),
(
"holomorphic_anomaly_equation",
holomorphic_anomaly_equation_ty(),
),
("TopologicalAmplitude", topological_amplitude_ty()),
(
"swampland_distance_conjecture",
swampland_distance_conjecture_ty(),
),
("de_sitter_conjecture", de_sitter_conjecture_ty()),
("weak_gravity_conjecture", weak_gravity_conjecture_ty()),
("swampland_consistency", swampland_consistency_ty()),
("landscape_vs_swampland", landscape_vs_swampland_ty()),
("MatrixModel", matrix_model_ty()),
("BFSSModel", bfss_model_ty()),
(
"NonPerturbativeCorrection",
non_perturbative_correction_ty(),
),
("DInstanton", d_instanton_ty()),
("StringDualityBoundState", string_duality_bound_state_ty()),
("matrix_string_theory", matrix_string_theory_ty()),
];
for (name, ty) in axioms {
env.add(Declaration::Axiom {
name: Name::str(*name),
univ_params: vec![],
ty: ty.clone(),
})
.ok();
}
}
pub(super) fn lgamma_approx(x: f64) -> f64 {
if x <= 0.0 {
return f64::NAN;
}
(x - 0.5) * x.ln() - x + 0.5 * (2.0 * std::f64::consts::PI).ln()
}
#[cfg(test)]
mod ext_tests {
use super::*;
#[test]
fn test_build_ext_env() {
let mut env = build_string_theory_env();
build_string_theory_ext_env(&mut env);
assert!(env.get(&Name::str("VenezianoAmplitude")).is_some());
assert!(env.get(&Name::str("maldacena_conjecture")).is_some());
assert!(env.get(&Name::str("M2Brane")).is_some());
assert!(env
.get(&Name::str("swampland_distance_conjecture"))
.is_some());
}
#[test]
fn test_virasoro_ext_partition_numbers() {
let vir = VirasoroAlgebraExt::new(26.0, 0.0, 5);
assert_eq!(vir.partition_number(0), 1);
assert_eq!(vir.partition_number(1), 1);
assert_eq!(vir.partition_number(2), 2);
assert_eq!(vir.partition_number(3), 3);
assert_eq!(vir.partition_number(4), 5);
assert_eq!(vir.partition_number(5), 7);
}
#[test]
fn test_virasoro_ext_central_term() {
let vir = VirasoroAlgebraExt::new(26.0, 1.0, 3);
let ct = vir.central_term(2);
assert!(
(ct - 13.0).abs() < 1e-10,
"Central term for m=2 should be 13, got {ct}"
);
}
#[test]
fn test_virasoro_ext_character() {
let vir = VirasoroAlgebraExt::new(26.0, 0.0, 3);
let chi = vir.character_truncated(0.5);
assert!(
chi > 0.0 && chi.is_finite(),
"Character should be positive, got {chi}"
);
}
#[test]
fn test_veneziano_regge_trajectory() {
let amp = VenezianoAmplitudeCalc::new(1.0);
assert!((amp.regge_trajectory(0.0) - 1.0).abs() < 1e-12);
assert!((amp.regge_trajectory(2.0) - 2.0).abs() < 1e-12);
}
#[test]
fn test_veneziano_low_energy() {
let amp = VenezianoAmplitudeCalc::new(1.0);
let val = amp.low_energy_amplitude(-1.0, -2.0);
assert!(
(val - 1.5).abs() < 1e-10,
"Low energy amplitude should be 1.5, got {val}"
);
}
#[test]
fn test_calabiyau_hodge_quintic() {
let cy = CalabiyauHodge::quintic();
assert_eq!(cy.h11, 1);
assert_eq!(cy.h21, 101);
assert_eq!(cy.euler_characteristic(), -200);
assert_eq!(cy.total_moduli(), 102);
assert_eq!(cy.num_generations(), 100);
}
#[test]
fn test_calabiyau_hodge_mirror() {
let quintic = CalabiyauHodge::quintic();
let mirror = CalabiyauHodge::mirror_quintic();
assert!(quintic.is_mirror_of(&mirror));
assert!(mirror.is_mirror_of(&quintic));
assert_eq!(
quintic.euler_characteristic(),
-mirror.euler_characteristic()
);
}
#[test]
fn test_ads_cft_dictionary_conformal_dim() {
let dict = AdSCFTDictionary::ads5_cft4(100);
let delta = dict.conformal_dimension(0.0);
assert!(
(delta - 4.0).abs() < 1e-10,
"Massless scalar: Δ should be d=4, got {delta}"
);
}
#[test]
fn test_ads_cft_bf_bound() {
let dict = AdSCFTDictionary::new(4, 1.0, 1.0, 10, 0.1);
let bf = dict.bf_bound();
assert!(
(bf - (-4.0)).abs() < 1e-10,
"BF bound should be -4 for d=4,L=1, got {bf}"
);
}
#[test]
fn test_ads_cft_t_hooft_coupling() {
let dict = AdSCFTDictionary::new(4, 1.0, 0.01, 100, 0.1);
let lambda = dict.t_hooft_coupling();
let expected = 4.0 * std::f64::consts::PI * 0.1 * 100.0;
assert!(
(lambda - expected).abs() < 1e-10,
"t'Hooft coupling mismatch"
);
}
#[test]
fn test_m_theory_branes() {
let m = MTheory::new(11);
assert!(m.eleven_dim_supergravity());
let (m2, m5) = m.m2_m5_branes();
assert!(m2 > 0.0);
assert!(m5 > 0.0);
assert!(m2 > m5, "M2 tension should exceed M5 in natural units");
}
#[test]
fn test_topological_string_mirror() {
let ts = TopologicalString::new(true, true);
assert!(ts.mirror_symmetry());
assert!(ts.gromov_witten());
assert!(ts.kodaira_spencer());
}
}