This repository presents a theoretical and computational framework for analyzing discrete integer sequences through a geometry-inspired curvature model. By drawing a pedagogical analogy to relativistic distortions, it defines a forward diagnostic map that highlights structural irregularities—especially those arising from divisor density—and a calibrated recovery path that infers traversal rate v from observed Z sequences under an explicit support prior. The model remains pointwise forward in n and does not perform blind inversion of unknown integers, but it is now distributionally inverse in v when the source regime is calibrated.
🆕 The Cognitive Distortion Layer (CDL) standardizes κ(n) as the shared curvature signal across the Z Framework, providing unified primitives for prime diagnostics, QMC sampling, and signal normalization. Source modules now live under src/python/, with specifications in docs/specification/CDL_SPECIFICATION.md and docs/specification/INTEGRATION.md.
-
Curvature Function:
$\kappa(n) = \frac{d(n) \cdot \ln(n)}{e^2}$ -
d(n): Divisor count of
$n$ (i.e., $\sigma_0(n)$). -
ln(n): Natural logarithm of
$n$ . -
Normalization: Constant
$e^2$ determined empirically. - Interpretation: Higher divisor counts and larger values yield greater local "curvature".
-
d(n): Divisor count of
-
Distortion Mapping (Forward Model):
$\Delta_n = v \cdot \kappa(n)$ -
v: A traversal-rate parameter. In forward use it may be user-supplied. In recovery use it is inferred from observed
Zvalues relative to a calibrated support prior. -
$\Delta_n$ : Modeled distortion at$n$ . - Purpose: Encodes how rapid progression through integers skews apparent structure.
-
v: A traversal-rate parameter. In forward use it may be user-supplied. In recovery use it is inferred from observed
-
Perceived Value:
$n_{\text{perceived}} = n \times \exp\bigl(\Delta_n\bigr)$ - Applies exponential scaling to the true integer based on
$\Delta_n$ . - Emphasizes how distortion amplifies structural irregularities in composites.
- Applies exponential scaling to the true integer based on
-
Z-Transformation (Context-Dependent Normalization):
$Z(n) ;=; \frac{n}{\exp\bigl(v \cdot \kappa(n)\bigr)}$ -
Pointwise forward in
$n$ : Assumes knowledge of$n$ and$v$ to normalize a specific integer. -
Distributionally inverse in
$v$ : Under a calibrated support or sequence prior, observedZvalues recover traversal rate through moment matching, MLE, or distributional fingerprints. - Outcome: Reveals underlying structural stability and exposes the process regime that generated the observed distortion pattern.
-
Pointwise forward in
-
Prime vs. Composite Curvature (n = 2–49)
- Prime average curvature: ~0.739
- Composite average curvature: ~2.252
- Ratio: Composites ≈3.05× higher curvature
-
Classification Test
- Simple threshold on
$\kappa(n)$ yields ~83% accuracy distinguishing primes from composites.
- Simple threshold on
These results demonstrate that primes appear as "minimal-curvature geodesics" within the discrete sequence, providing a quantitative diagnostic measure of number complexity.
-
Language: Python 3
-
Source Layout:
src/python/cdl.py: Canonical CDL primitivessrc/python/cdl_continuous.py: Continuous-domain CDL extensionssrc/python/v_recovery.py: Traversal-rate inferencesrc/python/cognitive_pilot.py: Sprint 6 cognitive pilot pipeline
-
Repository Layout:
docs/: Specifications, summaries, roadmap, and concept notesdata/: Reference data and generated simulation tracesartifacts/: Generated reports and figuresexperiments/: Research sprint outputs and benchmarksscripts/: Demo, dashboard, report, and reproduction utilitiestests/: Reorganized pytest suite
The Cognitive Distortion Layer provides production-ready primitives:
import cdl
# Core primitive 1: Curvature signal
kappa_value = cdl.kappa(17) # Returns κ(n)
# Core primitive 2: Threshold classifier
classification = cdl.classify(17, threshold=1.5) # "prime" or "composite"
# Core primitive 3: Z-normalization
z_value = cdl.z_normalize(17, v=1.0) # Returns Z(n)
# Integration helpers
likely_primes, likely_composites = cdl.prime_diagnostic_prefilter(candidates)
biased_candidates = cdl.qmc_sampling_bias(candidates, bias_strength=0.8)
normalized_signals = cdl.signal_normalize_pipeline(raw_signals, v=1.0)See docs/specification/INTEGRATION.md for complete integration examples.
The distributional recovery path treats v as an observable once the source regime is calibrated:
import numpy as np
from v_recovery import VRecovery, generate_z_sequence
rng = np.random.default_rng(321)
recovery = VRecovery(
calibration_n_max=3000,
sample_size=500,
sequence_type="random",
reference_trials=10,
random_seed=321,
)
z_sequence, _ = generate_z_sequence(
numbers=recovery.numbers,
kappas=recovery.kappas,
rng=rng,
v=1.5,
sample_size=500,
sequence_type="random",
prime_mask=recovery.prime_mask,
)
estimate = recovery.infer_v(z_sequence, method="fingerprint")
print(estimate.v_estimate)The same recovery path is used in src/python/cognitive_pilot.py to recover participant-level v values from observed response traces.
The geodesic prime prefilter has moved to the standalone repository geodesic-prime-prefilter.
CDL remains the research home for the core curvature primitives and the broader Z Framework. The standalone repository now carries the production Python package, golden vectors, manual validation flow, and the multi-language porting surface for the prefilter.
The standalone gist lives at scripts/demos/curvature_gist.py and has only numpy as a dependency:
# Basic usage (n = 2-50, default parameters)
python scripts/demos/curvature_gist.py
# Extended analysis with 10,000 numbers
python scripts/demos/curvature_gist.py --max-n 10000
# Custom v-parameter for Z-transformation
python scripts/demos/curvature_gist.py --max-n 1000 --v-param 0.5
# Fewer bootstrap samples for faster execution
python scripts/demos/curvature_gist.py --max-n 100 --bootstrap-samples 500Key Features:
- Instant computation for custom n ranges
- Built-in primality checks and bootstrap CI reporting
- Extensible v-parameter tuning for Z-normalization
- Outputs
data/reference/kappas.csvwith (n, κ(n), Z(n)) data - ~83% classification accuracy for prime vs composite
The gist can also be imported as a module:
# Run complete cognitive model with visualizations
python scripts/demos/main.pyGenerates curvature statistics, writes figures into artifacts/figures/, and writes CSV traces into data/simulated/.
# Run CDL test suite
python tests/test_suite.py
# Generate baseline validation report
python scripts/reports/baseline_report.py
# Generate visualization dashboards
python scripts/dashboards/generate_cdl_dashboards.py
# Run the full Sprint 1–6 local reproduction
python scripts/reproduce_sprints.pyValidation Results:
- Seed set (n=2-49): Prime avg κ = 0.739, Composite avg κ = 2.252, Accuracy = 83.7%
- Hold-out (n=50-10K): Accuracy = 88.2%, maintains separation pattern
- Z-normalization: 99.2% variance reduction
- v recovery: integer-space tests meet MLE
±0.05, fingerprint±0.10, and moment-match±0.10tolerances; continuous recovery meets fingerprint±0.05; the deterministic cognitive pilot recovers participantvwithin±0.15 - All acceptance criteria met ✓
The baseline report is written to artifacts/reports/baseline_report.json.
-
No Standalone Inverse for Unknown Integers
- The Z-transformation requires known
$n$ and rate$v$ for pointwise normalization. It does not recover unknown integers from isolated observed values.
- The Z-transformation requires known
-
Distributional Recovery Requires Calibration
- Traversal rate
vis recoverable from observedZsequences only relative to an explicit support prior or calibrated sequence regime. Prior mismatch can shift the recovered value.
- Traversal rate
-
Process Channel Exposure
- Because
Zdistributions retain information aboutv, normalized outputs can fingerprint the generating or perceptual pipeline when the support law is known.
- Because
-
Metaphorical Analogy
- References to relativity and geodesics are pedagogical. The core mathematics stands independently of physical interpretations.
- Prior-Robust Recovery: Infer
vreliably when the support law is only partially known, and characterize identifiability under prior mismatch. - Process Fingerprinting: Use recovered
vandZfingerprints to audit samplers, detect drift, and compare generation regimes. - Divisor-Family Resonances: Characterize the fixed-point law
v = e^2 / dacross exact divisor-count families beyond the primed = 2band. - Enhanced Classification: Integrate curvature features into machine-learning classifiers for primality testing.
- Theoretical Extensions: Investigate connections between divisor-based curvature and deeper analytic number theory.
