CUNEIFORM
A Python library for exact sexagesimal (base-60) rational arithmetic, with applications to computational number theory and cryptographic analysis.
What it does
The sexagesimal number system has a useful property: fractions with 5-smooth denominators (prime factors limited to 2, 3, 5) have terminating representations. CUNEIFORM formalizes this through a regularity classification that decomposes integers by their "distance" from being 5-smooth, then investigates whether this decomposition interacts usefully with smooth number detection — the computational bottleneck in integer factorization algorithms like the Quadratic Sieve and Number Field Sieve.
The library also implements Wildberger's rational trigonometry (quadrance/spread instead of distance/angle), reproduces and extends Plimpton 322 (a ~1800 BCE tablet containing 15 Pythagorean triples with 5-smooth generators), and provides a computer algebra system over the rationals.
Install
python -m venv .venv
source .venv/bin/activate
pip install -e .
For 10-100x faster big-integer arithmetic (recommended for factoring scripts):
pip install -e ".[fast]"
This installs gmpy2 which wraps the GMP library. The library works without it, but number theory operations on large integers will be significantly slower. The acceleration is automatic — no code changes needed.
Quick start
from cuneiform.core.sexagesimal import Sexa
from cuneiform.core.rational import SexaRational
# Sexagesimal notation: 1;30 = 1 + 30/60 = 3/2
x = Sexa("1;30")
print(x.as_fraction) # 3/2
# Exact rational arithmetic — no floats anywhere
a = SexaRational(1, 3)
b = SexaRational(1, 5)
print(a + b) # 8/15
# Regularity classification
from cuneiform.number_theory.regularity import RegularityClass
rc = RegularityClass(360)
print(rc.regularity_tier) # 0 (fully 5-smooth)
print(rc.is_regular) # True
rc2 = RegularityClass(77) # 7 * 11
print(rc2.regularity_tier) # 2 (two non-smooth prime factors)
CLI
python -m cuneiform info # library overview
python -m cuneiform validate # 8 mathematical identity checks
python -m cuneiform tabulate --format csv # extend Plimpton 322 to thousands of rows
python -m cuneiform experiment smooth-density --bits 64 --trials 100 --seed 42
python -m cuneiform paper -o paper.tex # generate LaTeX paper with real data
Modules
| Module | What it provides |
|---|---|
core |
Sexa (base-60 notation), SexaRational (exact rationals), SmoothNumber |
tablet |
Plimpton 322 reproduction — all 15 original rows verified against published scholarship |
geometry |
Rational trigonometry: Quadrance, Spread, all 5 laws, constructions |
number_theory |
Regularity classification, Quadratic Sieve (standard + sexagesimal variant), ECM, smoothness analysis |
crypto |
Scaling analysis, RSA regularity profiling, pure-Python LLL, elliptic curve arithmetic, post-quantum parameter survey |
cas |
RatPoly (polynomial algebra), RatMatrix (exact linear algebra), algebraic calculus, SmoothRing (Z[1/60]) |
quantum |
Classical simulation of Shor period-finding (binary vs sexagesimal QFT), Grover oracle gate analysis |
archaeology |
Tablet analyzer (relationship detection, scribal error detection, gap filling), corpus of known tablets |
hardware |
SexaALU behavioral simulation — 19 opcodes, 16 registers, cycle-accurate |
finance |
Rational price levels, support/resistance via regularity, pattern geometry |
math_expansion |
Chromogeometry, finite field rational trig, p-adic valuations |
education |
Interactive exercises (multiplication, reciprocals, square roots, triple generation) |
experiments |
Smooth density experiment, Plimpton tabulator, benchmark framework, paper pipeline |
publication |
LaTeX paper/figure/table generators with pgfplots output |
Key concepts
Regularity tier: For integer n, extract the largest 5-smooth divisor (the "regular part") and count the prime factors of the remaining cofactor. Tier 0 = fully 5-smooth. Tier 1 = one non-smooth prime factor. Higher tiers = further from regular.
The hypothesis: QS polynomial values at low regularity tiers may have higher B-smooth rates than those at high tiers, because the 5-smooth factor is "already done." The experiments module measures this and the crypto.scaling module tests whether any effect persists at larger bit sizes.
Rational trigonometry: Replace distance with quadrance (d²) and angle with spread (sin²θ). All five laws are algebraic identities over Q — no transcendental functions, no floating point.
Tests
pytest # 672 tests, ~18s
Project structure
cuneiform/ # library source
core/ # Sexa, SexaRational, SmoothNumber
tablet/ # Plimpton 322
geometry/ # rational trigonometry
number_theory/ # regularity, sieves, ECM, analysis
crypto/ # RSA, lattice, EC, post-quantum, scaling
cas/ # polynomials, matrices, calculus, Z[1/60]
quantum/ # Shor/Grover simulations
archaeology/ # tablet analysis and corpus
hardware/ # SexaALU simulation
finance/ # rational price analysis
math_expansion/ # chromogeometry, finite fields, p-adic
education/ # interactive exercises
experiments/ # experiment runners and paper pipeline
publication/ # LaTeX generation
tests/ # 672 tests
examples/ # standalone usage examples
primes/ # experimental RSA factoring scripts (just for fun)
License
MIT
Metadata
Release files for cuneiform 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cuneiform-0.1.0.tar.gz | 146.7 kB | Without provenance | Details for cuneiform-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cuneiform-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cuneiform-0.1.0-py3-none-any.whl |
Total release size: 288.0 kB
Release files / cuneiform-0.1.0.tar.gz
| Download URL | cuneiform-0.1.0.tar.gz |
|---|---|
| Size | 146.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f159c50aafc85048f2821229eb527cd6c470f334f7d2b4291f383aab223b69bd
|
|
BLAKE2b-256 checksum How to use checksums |
9d4394422cd3fc25bf6bddefbc22ac0c1f9dd003ce2924697b6779ec38fd86b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / cuneiform-0.1.0-py3-none-any.whl
| Download URL | cuneiform-0.1.0-py3-none-any.whl |
|---|---|
| Size | 141.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32521d2f59ded1e147f64bc9e72bc9c02756065d38a18b6eaf1991e1cb6c1430
|
|
BLAKE2b-256 checksum How to use checksums |
98e27dc88cfbc7bc0598f1fb3d163263e61f3ee90da41a564c6ddf0512c8a7f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for cuneiform 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.