use oxilean_kernel::{Declaration, Environment, Expr, Name};
use super::types::{
AbsolutelyIrreducible, BreuilKisin, CrystallineLiftingRing, CrystallineRepresentation,
DeRhamRepresentation, DieudonneModule, EtaleLocalSystem, FilteredPhiModule, FiltrationOnBdR,
FontaineDieudonne, FrobeniusOnBcrys, GaloisRepresentationOfEllipticCurve,
HodgeTateDecomposition, HodgeTateDecompositionComputer, HodgeTateWeights, IwasawaTheory,
LAdicSheaf, MonodromyOperator, PAdicLanglands, PAdicPeriodRings, PAdicRepresentation,
PadicLFunctionInterpolation, PadicNumber, PerfectoidAlgebra, PerfectoidChar, PeriodRing,
PhiModuleComputation, PrismaticCohomology, SemiStableRepresentation, SyntonicComplex,
WachModuleCheck, WeaklyAdmissible,
};
pub fn cst(s: &str) -> Expr {
Expr::Const(Name::str(s), vec![])
}
pub fn prop() -> Expr {
Expr::Sort(oxilean_kernel::Level::zero())
}
pub fn type0() -> Expr {
Expr::Sort(oxilean_kernel::Level::succ(oxilean_kernel::Level::zero()))
}
pub fn nat_ty() -> Expr {
cst("Nat")
}
pub fn int_ty() -> Expr {
cst("Int")
}
pub fn real_ty() -> Expr {
cst("Real")
}
pub fn bool_ty() -> Expr {
cst("Bool")
}
pub fn arrow(a: Expr, b: Expr) -> Expr {
Expr::Pi(
oxilean_kernel::BinderInfo::Default,
Name::str("_"),
Box::new(a),
Box::new(b),
)
}
pub fn padic_period_rings_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn filtration_on_bdr_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn frobenius_on_bcrys_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn monodromy_operator_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn padic_representation_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn hodge_tate_decomposition_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), prop()))
}
pub fn hodge_tate_weights_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn is_hodge_tate_ty() -> Expr {
prop()
}
pub fn is_de_rham_ty() -> Expr {
prop()
}
pub fn is_crystalline_ty() -> Expr {
prop()
}
pub fn is_semi_stable_ty() -> Expr {
prop()
}
pub fn crystalline_representation_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn semi_stable_representation_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn de_rham_representation_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn weakly_admissible_ty() -> Expr {
prop()
}
pub fn fontaine_theorem_ty() -> Expr {
prop()
}
pub fn filtered_phi_module_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn fontaine_dieudonne_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn breuil_kisin_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn kisin_equivalence_ty() -> Expr {
prop()
}
pub fn tate_module_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn galois_representation_of_elliptic_curve_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn absolutely_irreducible_ty() -> Expr {
prop()
}
pub fn crystalline_lifting_ring_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn padic_comparison_theorem_ty() -> Expr {
prop()
}
pub fn sen_theorem_ty() -> Expr {
prop()
}
pub fn berger_theorem_ty() -> Expr {
prop()
}
pub fn colmez_fontaine_ty() -> Expr {
prop()
}
pub fn tate_twist_ty() -> Expr {
arrow(int_ty(), arrow(nat_ty(), type0()))
}
pub fn cyclotomic_character_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn newton_polygon_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn hodge_polygon_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn bdr_ring_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn bcrys_ring_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn bst_ring_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn bht_ring_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn bdr_filtration_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn crystalline_comparison_ty() -> Expr {
prop()
}
pub fn de_rham_comparison_ty() -> Expr {
prop()
}
pub fn etale_comparison_ty() -> Expr {
prop()
}
pub fn crystalline_de_rham_comparison_ty() -> Expr {
prop()
}
pub fn p_divisible_group_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn dieudonne_module_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn formal_group_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn p_divisible_group_equivalence_ty() -> Expr {
prop()
}
pub fn perfectoid_space_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn tilting_functor_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn tilting_equivalence_ty() -> Expr {
prop()
}
pub fn almost_mathematics_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn perfectoid_field_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn prism_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn prismatic_site_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn prismatic_cohomology_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn nygaard_filtration_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn bk_prism_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn ainf_prism_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn syntomic_complex_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn padic_regulator_ty() -> Expr {
prop()
}
pub fn syntomic_cohomology_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn wach_module_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn wach_module_equivalence_ty() -> Expr {
prop()
}
pub fn positive_crystalline_rep_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn padic_l_function_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn iwasawa_main_conjecture_ty() -> Expr {
prop()
}
pub fn iwasawa_algebra_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn padic_l_function_interpolation_ty() -> Expr {
prop()
}
pub fn iwasawa_invariants_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn sen_operator_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn sen_theory_ty() -> Expr {
prop()
}
pub fn hodge_tate_weight_multiplicity_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), prop()))
}
pub fn almost_purity_theorem_ty() -> Expr {
prop()
}
pub fn faltings_almost_etale_ty() -> Expr {
prop()
}
pub fn perfectoid_almost_purity_ty() -> Expr {
prop()
}
pub fn filtered_phi_n_module_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn admissible_filtered_module_ty() -> Expr {
prop()
}
pub fn weakly_admissible_equals_admissible_ty() -> Expr {
prop()
}
pub fn breuil_kisin_module_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn breuil_kisin_g_module_ty() -> Expr {
arrow(nat_ty(), arrow(nat_ty(), type0()))
}
pub fn integral_crystalline_rep_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn witt_vectors_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn ainf_ring_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn theta_map_ty() -> Expr {
prop()
}
pub fn crystalline_comparison_isom_ty() -> Expr {
arrow(nat_ty(), prop())
}
pub fn de_rham_comparison_isom_ty() -> Expr {
arrow(nat_ty(), prop())
}
pub fn perfectoid_tilt_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn delta_ring_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn prismatic_frobenius_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn kisin_fargues_ty() -> Expr {
prop()
}
pub fn overconvergent_phi_module_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn etal_phi_module_ty() -> Expr {
arrow(nat_ty(), type0())
}
pub fn fontaine_equivalence_ty() -> Expr {
prop()
}
pub fn colmez_functor_ty() -> Expr {
arrow(nat_ty(), type0())
}
type AxiomEntry = (&'static str, fn() -> Expr);
pub fn build_env(env: &mut Environment) {
let axioms: &[AxiomEntry] = &[
("PAdicPeriodRings", padic_period_rings_ty),
("FiltrationOnBdR", filtration_on_bdr_ty),
("FrobeniusOnBcrys", frobenius_on_bcrys_ty),
("MonodromyOperator", monodromy_operator_ty),
("PAdicRepresentation", padic_representation_ty),
("HodgeTateDecomposition", hodge_tate_decomposition_ty),
("HodgeTateWeights", hodge_tate_weights_ty),
("IsHodgeTate", is_hodge_tate_ty),
("IsDeRham", is_de_rham_ty),
("IsCrystalline", is_crystalline_ty),
("IsSemiStable", is_semi_stable_ty),
("CrystallineRepresentation", crystalline_representation_ty),
("SemiStableRepresentation", semi_stable_representation_ty),
("DeRhamRepresentation", de_rham_representation_ty),
("WeaklyAdmissible", weakly_admissible_ty),
("FontaineTheorem", fontaine_theorem_ty),
("FilteredPhiModule", filtered_phi_module_ty),
("FontaineDieudonne", fontaine_dieudonne_ty),
("BreuilKisin", breuil_kisin_ty),
("KisinEquivalence", kisin_equivalence_ty),
("TateModule", tate_module_ty),
(
"GaloisRepresentationOfEllipticCurve",
galois_representation_of_elliptic_curve_ty,
),
("AbsolutelyIrreducible", absolutely_irreducible_ty),
("CrystallineLiftingRing", crystalline_lifting_ring_ty),
("PAdicComparisonTheorem", padic_comparison_theorem_ty),
("SenTheorem", sen_theorem_ty),
("BergerTheorem", berger_theorem_ty),
("ColmezFontaine", colmez_fontaine_ty),
("TateTwist", tate_twist_ty),
("CyclotomicCharacter", cyclotomic_character_ty),
("NewtonPolygon", newton_polygon_ty),
("HodgePolygon", hodge_polygon_ty),
("BdRRing", bdr_ring_ty),
("BcrysRing", bcrys_ring_ty),
("BstRing", bst_ring_ty),
("BHTRing", bht_ring_ty),
("BdRFiltration", bdr_filtration_ty),
("CrystallineComparison", crystalline_comparison_ty),
("DeRhamComparison", de_rham_comparison_ty),
("EtaleComparison", etale_comparison_ty),
(
"CrystallineDeRhamComparison",
crystalline_de_rham_comparison_ty,
),
("PDivisibleGroup", p_divisible_group_ty),
("DieudonneModule", dieudonne_module_ty),
("FormalGroup", formal_group_ty),
(
"PDivisibleGroupEquivalence",
p_divisible_group_equivalence_ty,
),
("PerfectoidSpace", perfectoid_space_ty),
("TiltingFunctor", tilting_functor_ty),
("TiltingEquivalence", tilting_equivalence_ty),
("AlmostMathematics", almost_mathematics_ty),
("PerfectoidField", perfectoid_field_ty),
("Prism", prism_ty),
("PrismaticSite", prismatic_site_ty),
("PrismaticCohomology", prismatic_cohomology_ty),
("NygaardFiltration", nygaard_filtration_ty),
("BKPrism", bk_prism_ty),
("AinfPrism", ainf_prism_ty),
("SyntomicComplex", syntomic_complex_ty),
("PAdicRegulator", padic_regulator_ty),
("SyntomicCohomology", syntomic_cohomology_ty),
("WachModule", wach_module_ty),
("WachModuleEquivalence", wach_module_equivalence_ty),
("PositiveCrystallineRep", positive_crystalline_rep_ty),
("PAdicLFunction", padic_l_function_ty),
("IwasawaMainConjecture", iwasawa_main_conjecture_ty),
("IwasawaAlgebra", iwasawa_algebra_ty),
(
"PAdicLFunctionInterpolation",
padic_l_function_interpolation_ty,
),
("IwasawaInvariants", iwasawa_invariants_ty),
("SenOperator", sen_operator_ty),
("SenTheory", sen_theory_ty),
(
"HodgeTateWeightMultiplicity",
hodge_tate_weight_multiplicity_ty,
),
("AlmostPurityTheorem", almost_purity_theorem_ty),
("FaltingsAlmostEtale", faltings_almost_etale_ty),
("PerfectoidAlmostPurity", perfectoid_almost_purity_ty),
("FilteredPhiNModule", filtered_phi_n_module_ty),
("AdmissibleFilteredModule", admissible_filtered_module_ty),
(
"WeaklyAdmissibleEqualsAdmissible",
weakly_admissible_equals_admissible_ty,
),
("BreuilKisinModule", breuil_kisin_module_ty),
("BreuilKisinGModule", breuil_kisin_g_module_ty),
("IntegralCrystallineRep", integral_crystalline_rep_ty),
("WittVectors", witt_vectors_ty),
("AinfRing", ainf_ring_ty),
("ThetaMap", theta_map_ty),
("CrystallineComparisonIsom", crystalline_comparison_isom_ty),
("DeRhamComparisonIsom", de_rham_comparison_isom_ty),
("PerfectoidTilt", perfectoid_tilt_ty),
("DeltaRing", delta_ring_ty),
("PrismaticFrobenius", prismatic_frobenius_ty),
("KisinFargues", kisin_fargues_ty),
("OverconvergentPhiModule", overconvergent_phi_module_ty),
("EtalPhiModule", etal_phi_module_ty),
("FontaineEquivalence", fontaine_equivalence_ty),
("ColmezFunctor", colmez_functor_ty),
];
for (name, ty_fn) in axioms {
env.add(Declaration::Axiom {
name: Name::str(*name),
univ_params: vec![],
ty: ty_fn(),
})
.ok();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_padic_number_from_integer() {
let x = PadicNumber::from_integer(5, 13);
assert_eq!(x.digits, vec![3, 2]);
assert_eq!(x.padic_valuation(), Some(0));
}
#[test]
fn test_padic_number_norm() {
let x = PadicNumber::from_integer(5, 25);
assert_eq!(x.padic_valuation(), Some(2));
let norm = x.norm();
assert!((norm - 0.04).abs() < 1e-10);
}
#[test]
fn test_padic_number_add() {
let a = PadicNumber::from_integer(5, 3);
let b = PadicNumber::from_integer(5, 4);
let sum = a.add(&b);
assert_eq!(sum.digits[0], 2);
assert_eq!(sum.digits[1], 1);
}
#[test]
fn test_hodge_tate_decomposition_computer() {
let comp = HodgeTateDecompositionComputer::new(vec![0, 0, 1, 1, 2]);
let decomp = comp.compute();
assert_eq!(decomp, vec![(0, 2), (1, 2), (2, 1)]);
assert_eq!(comp.dimension(), 5);
}
#[test]
fn test_hodge_tate_format() {
let comp = HodgeTateDecompositionComputer::new(vec![0, 1]);
let s = comp.format_decomposition();
assert!(s.contains("C_p(0)^1"));
assert!(s.contains("C_p(1)^1"));
}
#[test]
fn test_phi_module_trace_det() {
let m = PhiModuleComputation::new(5, vec![vec![2, 1], vec![0, 3]]);
assert_eq!(m.trace(), 5);
assert_eq!(m.determinant(), Some(6));
}
#[test]
fn test_phi_module_newton_slope() {
let m = PhiModuleComputation::new(5, vec![vec![5, 0], vec![0, 1]]);
let slope = m.newton_slope().expect("newton_slope should succeed");
assert!((slope - 0.5).abs() < 1e-10);
}
#[test]
fn test_wach_module_check_valid() {
let mut w = WachModuleCheck::new(2, 5, 1);
assert!(!w.is_valid_wach_module());
w.set_all_ok();
assert!(w.is_valid_wach_module());
}
#[test]
fn test_wach_module_berger_string() {
let w = WachModuleCheck::new(2, 5, 1);
let s = w.berger_equivalence();
assert!(s.contains("Wach modules"));
assert!(s.contains("positive crys"));
}
#[test]
fn test_padic_l_function_interpolation() {
let mut lp = PadicLFunctionInterpolation::new(5, 1);
lp.add_value(1, -0.5);
lp.add_value(2, 0.25);
assert_eq!(lp.query(1), Some(-0.5));
assert_eq!(lp.query(3), None);
}
#[test]
fn test_padic_l_function_mu_invariant() {
let mut lp = PadicLFunctionInterpolation::new(5, 1);
lp.add_value(1, 1.0);
lp.add_value(2, 0.5);
assert_eq!(lp.mu_invariant(), 0);
}
#[test]
fn test_build_env_has_new_axioms() {
let mut env = Environment::new();
build_env(&mut env);
let names = [
"BdRRing",
"PrismaticCohomology",
"WachModule",
"PAdicLFunction",
"TiltingEquivalence",
"AlmostPurityTheorem",
"FontaineEquivalence",
"ColmezFunctor",
"WittVectors",
"AinfRing",
];
for name in &names {
assert!(
env.get(&Name::str(*name)).is_some(),
"Missing axiom: {name}"
);
}
}
#[test]
fn test_period_ring_contains() {
assert!(PeriodRing::BdR.contains_ring(&PeriodRing::Bcrys));
assert!(PeriodRing::Bst.contains_ring(&PeriodRing::Bcrys));
assert!(!PeriodRing::Bcrys.contains_ring(&PeriodRing::BdR));
assert!(!PeriodRing::Bht.contains_ring(&PeriodRing::BdR));
}
#[test]
fn test_padic_number_display() {
let x = PadicNumber::from_integer(5, 0);
let d = x.display();
assert!(d.is_empty() || d == "0");
}
}
#[cfg(test)]
mod tests_padic_hodge_ext {
use super::*;
#[test]
fn test_ladic_sheaf() {
let sheaf = LAdicSheaf::constant_sheaf("X", 5);
assert_eq!(sheaf.rank, 1);
assert!(sheaf.is_lisse);
let weil = sheaf.weil_conjecture_reference();
assert!(weil.contains("Deligne"));
let trace = sheaf.grothendieck_trace_formula();
assert!(trace.contains("Frob"));
}
#[test]
fn test_etale_local_system() {
let els = EtaleLocalSystem::new("ρ_E", vec![0, 1]).crystalline();
assert!(els.is_crystalline);
let font = els.fontaine_correspondence();
assert!(font.contains("Fontaine"));
}
#[test]
fn test_prismatic_cohomology() {
let ainf = PrismaticCohomology::ainf_prism();
assert!(ainf.perfect_prism);
let bms = ainf.bms_comparison_theorem();
assert!(bms.contains("BMS"));
assert!(ainf.is_universal_cohomology_theory());
let ht = ainf.hodge_tate_comparison();
assert!(ht.contains("HT"));
}
#[test]
fn test_perfectoid_algebra() {
let pa = PerfectoidAlgebra::new("C_p", PerfectoidChar::CharZero);
assert!(!pa.is_tilted_char_p());
let tilting = pa.scholze_tilting_equivalence();
assert!(tilting.contains("Scholze"));
let witt = pa.witt_vector_description();
assert!(witt.contains("W("));
}
#[test]
fn test_padic_langlands() {
let pl = PAdicLanglands::gl2_qp(7);
assert_eq!(pl.prime_p, 7);
let colmez = pl.colmez_description();
assert!(colmez.contains("Colmez"));
let bm = pl.breuil_mézard_conjecture();
assert!(bm.contains("Breuil"));
}
#[test]
fn test_iwasawa_theory() {
let iw = IwasawaTheory::cyclotomic("Q");
let mc = iw.main_conjecture_iwasawa();
assert!(mc.contains("Iwasawa"));
let st = iw.structure_theorem();
assert!(st.contains("Λ"));
}
}
#[cfg(test)]
mod tests_padic_hodge_ext2 {
use super::*;
#[test]
fn test_syntomic_complex() {
let sc = SyntonicComplex {
scheme: "X".to_string(),
torsion_bound: 4,
is_quasi_syntomic: true,
};
assert!(sc.is_quasi_syntomic);
let cmp = sc.aq_crys_comparison();
assert!(cmp.contains("syntomic"));
}
}