Skip to main content

adinkra-math

West African Adinkra symbols as a mathematical framework — symbolic encoding, topology, supersymmetry, and machine learning.

What This Does

adinkra-math implements the mathematics inspired by Adinkra symbols — the visual symbols of the Ashanti people of West Africa. It provides symbolic encoding of concepts as geometric primitives, glyph composition with invariant preservation, topological analysis (Euler characteristic, genus), supersymmetry Adinkra graphs (Boson-Fermion classification with chromotopology verification), and basic ML operations (kNN, K-means) on symbol vectors. Use it for symbolic AI, topological data analysis, physics simulations, or cultural math education.

The Cultural Root

Adinkra symbols originated with the Ashanti (Asante) people of Ghana and Côte d'Ivoire. Each symbol encodes a proverb or concept — Sankofa ("go back and fetch it") represents learning from the past. The mathematical insight: symbols compress complex meaning into structured geometric primitives, which is exactly what feature vectors do in machine learning. Adinkras also appear in theoretical physics: supersymmetry Adinkras are bipartite graphs encoding the relationship between bosons and fermions.

Install

pip install adinkra-math

Quick Start

from adinkramath.symbol import Symbol, SymbolType, get_builtin_symbols
from adinkramath.glyph import Glyph, GlyphOperation, compose
from adinkramath.topology import euler_characteristic, genus
from adinkramath.encoding import encode_concept, knn, kmeans
from adinkramath.supersymmetry import create_adinkra, verify_chromotopology

# Work with built-in Adinkra symbols
symbols = get_builtin_symbols()
for s in symbols:
    print(f"{s.name}: {s.to_vector()}")

# Compose glyphs (symbols combined)
g1 = Glyph(symbols=[symbols[0]])
g2 = Glyph(symbols=[symbols[1]])
composed = compose(g1, g2, GlyphOperation.OVERLAY)
print(f"Composed weight: {composed.total_weight()}")

# Check topological invariant
from adinkramath.glyph import preserve_invariant
print(f"Invariant preserved: {preserve_invariant(composed)}")

# Encode concepts as vectors
c1 = encode_concept("courage", seed=42)
c2 = encode_concept("wisdom", seed=42)
print(f"Vector length: {len(c1.vector)}")

# K-nearest neighbors
from adinkramath.encoding import Concept, nearest_concept
concepts = [encode_concept(w, seed=0) for w in ["love", "war", "peace", "fear"]]
result = nearest_concept(encode_concept("bravery", seed=0).vector, concepts)

# K-means clustering
clusters = kmeans(concepts, k=2)

# Supersymmetry Adinkras
adinkra = create_adinkra(rank=2)
print(f"Bosons: {len(adinkra.bosons)}, Fermions: {len(adinkra.fermions)}")
valid = verify_chromotopology(adinkra)
print(f"Chromotopology valid: {valid}")

# Topology
euler = euler_characteristic(vertices=8, edges=12, faces=6)
print(f"Euler characteristic: {euler}, Genus: {genus(euler)}")

API Reference

symbol module

SymbolType (enum)

CIRCLE, SPIRAL, CROSS, KNOT, LINE, ARC, TRIANGLE, DIAMOND — fundamental geometric primitives.

Symbol

@dataclass
class Symbol:
    name: str
    primitives: list[tuple[SymbolType, dict]]  # (type, parameters)
    meaning: str
    weight: float = 1.0

    def to_vector(self) -> list[float]

get_builtin_symbols() → list[Symbol]

Returns nine canonical Adinkra glyphs with their geometric primitives.

glyph module

GlyphOperation (enum)

STACK, NEST, INTERLEAVE, MIRROR, OVERLAY — ways to combine glyphs.

Glyph

class Glyph:
    symbols: list[Symbol]

    def primitives(self) -> list[tuple]
    def total_weight(self) -> float

compose(g1, g2, operation) → Glyph

Combine two glyphs. Returns a new Glyph with merged primitives.

preserve_invariant(glyph) → bool

