Created
June 15, 2025 20:43
-
-
Save afflom/f02099dc161d15d6a5ecf4d34df4d65f to your computer and use it in GitHub Desktop.
Coherence Object Calculus Example in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Computational demonstration of two foundational lemmas in Coherent Object Calculus (COC) | |
# 1. channel_decomposition_bijective for n up to 1,000,000 | |
# 2. resonance_well_defined for all v in 0..255 | |
# --- Helper definitions mirrored from the spec ------------------------------- | |
def channel_decompose(n: int): | |
"""Return the base‑256 little‑endian byte list of a positive integer n (n>0).""" | |
if n <= 0: | |
raise ValueError("n must be positive") | |
lst = [] | |
while n: | |
lst.append(n % 256) | |
n //= 256 | |
return lst | |
def reconstruct(bytes_le): | |
"""Reconstruct an integer from its little‑endian base‑256 expansion.""" | |
n = 0 | |
for i, b in enumerate(bytes_le): | |
n += b * (256 ** i) | |
return n | |
# Constants α₁ … α₈ | |
constants = [ | |
1.0, # α₁ unity | |
1.839287, # α₂ Tribonacci | |
1.618034, # α₃ golden ratio | |
0.5, # α₄ adelic threshold | |
0.159155, # α₅ interference null | |
6.283185, # α₆ 2π scale transition | |
0.199612, # α₇ phase coupling | |
14.134725 # α₈ Riemann resonance | |
] | |
def bit_pattern(n: int, i: int) -> bool: | |
"""Return True if bit i of n is 1.""" | |
return ((n >> i) & 1) == 1 | |
def resonance(v: int) -> float: | |
"""Product ∏ constants[i] over active bits of v (0 ≤ v < 256).""" | |
prod = 1.0 | |
for i in range(8): | |
if bit_pattern(v, i): | |
prod *= constants[i] | |
return prod | |
# --- Lemma 1: channel_decomposition_bijective (finite verification) ---------- | |
MAX_N = 1_000_000 | |
bijective_pass = all(reconstruct(channel_decompose(n)) == n for n in range(1, MAX_N + 1)) | |
# --- Lemma 2: resonance_well_defined (all v in 0..255) ----------------------- | |
resonance_positive_pass = all(resonance(v) > 0 for v in range(256)) | |
# --- Output results ---------------------------------------------------------- | |
print(f"Lemma channel_decomposition_bijective holds for all n in [1, {MAX_N}]: {bijective_pass}") | |
print(f"Lemma resonance_well_defined holds for all v in 0..255: {resonance_positive_pass}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment