#!/usr/bin/env python3
"""
BSDProver: Computational Analysis of the Birch and Swinnerton-Dyer Conjecture

A modular framework for computing and comparing both sides of the BSD formula:

  L(E,1) = (Omega_E * R_E * |Sha(E)| * prod(c_p)) / |E(Q)_tors|^2

Each component is computed by a dedicated, mathematically rigorous algorithm:
  - L(E,1) via the Approximate Functional Equation
  - Omega_E via AGM / complete elliptic integrals (Cremona Section 2.4)
  - R_E via Neron-Tate canonical height pairing (duplication formula)
  - c_p via Tate's algorithm for Kodaira classification
  - |E(Q)_tors| via Mazur's theorem and division polynomials
  - |Sha| via BSD formula inversion or LMFDB-verified data

This system is part of the Fractal Correction Engine (FCE). The FCE is a
general-purpose computational framework that uses pi and local curvature
to extract a fractal path identical to the observed path, enabling forwards
and backwards trajectory prediction and wave/interference mapping. In the
context of BSD conjecture exploration, the FCE methodology is applied to
iteratively optimize component calculations while preserving curve identity,
treating the BSD formula as a system whose components can be refined through
successive approximation.

Note: This is a computational exploration tool, not a proof system. The BSD
conjecture remains an open Millennium Prize Problem.

Version: 2.1.0
License: MIT
"""

__version__ = "2.1.0"
__author__ = "BSD Research Team"
__license__ = "MIT"

# Core imports -- wrapped in try/except so partial imports don't break the package
try:
    from .curve_parser import CurveParser, EllipticCurve
except ImportError:
    pass

try:
    from .l_function_engine import LFunctionEngine, PadicLFunction
except ImportError:
    pass

try:
    from .height_entropy import HeightEntropyAnalyzer, CanonicalHeightComputer
except ImportError:
    pass

try:
    from .period_computer import PeriodComputer, ComplexMultiplicationDetector
except ImportError:
    pass

try:
    from .regulator_matrix import RegulatorComputer, HeightPairingMatrix
except ImportError:
    pass

try:
    from .sha_estimator import ShaEstimator
except ImportError:
    pass

try:
    from .arb_interface import ArbInterface, IntervalArithmetic
except ImportError:
    pass

try:
    from .descent_engine import TwoDescentEngine, FullDescentEngine, DescentResult
except ImportError:
    pass

try:
    from .enhanced_rank_computer import HeegnerPointEngine, EnhancedRankComputer, RankResult
except ImportError:
    pass

try:
    from .torsion_analyzer import TorsionAnalyzer, TorsionStructure
except ImportError:
    pass

try:
    from .kodaira_analyzer import KodairaAnalyzer, TamagawaResult
except ImportError:
    pass

try:
    from .main_prover import BSDProver
except ImportError:
    pass


# Exception classes
class BSDProverError(Exception):
    """Base exception for BSDProver module"""
    pass

class CurveError(BSDProverError):
    """Exception for invalid elliptic curves"""
    pass

class ComputationError(BSDProverError):
    """Exception for computational failures"""
    pass


def get_version_info():
    """Get version information"""
    return {
        "version": __version__,
        "author": __author__,
        "license": __license__,
        "components": {
            "l_function": "Approximate Functional Equation (AFE)",
            "periods": "AGM / complete elliptic integrals (Cremona 2.4)",
            "heights": "Neron-Tate canonical height via duplication formula",
            "kodaira": "Tate's algorithm for Kodaira classification",
            "torsion": "Mazur classification with division polynomials",
            "sha": "BSD formula inversion / LMFDB-verified",
            "descent": "2-Selmer group bounds",
            "arb": "Interval arithmetic with error tracking",
        },
    }


# Default configuration
DEFAULT_CONFIG = {
    "max_height": 1000,
    "prime_limit": 10000,
    "precision_digits": 30,
    "bsd_tolerance": 1e-6,
    "theoretical_weight": 0.8,
    "correction_steps": 50,
    "enable_arb": True,
    "enable_p_adic": False,
    "enable_ml": False,
    "enable_quantum": False,
    "enable_proofs": True,
    "verification_level": "standard",
}

__all__ = [
    "BSDProver",
    "CurveParser", "EllipticCurve",
    "LFunctionEngine", "PadicLFunction",
    "HeightEntropyAnalyzer", "CanonicalHeightComputer",
    "PeriodComputer", "ComplexMultiplicationDetector",
    "RegulatorComputer", "HeightPairingMatrix",
    "ShaEstimator",
    "ArbInterface", "IntervalArithmetic",
    "TwoDescentEngine", "FullDescentEngine", "DescentResult",
    "HeegnerPointEngine", "EnhancedRankComputer", "RankResult",
    "TorsionAnalyzer", "TorsionStructure",
    "KodairaAnalyzer", "TamagawaResult",
    "BSDProverError", "CurveError", "ComputationError",
    "get_version_info", "DEFAULT_CONFIG",
]
