This document provides technical details about the advanced TNFR infrastructure integration in the primality testing package.
from tnfr_primality.advanced_core import HAS_TNFR_INFRASTRUCTURE, get_infrastructure_status
# Automatic detection of available TNFR components
if HAS_TNFR_INFRASTRUCTURE:
print("Full TNFR repository integration available")
print(get_infrastructure_status())
else:
print("Using fallback algorithms")Key Features:
--infrastructure-statusfrom tnfr.mathematics.arithmetic_networks import ArithmeticTNFRNetwork
# Create advanced network for comprehensive analysis
network = ArithmeticTNFRNetwork(max_number=1000)
stats = network.summary_statistics()
# Access advanced metrics
prime_ratio = stats['prime_ratio']
delta_nfr_separation = stats['DELTA_NFR_separation']Capabilities:
from tnfr.utils.cache import TNFRHierarchicalCache, cache_tnfr_computation
@cache_tnfr_computation(cache_level=CacheLevel.AGGRESSIVE)
def optimized_function(n):
return expensive_computation(n)Architecture:
from tnfr.mathematics.constants import (
PHI, GAMMA, PI, E, # Universal mathematical constants
MATH_DELTA_NFR_THRESHOLD_CANONICAL # TNFR-specific thresholds
)
# Direct use of repository constants in computations
delta_nfr = compute_structural_pressure(n, phi=PHI, gamma=GAMMA)Constants Available: the engine exposes PHI, GAMMA, PI, E as notational labels for parameters. Only π is a genuine structural scale (it bounds the phase sector); φ, γ, e are notational. A canonical tolerance (≈ 0.0676) is also exposed.
certificate = tnfr_is_prime_advanced(997, return_certificate=True)
print(f"Explanation: {certificate.explanation}")
print(f"τ(n) = {certificate.tau}") # Divisor count
print(f"σ(n) = {certificate.sigma}") # Divisor sum
print(f"ω(n) = {certificate.omega}") # Distinct prime factor countCertificate Features:
Algorithm: O(log n) complexity for ω(n) computation
Integration: SymPy for exact arithmetic when needed
Backends Supported:
# Comprehensive system diagnostics
python -m tnfr_primality --infrastructure-status
# Output includes:
# - Available TNFR components
# - System information
# - Canonical constants verification
# - Cache status and configuration# Explicit advanced algorithm usage
python -m tnfr_primality --advanced 17 97 997
# Cached computation for performance
python -m tnfr_primality --advanced --cached 17 97 997
# JSON output with full certificate data
python -m tnfr_primality --advanced 17 --json-output# Advanced benchmark with analytics
python -m tnfr_primality --benchmark 1000 --advanced --cached
# Includes:
# - Performance metrics (numbers/second)
# - Cache hit rates
# - Algorithm comparison data
# - Memory usage statistics# Basic integration
from tnfr_primality import tnfr_is_prime
is_prime, delta_nfr = tnfr_is_prime(997) # Auto-detects best algorithm
# Advanced integration
from tnfr_primality.advanced_core import (
tnfr_is_prime_advanced,
cached_tnfr_is_prime_advanced,
validate_tnfr_theory_advanced
)
# Get detailed analysis
certificate = tnfr_is_prime_advanced(997, return_certificate=True)
# High-performance batch processing
results = []
for n in range(1000, 2000):
is_prime, delta_nfr = cached_tnfr_is_prime_advanced(n)
results.append((n, is_prime, delta_nfr))
# Comprehensive theory validation
validation = validate_tnfr_theory_advanced(max_n=10000)
print(f"Accuracy: {validation['accuracy']}")import json
# Get validation results as JSON
validation = validate_tnfr_theory_advanced(max_n=100)
json_output = json.dumps(validation, indent=2)
# Parse results for integration
data = json.loads(json_output)
prime_examples = data['prime_examples']
performance_ms = data['performance_ms']The system automatically handles missing components:
from tnfr_primality.advanced_core import get_system_info
info = get_system_info()
print(f"Infrastructure available: {info['infrastructure_available']}")
print(f"Cache available: {info['cache_available']}")
print(f"Constants verified: {info['constants']}")The implementation uses the four-field tetrad (associated with the four constants notationally — only π is a genuine structural scale):
All 13 canonical operators from TNFR theory are available:
All operations comply with TNFR unified grammar rules U1-U6:
This advanced integration is released under the MIT License, same as the main TNFR repository.