Sexagesimal Rational Mathematics Library
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cuneiform-0.1.0.tar.gz.
File metadata
- Download URL: cuneiform-0.1.0.tar.gz
- Upload date:
- Size: 146.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f159c50aafc85048f2821229eb527cd6c470f334f7d2b4291f383aab223b69bd
|
|
| MD5 |
7b8c5ce4d65fba4df6e3ec8d43c3a73f
|
|
| BLAKE2b-256 |
9d4394422cd3fc25bf6bddefbc22ac0c1f9dd003ce2924697b6779ec38fd86b5
|
File details
Details for the file cuneiform-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cuneiform-0.1.0-py3-none-any.whl
- Upload date:
- Size: 141.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32521d2f59ded1e147f64bc9e72bc9c02756065d38a18b6eaf1991e1cb6c1430
|
|
| MD5 |
1f92dc24421ed3f810066a6dba7ef4f9
|
|
| BLAKE2b-256 |
98e27dc88cfbc7bc0598f1fb3d163263e61f3ee90da41a564c6ddf0512c8a7f8
|