Skip to main content

Fundamental Theorem of Arithmetic as a coordinate system — divisibility lattices for any domain

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adelic_fta-0.1.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adelic_fta-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file adelic_fta-0.1.0.tar.gz.

File metadata

  • Download URL: adelic_fta-0.1.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for adelic_fta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 89c8497bc4c1aaff40d199ba07ef4e78b75311f30dc1fc3853cdcd2cb106718a
MD5 aa3c938d4249976b68985dcdcb546040
BLAKE2b-256 75f21dfc49a438333c0ab88ba7450ae5ab2250f14d94d8b9d05e9010ec829b5d

See more details on using hashes here.

File details

Details for the file adelic_fta-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: adelic_fta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for adelic_fta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f16d41cc04c9634c4f70f98deaf55a878bc1622334fe879e3d3d27f2b7ef3176
MD5 bb2446b2856fc0abe5eef31a3e5a7bcb
BLAKE2b-256 1c53607c03b11fdb26897c69279f8a019e090e9edde51277a51971eb13b928ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page