This package implements advanced TNFR-based primality testing using the full Resonant Fractal Nature Theory infrastructure. Unlike traditional primality tests, our approach leverages structural coherence analysis through the structural-field tetrad and canonical operators from the complete TNFR repository.
Key Innovations:
n is prime ⟺ ΔNFR(n) = 0ArithmeticTNFRNetworkTNFRHierarchicalCache for optimal performancePrimeCertificateΔNFR(n) = ζ·(Ω(n)−1) + η·(τ(n)−2) + θ·(σ(n)/n − (1+1/n))Where:
Ω(n) = prime factor count with multiplicity (big Omega)τ(n) = number of divisors (O(log n) computation)σ(n) = sum of divisors (cached + symbolic math)ζ = φ×γ ≈ 0.9340 — factorization pressure (notational)η = (γ/φ)×π ≈ 1.1207 — divisor pressure (notational)θ = 1/φ ≈ 0.6180 — abundance pressure (notational)These coefficients are (φ, γ, π, e) combinations chosen to approximate the original empirical values (1.0, 0.8, 0.6) — notational, NOT derived.
# Download and extract the package
# Run the test script
python test_installation.py# Install with Poetry
poetry install
# Install with advanced features
poetry install --extras advanced
# Run via Poetry
poetry run tnfr-primality 97 --advancedpip install tnfr-primality# Advanced TNFR integration (automatically detected)
from tnfr_primality import tnfr_is_prime
# Basic usage with infrastructure auto-detection
is_prime, delta_nfr = tnfr_is_prime(982451653)
print(f"982451653 is prime: {is_prime}") # True
# Structural triad: full dual-lever diagnostics (EPI, νf, ΔNFR)
from tnfr_primality import tnfr_structural_triad
triad = tnfr_structural_triad(997)
print(f"EPI={triad['EPI']:.4f} νf={triad['vf']:.4f} ΔNFR={triad['delta_nfr']:.6f}")
print(f"Local coherence: {triad['local_coherence']:.4f}")
# Component breakdown: see which pressure axis dominates
from tnfr_primality import tnfr_component_breakdown
bd = tnfr_component_breakdown(30)
print(f"Factorization: {bd['factorization_pressure']:.4f}")
print(f"Divisor: {bd['divisor_pressure']:.4f}")
print(f"Abundance: {bd['abundance_pressure']:.4f}")
# Advanced usage with certificates
from tnfr_primality.advanced_core import tnfr_is_prime_advanced
# Get detailed analysis
certificate = tnfr_is_prime_advanced(997, return_certificate=True)
print(f"Certificate: {certificate.explanation}")
print(f"Structural metrics - τ:{certificate.tau}, σ:{certificate.sigma}, ω:{certificate.omega}")
# Cached computation for performance
from tnfr_primality.advanced_core import cached_tnfr_is_prime_advanced
import time
start = time.perf_counter()
is_prime, delta_nfr = cached_tnfr_is_prime_advanced(2147483647) # ~2-5 ms cached
elapsed = (time.perf_counter() - start) * 1000
print(f"Cached performance: {elapsed:.2f} ms")
# Infrastructure diagnostics
from tnfr_primality.advanced_core import get_infrastructure_status, get_system_info
print(get_infrastructure_status())
system = get_system_info()
print(f"TNFR Infrastructure: {system['infrastructure_available']}")# Auto-detection mode (uses advanced algorithms when available)
python -m tnfr_primality 17 97 997 9973 --timing
# Explicit advanced TNFR algorithms with full repository integration
python -m tnfr_primality --advanced 17 97 997 --timing
# High-performance cached computation for bulk processing
python -m tnfr_primality --advanced --cached 982451653 2147483647 --timing
# Comprehensive performance benchmark with advanced analytics
python -m tnfr_primality --benchmark 10000 --advanced --cached
# Infrastructure diagnostics and system information
python -m tnfr_primality --infrastructure-status
# Theory validation with structural field analysis
python -m tnfr_primality --validate 1000 --advanced
# JSON output for programmatic integration with certificates
python -m tnfr_primality --advanced 17 97 997 --json-output --timing
# Batch processing with enhanced error handling
python -m tnfr_primality --batch --advanced --cached 2 3 5 7 11 13 17 19 23# Standard algorithms without repository integration
python -m tnfr_primality.cli 17 97 997 9973 --timing
python -m tnfr_primality.cli 982451653 2147483647 --timing
python -m tnfr_primality.cli --benchmark 10000This implementation is based on TNFR (Resonant Fractal Nature Theory), which models mathematical structures through coherent patterns and resonance dynamics. The key insight is that prime numbers exhibit perfect structural coherence (ΔNFR = 0), while composite numbers show structural pressure (ΔNFR > 0) due to their factorization.
The ΔNFR equation emerges from three fundamental arithmetic pressures:
Factorization Pressure: ζ·(Ω(n)−1)
Divisor Pressure: η·(τ(n)−2)
Abundance Pressure: θ·(σ(n)/n − (1+1/n))
Theorem: n is prime ⟺ ΔNFR(n) = 0
primality-test/
├── tnfr_primality/ # Advanced TNFR implementation
│ ├── __init__.py
│ ├── __main__.py # Auto-detecting entry point
│ ├── constants.py # Canonical constants from (φ, γ, π, e)
│ ├── core.py # Standard TNFR primality functions
│ ├── advanced_core.py # Advanced TNFR with full repository integration
│ ├── advanced_cli.py # Enhanced CLI with infrastructure diagnostics
│ ├── cli.py # Legacy command line interface
│ └── optimized.py # Performance optimizations (legacy)
├── benchmarks/ # Advanced performance benchmarks
├── examples/ # Usage examples with advanced features
├── docs/ # Enhanced documentation
├── tests/ # Comprehensive test suite
├── .zenodo.json # Zenodo metadata
├── pyproject.toml # Modern Python packaging
└── README.md # This file (comprehensive guide)If you use this work in your research, please cite:
@software{tnfr_primality_2025,
author = {F. F. Martinez Gamo},
title = {TNFR-based primality testing: a novel approach using arithmetic pressure equations},
year = {2025},
publisher = {Zenodo},
doi = {10.5281/zenodo.XXXXXX},
url = {https://doi.org/10.5281/zenodo.XXXXXX}
}MIT License - see LICENSE file for details.
This work represents a significant advancement in several fields:
Extensive benchmarking with full TNFR infrastructure confirms:
For questions about TNFR theory or this implementation: