fta
Fundamental Theorem of Arithmetic as a coordinate system.
Every positive integer has a unique prime factorization. fta treats that
factorization as a coordinate system — each prime is an axis, each exponent is
a coordinate. Under this embedding, divisibility becomes geometry.
The central object is Lattice(n): the complete divisibility structure of an
integer. Give it a number; get back every way it can be cleanly subdivided and
how those subdivisions relate to each other.
No assumptions about what the integers represent. The domain sits entirely outside this package.
Install
pip install fta
Usage
from fta import Lattice
L = Lattice(12)
L.members() # (1, 2, 3, 4, 6, 12) — all divisors
L.covers(3) # (6,) — immediate parent in Hasse diagram
L.covered_by(6) # (2, 3) — immediate children
L.hasse_edges() # all (child, parent) pairs
L.meet(4, 6) # 2 — gcd
L.join(4, 6) # 12 — lcm
L.divides(3, 6) # True
L.depth(4) # 2 — steps from bottom (1)
L.height(4) # 1 — steps to top (n)
L.members_lte(6) # (1, 2, 3, 6) — downward closure
L.members_gte(3) # (3, 6, 12) — upward closure
L.primes() # (2, 3) — prime axes
L.coordinate(12) # {2: 2, 3: 1} — prime exponent vector
Standalone utilities:
from fta import factorize, smallest_divisor_gte
factorize(360) # {2: 3, 3: 2, 5: 1}
smallest_divisor_gte(3600, 250) # 300 — smallest divisor of 3600 that is >= 250
Applications
Lattice(n) is useful anywhere you need to know how an integer can be
hierarchically subdivided. The arithmetic is the same across all of these —
only the interpretation of the integers changes.
Signal processing — Given a time horizon (e.g. 86400 seconds = one day)
and a finest meaningful unit (e.g. 60 seconds = one minute), Lattice(86400)
gives every valid measurement window and how they relate. The divisibility
structure ensures windows at different scales are arithmetically coherent with
each other.
Database partitioning — Choosing partition sizes that divide cleanly into
each other avoids remainder handling and uneven splits. Lattice(n) for your
table size gives every valid partition size and the hierarchy between them.
Compiler / loop tiling — A CPU cache line is 64 bytes, an AVX register is
256 bits, a memory page is 4096 bytes. Valid tile sizes must divide the working
set size cleanly. Lattice(n).members() enumerates all valid tile sizes;
covers() gives the next level up in the memory hierarchy.
Music / tuning theory — Just intonation intervals are ratios of small integers. The divisibility lattice of a frequency denominator gives all harmonically related intervals and their relationships.
Scheduling — Valid sub-period sizes for a time period (e.g. tasks that fit
evenly into a one-hour window). members() gives every valid granularity;
covers() gives the next coarser level.
Mathematical background
Under the prime exponent coordinate embedding:
| Operation | Integer arithmetic | Coordinate arithmetic |
|---|---|---|
| Multiply | a × b | coordinate-wise add |
| Divide | a / b | coordinate-wise sub |
| Divides | a | b | coordinate-wise ≤ |
| GCD | gcd(a, b) | coordinate-wise min |
| LCM | lcm(a, b) | coordinate-wise max |
The Hasse diagram of the divisibility lattice is the graph where m2 covers m1 iff m2/m1 is prime — one step along a single prime axis.
License
MIT
Metadata
Release files for adelic-fta 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 | |
|---|---|---|---|---|
| adelic_fta-0.1.0.tar.gz | 31.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adelic_fta-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.8 kB
Release files / adelic_fta-0.1.0.tar.gz
| Download URL | adelic_fta-0.1.0.tar.gz |
|---|---|
| Size | 31.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89c8497bc4c1aaff40d199ba07ef4e78b75311f30dc1fc3853cdcd2cb106718a
|
|
BLAKE2b-256 checksum How to use checksums |
75f21dfc49a438333c0ab88ba7450ae5ab2250f14d94d8b9d05e9010ec829b5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / adelic_fta-0.1.0-py3-none-any.whl
| Download URL | adelic_fta-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f16d41cc04c9634c4f70f98deaf55a878bc1622334fe879e3d3d27f2b7ef3176
|
|
BLAKE2b-256 checksum How to use checksums |
1c53607c03b11fdb26897c69279f8a019e090e9edde51277a51971eb13b928ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for adelic-fta 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.