Check if the glyph preserves the Adinkra topological invariant (must contain both closed and open primitives).

topology module

connected_components(graph) → int

Count connected components in an adjacency-list graph.

euler_characteristic(vertices, edges, faces) → int

Compute χ = V − E + F. For a sphere, χ = 2.

genus(euler_char) → int

Compute genus g = (2 − χ) / 2. Sphere → 0, torus → 1.

encoding module

Concept

@dataclass
class Concept:
    label: str
    vector: list[float]

encode_concept(text, dimensions=16, seed=None) → Concept

Deterministically hash text to a fixed-length float vector.

distance(v1, v2) → float

Euclidean distance between vectors.

nearest_concept(vector, concepts) → Concept

Find the closest concept by Euclidean distance.

knn(query, concepts, k=5) → list[Concept]

K-nearest neighbors search.

kmeans(concepts, k=3, max_iter=100) → list[list[Concept]]

Simple K-means clustering on concept vectors.

supersymmetry module

SUSYAdinkra

@dataclass
class SUSYAdinkra:
    rank: int
    bosons: list[int]
    fermions: list[int]
    edges: list[tuple[int, int, int]]  # (boson, fermion, generator_index)

create_adinkra(rank) → SUSYAdinkra

Create a rank-N supersymmetry Adinkra with 2^(N-1) bosons and 2^(N-1) fermions.

verify_chromotopology(adinkra) → bool

Verify: (1) every node has exactly N edges, (2) each generator index appears once per node, (3) two-colorability holds.

boson_fermion_split(adinkra) → tuple[list, list]

Split the Adinkra into bosonic and fermionic sectors.

How It Works

Symbol Vectors: Each SymbolType maps to a dimension in a fixed-length feature vector. A symbol's vector is the weighted sum of its primitives' contributions.

Concept Encoding: Uses deterministic hashing (SHA-family) to map arbitrary text to a float vector of configurable dimension. Same input always produces the same vector.

K-means: Standard Lloyd's algorithm — random initialization, assign to nearest centroid, recompute centroids, repeat until convergence or max iterations.

SUSY Adinkras: For rank N, creates 2^(N-1) boson and 2^(N-1) fermion nodes connected by N generators. The chromotopology conditions ensure the graph properly represents supersymmetry algebra.

The Math

Euler Characteristic: χ = V − E + F. For orientable closed surfaces: genus g = (2 − χ)/2.

Supersymmetry Adinkras: For N supersymmetry generators, the Adinkra has 2^(N-1) bosons and 2^(N-1) fermions. Each node has degree N. The chromotopology ensures the "dashing" (chromatic structure) is consistent with the Clifford algebra underlying supersymmetry.

K-means Objective: Minimize J = Σₖ Σ_{x∈Cₖ} ||x − μₖ||² where μₖ is the centroid of cluster Cₖ.

License

MIT

Metadata

Release files for adinkra-math 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adinkra-math 0.2.0
File Size Uploaded Provenance Actions
adinkra_math-0.2.0.tar.gz 12.7 kB Without provenance Details for adinkra_math-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adinkra-math 0.2.0
File Interpreter ABI Platform Actions
adinkra_math-0.2.0-py3-none-any.whl Python 3 none any Details for adinkra_math-0.2.0-py3-none-any.whl

Total release size: 25.2 kB

Release files / adinkra_math-0.2.0.tar.gz

Download URL adinkra_math-0.2.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b20811895475f47651d77bc49567c2159077b85e254e7e5efaacbe7f4490efda
BLAKE2b-256 checksum
How to use checksums
f24433ff33434fd4014249ad15da93f0aec40a52d8681ae398da69c7d12819a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / adinkra_math-0.2.0-py3-none-any.whl

Download URL adinkra_math-0.2.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac420bee8c003399aee439dc61c42ada36691970a109f4a183c2dd24d0b8313b
BLAKE2b-256 checksum
How to use checksums
2dc7d0fce6b16e44d22f6881819b50ab895f7c5ade07edf16c84c2e04667c00b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for adinkra-math 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page