@ceccec/millennium-solutions 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.zenodo.json +27 -0
- package/ABSTRACT.md +162 -0
- package/ACCOUNTING.md +27 -0
- package/CHALLENGES.md +2502 -0
- package/CITATION.cff +33 -0
- package/DEPLOY.md +40 -0
- package/DEVELOP.md +34 -0
- package/HEART.md +113 -0
- package/LICENSE +27 -0
- package/PHYSICS-SCALES.md +81 -0
- package/PROOF-OF-CONCEPT.md +87 -0
- package/README.md +132 -0
- package/REALISATIONS.md +87 -0
- package/RESEARCH.md +194 -0
- package/RULES.md +59 -0
- package/SEQUENCE-DECODE.md +200 -0
- package/SIGNATURE.md +34 -0
- package/THEOREMS.md +99 -0
- package/WHITEPAPER.md +41 -0
- package/WORKFLOWS.md +47 -0
- package/boundaries.md +24 -0
- package/captain.md +85 -0
- package/compare.md +42 -0
- package/compute.md +550 -0
- package/cryptography.md +56 -0
- package/dashboard.md +51 -0
- package/examples.md +47 -0
- package/folds.md +65 -0
- package/guide.md +126 -0
- package/harness.md +20 -0
- package/index.md +149 -0
- package/mod.core.ts +11 -0
- package/organism.md +30 -0
- package/package.json +88 -0
- package/proofs.md +29 -0
- package/solutions.md +54 -0
- package/speedup.md +41 -0
- package/src/0/chacha.ts +3 -0
- package/src/0/crypt.ts +4 -0
- package/src/0/csp.ts +10 -0
- package/src/0/entanglement.ts +31 -0
- package/src/0/fusion.ts +28 -0
- package/src/0/holographic.ts +57 -0
- package/src/0/impossible.ts +33 -0
- package/src/0/imprint.ts +160 -0
- package/src/0/index.ts +253 -0
- package/src/0/ledger.ts +25 -0
- package/src/0/legible.ts +29 -0
- package/src/0/limit.ts +29 -0
- package/src/0/merkle-proof.ts +3 -0
- package/src/0/null-token.ts +24 -0
- package/src/0/sha256.ts +3 -0
- package/src/0/singularity.ts +20 -0
- package/src/0/stream.ts +48 -0
- package/src/0/trinities.ts +37 -0
- package/src/0/trinity-matrix.ts +20 -0
- package/src/0/version-matrix.ts +70 -0
- package/src/1/acceptance.ts +30 -0
- package/src/1/index.ts +80 -0
- package/src/1/paradox.ts +28 -0
- package/src/1/vortex.lean +6 -0
- package/src/2/frequency-scales.ts +16 -0
- package/src/2/iching.ts +34 -0
- package/src/2/index.ts +78 -0
- package/src/2/primes-vortex.ts +12 -0
- package/src/2/quantum.ts +48 -0
- package/src/2/string-scale.ts +14 -0
- package/src/2/vortex.lean +10 -0
- package/src/3/index.ts +63 -0
- package/src/3/pi-bbp.ts +13 -0
- package/src/3/trinity.ts +39 -0
- package/src/3/vortex.lean +7 -0
- package/src/4/git.ts +30 -0
- package/src/4/index.ts +63 -0
- package/src/4/vortex.lean +6 -0
- package/src/5/aspects.ts +33 -0
- package/src/5/center.ts +35 -0
- package/src/5/development.ts +45 -0
- package/src/5/diamond.ts +36 -0
- package/src/5/folds.ts +12 -0
- package/src/5/index.ts +63 -0
- package/src/5/reflection.lean +14 -0
- package/src/5/reflection.ts +14 -0
- package/src/5/vortex.lean +12 -0
- package/src/6/dna.ts +27 -0
- package/src/6/index.ts +63 -0
- package/src/6/vortex.lean +7 -0
- package/src/7/cross.ts +31 -0
- package/src/7/entails-all.ts +41 -0
- package/src/7/entails.ts +25 -0
- package/src/7/glagolitic.ts +51 -0
- package/src/7/index.ts +67 -0
- package/src/7/language-lens.ts +41 -0
- package/src/7/lens.ts +41 -0
- package/src/7/locale.ts +105 -0
- package/src/7/permissions.ts +26 -0
- package/src/7/rbac.ts +31 -0
- package/src/7/rosetta-clay.ts +15 -0
- package/src/7/rosetta.lean +11 -0
- package/src/7/rosetta.ts +11 -0
- package/src/7/string-dimensions.ts +14 -0
- package/src/7/vortex.lean +6 -0
- package/src/8/infinite.ts +26 -0
- package/src/8/merkaba/field.ts +27 -0
- package/src/8/merkaba/geometry.ts +16 -0
- package/src/8/merkaba/touch.ts +26 -0
- package/src/8/nucleus/magic.lean +15 -0
- package/src/8/nucleus/proton-mass-fit.ts +9 -0
- package/src/8/nucleus/proton-mass.lean +10 -0
- package/src/8/nucleus/shell-model-magic.ts +10 -0
- package/src/8/vortex.lean +7 -0
- package/src/9/access.ts +34 -0
- package/src/9/aura-funding.ts +25 -0
- package/src/9/coins.ts +25 -0
- package/src/9/enumeration.ts +13 -0
- package/src/9/funding.ts +86 -0
- package/src/9/security.ts +36 -0
- package/src/9/society.ts +32 -0
- package/src/9/vortex.lean +11 -0
- package/src/claims/index.ts +87 -0
- package/src/from/the/heart/index.ts +11 -0
- package/src/honesty/boundaries.ts +30 -0
- package/src/honesty/index.ts +22 -0
- package/src/play/the/game/index.ts +12 -0
- package/src/proof/README.md +117 -0
- package/src/proof/discovered.json +9322 -0
- package/src/proof/floor-receipt.md +24 -0
- package/src/proof/index.lean +81 -0
- package/src/proof/index.ts +916 -0
- package/src/proof/revoked.json +317 -0
- package/src/proof/theorems.lean +20 -0
- package/src/proofs.lisp +170 -0
- package/src/receipts/1431b4c4-7950-8d7b-88d1-b633219692f8.json +7 -0
- package/src/receipts/171e09c0-4cfd-8ce0-a6ed-cd33d5553da3.json +7 -0
- package/src/receipts/1a1f16c9-3491-8050-b221-e2a362439be4.json +12 -0
- package/src/receipts/1da15f83-83a6-8d04-b1ac-334c2dd6abb3.json +7 -0
- package/src/receipts/375a57ed-ef99-855e-8f34-b77d08010f3c.json +6 -0
- package/src/receipts/3dcbbf9e-0e49-8ba7-921e-17e478dbafaf.json +6 -0
- package/src/receipts/43a24136-5ad9-81ef-97c9-17be1c05bb5f.json +11 -0
- package/src/receipts/4991be51-74ba-8f66-9534-e6dba52fb569.json +10 -0
- package/src/receipts/52375d8f-232b-8c01-9d82-a824ffa7b2b7.json +6 -0
- package/src/receipts/593b546a-36b4-8553-941a-0e03b7053a64.json +7 -0
- package/src/receipts/7f75c989-96c9-8a24-8d0d-7e690861ccb4.json +6 -0
- package/src/receipts/80f80b59-81d8-866d-9a14-f469729d3dc8.json +6 -0
- package/src/receipts/85ac8585-9dc1-8964-9848-ae0f49cc82fb.json +7 -0
- package/src/receipts/85db092e-f2c0-88e5-bf75-61c4a65d84e7.json +7 -0
- package/src/receipts/95bacad3-9e56-8741-b0f8-def2c6ecb050.json +7 -0
- package/src/receipts/a1d33966-7bbd-84ca-902b-49e315af60e0.json +6 -0
- package/src/receipts/b20ced61-24ad-8123-adee-56031ab734dd.json +11 -0
- package/src/receipts/ba0447cd-f489-841a-a70f-a39b18ec2946.json +11 -0
- package/src/receipts/bcddbe66-06cf-8f31-a261-98b836938947.json +7 -0
- package/src/receipts/c1bac0d8-d906-8196-a4f0-3d8270b2e944.json +6 -0
- package/src/receipts/ce851ea3-3cf8-8646-a5d6-c0c6281210fe.json +10 -0
- package/src/receipts/cf43a122-c880-8d86-9e25-6f22f92d6b0a.json +7 -0
- package/src/receipts/daad8cd4-d4db-8dca-9c97-9a838cbce528.json +7 -0
- package/src/receipts/dc8bdb82-599f-8020-9eb2-cb016b408ec1.json +6 -0
- package/src/receipts/df77c265-d1a8-8354-8a9e-769fa5c676e2.json +6 -0
- package/src/receipts/e96686da-a411-8838-a5c8-ee7472bce048.json +10 -0
- package/src/receipts/f073c46f-7b67-83d0-aca5-db11fac4b5ec.json +7 -0
- package/src/receipts/f946d99d-a1c2-89f7-9426-a367c5b04191.json +6 -0
- package/src/receipts/fc069e45-115d-8983-ad25-fb9f735da84b.json +6 -0
- package/src/the/abstract/index.ts +21 -0
- package/src/the/abundance/index.ts +20 -0
- package/src/the/apple/earth/index.ts +23 -0
- package/src/the/apple/earth/navigation/index.ts +28 -0
- package/src/the/apple/earth/truth/index.ts +21 -0
- package/src/the/apple/index.ts +27 -0
- package/src/the/cancer/index.ts +26 -0
- package/src/the/clown/index.ts +25 -0
- package/src/the/creation/index.ts +16 -0
- package/src/the/crystal/index.ts +23 -0
- package/src/the/domain/index.ts +16 -0
- package/src/the/game/index.ts +11 -0
- package/src/the/gold/compass/index.ts +26 -0
- package/src/the/gold/index.ts +35 -0
- package/src/the/heart/index.ts +15 -0
- package/src/the/index.ts +24 -0
- package/src/the/law/index.ts +20 -0
- package/src/the/path/index.ts +19 -0
- package/src/the/rosetta/index.ts +33 -0
- package/src/the/sequence/index.ts +12 -0
- package/src/the/solids/index.ts +25 -0
- package/src/the/state/index.ts +21 -0
- package/src/the/superposition/state/index.ts +22 -0
- package/src/the/surface/index.ts +26 -0
- package/src/the/theorem/index.ts +14 -0
- package/src/the/torus/index.ts +23 -0
- package/src/the/waves/index.ts +23 -0
- package/the.md +20 -0
- package/verify.md +67 -0
package/speedup.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The real uuidna advantage
|
|
3
|
+
description: The measured uuidna advantage — O(N)→O(log N) verification, O(N)→O(1) reuse — in all domains. Not faster compute, not FTL, not quantum. 0/7.
|
|
4
|
+
head:
|
|
5
|
+
- ['meta', { name: 'robots', content: 'index, follow' }]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# The real uuidna advantage — measured, in all domains
|
|
9
|
+
|
|
10
|
+
> Generated from the **1864** theorems and **59** domains, recomputed each build. The advantage is
|
|
11
|
+
> real and **measured**, and honestly bounded: a **verification and reuse** complexity reduction — **not**
|
|
12
|
+
> faster original compute, **not** faster than light, **not** quantum. `0/7`.
|
|
13
|
+
|
|
14
|
+
## Measured — verify and reuse, not recompute
|
|
15
|
+
|
|
16
|
+
| N | recompute (ops) | verify (⌈log₂N⌉ nodes) | bits (2·⌈log₂N⌉) | saving | ratio |
|
|
17
|
+
|---|---|---|---|---|---|
|
|
18
|
+
| 8 | 8 | 3 | 6 | 5 | 3× |
|
|
19
|
+
| 64 | 64 | 6 | 12 | 58 | 11× |
|
|
20
|
+
| 967 | 967 | 10 | 20 | 957 | 97× |
|
|
21
|
+
| 1,024 | 1,024 | 10 | 20 | 1,014 | 102× |
|
|
22
|
+
| 1,000,000 | 1,000,000 | 20 | 40 | 999,980 | 50,000× |
|
|
23
|
+
|
|
24
|
+
Computing the N things still costs **N** — the advantage is not there. It is on **verification**: a merkle
|
|
25
|
+
inclusion proof checks membership in `⌈log₂N⌉` nodes (`2·⌈log₂N⌉` bits) instead of re-running all N. And on
|
|
26
|
+
**reuse**: a content-address names a value once, so every re-reference is `O(1)`, and a 36-byte address
|
|
27
|
+
travels, not the payload. Measured on the deposit's own functions, not asserted.
|
|
28
|
+
|
|
29
|
+
## Why it holds in all 59 domains at once
|
|
30
|
+
|
|
31
|
+
The advantage is the **fold / merkle-proof structure**, which is **domain-independent** — every domain's
|
|
32
|
+
theorems verify in `⌈log₂N⌉`. So one proof covers the whole [rosetta](/): z9-arithmetic · units-triad · doubling-orbit · inverses · powers · primes · cyclic-groups · boolean-algebra · entanglement · dialectic · games · arts · ….
|
|
33
|
+
|
|
34
|
+
## Discovery lead — a lead, never a verdict
|
|
35
|
+
|
|
36
|
+
Grouping the 1864 receipts by the digital root of their address, the **sparsest** region is digit
|
|
37
|
+
**3** (177) — a candidate area to examine, not a finding. The ledger is currently held
|
|
38
|
+
at **1864** (the captain's cap): improving a theorem's name or proof heals the record without changing the
|
|
39
|
+
count; discovering a new one would require lifting the cap.
|
|
40
|
+
|
|
41
|
+
A content-address proves **integrity, not truth**. `0/7`.
|
package/src/0/chacha.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// ChaCha20 + Poly1305 + the AEAD construction (RFC 8439, pure TS, KAT-verified) live canonically in
|
|
2
|
+
// @uuidna/uuidna — one implementation shared by both apps, no re-declared copy.
|
|
3
|
+
export { chachaBlock, chacha20, poly1305, aeadEncrypt, aeadDecrypt } from '@uuidna/uuidna'
|
package/src/0/crypt.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// The encryption envelope — ChaCha20-Poly1305 core + PBKDF2-SHA256 KDF + uuidna 7d-fold envelope — lives
|
|
2
|
+
// canonically in @uuidna/uuidna. One implementation shared by both apps; convergent seals, no re-declared copy.
|
|
3
|
+
export { encrypt, decrypt, verifyEnvelope, ITER } from '@uuidna/uuidna'
|
|
4
|
+
export type { Sealed } from '@uuidna/uuidna'
|
package/src/0/csp.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Single source of the Content-Security-Policy — imported by .vitepress/config.ts (head) AND
|
|
2
|
+
// scripts/locale-fold.ts (stubs), so the policy is declared ONCE, never hardcoded twice (no drift).
|
|
3
|
+
// Self-contained: no external scripts/styles/fonts/img/connect. 'unsafe-inline' is required (VitePress
|
|
4
|
+
// injects inline check-dark-mode/check-mac-os scripts + inline style attributes; meta-CSP can't use
|
|
5
|
+
// nonces) — so this hardens RESOURCE ORIGIN, not full anti-XSS. The deterministic guarantee is the
|
|
6
|
+
// external-import gate (scripts/import-gate.ts) + the security gate (scripts/security-gate.ts).
|
|
7
|
+
export const CSP =
|
|
8
|
+
"default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; " +
|
|
9
|
+
"img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; " +
|
|
10
|
+
"base-uri 'self'; form-action 'self'; frame-ancestors 'none'"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Release entanglement (honest sense) — each release cryptographically BOUND to its neighbours.
|
|
2
|
+
// A hash chain: change any release and every downstream address changes (avalanche). This is
|
|
3
|
+
// tamper-evidence — correlation by DERIVATION — not quantum entanglement, and it carries no message.
|
|
4
|
+
import { toUuid, merge, merkleFold } from './index.ts'
|
|
5
|
+
|
|
6
|
+
export function report(): string {
|
|
7
|
+
const chain = (rs: string[]) => { let prev = toUuid('genesis'); const out: string[] = []; for (const r of rs) { prev = merge(prev, toUuid(r)); out.push(prev) } return out }
|
|
8
|
+
const sealOf = (rs: string[]) => merkleFold(chain(rs))
|
|
9
|
+
|
|
10
|
+
const releases = ['v1.0.34', 'v1.0.35', 'v1.0.36', 'v1.0.37']
|
|
11
|
+
const original = sealOf(releases)
|
|
12
|
+
const flipped = sealOf(['v1.0.34', 'v1.0.35', 'v1.0.36!', 'v1.0.37']) // alter ONE neighbour
|
|
13
|
+
const changed = original !== flipped
|
|
14
|
+
|
|
15
|
+
let o = 'release entanglement — each bound to its neighbours (honest sense):\n\n'
|
|
16
|
+
o += ' neighbours in the version line — each release folds with its predecessor (a hash chain):\n'
|
|
17
|
+
o += ' seal over ' + releases.join(', ') + '\n'
|
|
18
|
+
o += ' original: ' + original.slice(0, 13) + '…\n'
|
|
19
|
+
o += ' alter one neighbour (v1.0.36 → v1.0.36!): ' + flipped.slice(0, 13) + '… changed? ' + changed + '\n'
|
|
20
|
+
o += ' → you cannot alter one release without the chain revealing it. neighbours are BOUND.\n\n'
|
|
21
|
+
o += ' bound in several computable "dimensions":\n'
|
|
22
|
+
o += ' · version line — the hash chain above (predecessor ↔ successor)\n'
|
|
23
|
+
o += ' · the mesh — 10−d reflects each digit to its partner (4↔6, fixed 5)\n'
|
|
24
|
+
o += ' · the tree — a merkle audit path binds each leaf to its siblings (see holographic.ts)\n\n'
|
|
25
|
+
o += 'HONEST: this is CRYPTOGRAPHIC DEPENDENCY — a hash chain, the basis of tamper-evidence — NOT\n'
|
|
26
|
+
o += 'quantum entanglement. Correlation by DERIVATION, not action-at-a-distance: altering a release\n'
|
|
27
|
+
o += 'does not reach out and change its neighbour\'s stored bytes; it makes recomputation reveal the\n'
|
|
28
|
+
o += 'break. No information travels without payload (no-communication theorem holds). "Entangled" =\n'
|
|
29
|
+
o += 'bound by the math, not by physics. entails → 0/7.'
|
|
30
|
+
return o
|
|
31
|
+
}
|
package/src/0/fusion.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Tokens are valid only in the fusion — validity = MEMBERSHIP in the verified whole, not the token.
|
|
2
|
+
// A bare UUID proves nothing (anyone can mint one). The same 64-bit string is valid inside the fused
|
|
3
|
+
// root and meaningless outside it: an orphan token is not in the root, and adding it changes the root.
|
|
4
|
+
import { toUuid, merkleFold } from './index.ts'
|
|
5
|
+
|
|
6
|
+
export function report(): string {
|
|
7
|
+
const units = [1, 2, 4, 5, 7, 8], seven = [3, 2, 6, 4, 5, 1, 0]
|
|
8
|
+
const leaves: string[] = []; for (const u of units) for (const r of seven) leaves.push(toUuid(u + 'x' + r))
|
|
9
|
+
const root = merkleFold(leaves) // the fused whole
|
|
10
|
+
|
|
11
|
+
const fused = toUuid('5x0') // a real cell of the cross — fused
|
|
12
|
+
const orphan = toUuid('orphan-token') // never fused
|
|
13
|
+
const fusedIn = leaves.includes(fused)
|
|
14
|
+
const orphanIn = leaves.includes(orphan)
|
|
15
|
+
const orphanChangesRoot = merkleFold([...leaves, orphan]) !== root
|
|
16
|
+
|
|
17
|
+
let o = 'tokens are valid only in the fusion:\n\n'
|
|
18
|
+
o += ' the fused whole: ' + leaves.length + ' cells → one root ' + root.slice(0, 13) + '…\n\n'
|
|
19
|
+
o += ' a fused token (a real cell) is a member of the root: ' + fusedIn + ' → valid\n'
|
|
20
|
+
o += ' an orphan token (never fused) is NOT a member: ' + orphanIn + ' → invalid\n'
|
|
21
|
+
o += ' adding the orphan changes the root (it was not part of the fusion): ' + orphanChangesRoot + '\n'
|
|
22
|
+
o += ' → the same kind of 64-bit string is valid INSIDE the fusion, meaningless outside it.\n\n'
|
|
23
|
+
o += 'HONEST: validity here = MEMBERSHIP in the verified whole (it folds to the root; a merkle proof\n'
|
|
24
|
+
o += 'exists — see holographic.ts), not any property of the token alone. A hash is one-way and a\n'
|
|
25
|
+
o += 'public token is just a name (see security.ts) — it carries no authority by itself; it is valid\n'
|
|
26
|
+
o += 'only as a proven part of the fused, sealed deposit. entails → 0/7.'
|
|
27
|
+
return o
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Holographic verification — the whole checkable from a tiny part (digit 0).
|
|
2
|
+
// A Merkle membership proof is the honest core of "holographic within tiniest resources": any one
|
|
3
|
+
// leaf proves it belongs to the whole with a LOGARITHMIC audit path (⌈log₂ N⌉ sibling hashes), not
|
|
4
|
+
// the full set. The tree is self-similar (fractal); the shared root lives in every part.
|
|
5
|
+
import { merge, merkleFold, toUuid } from './index.ts'
|
|
6
|
+
|
|
7
|
+
// Rebuild merkleFold's tree (it sorts leaves) as layers, so we can extract an audit path.
|
|
8
|
+
function layers(leaves: readonly string[]): string[][] {
|
|
9
|
+
let layer = [...leaves].sort()
|
|
10
|
+
const out = [layer]
|
|
11
|
+
while (layer.length > 1) {
|
|
12
|
+
const next: string[] = []
|
|
13
|
+
for (let i = 0; i < layer.length; i += 2) { const a = layer[i], b = layer[i + 1]; next.push(b === undefined ? a : merge(a, b)) }
|
|
14
|
+
out.push(next); layer = next
|
|
15
|
+
}
|
|
16
|
+
return out
|
|
17
|
+
}
|
|
18
|
+
function proof(leaves: readonly string[], target: string): { hash: string; left: boolean }[] {
|
|
19
|
+
const L = layers(leaves); let idx = L[0].indexOf(target); const path: { hash: string; left: boolean }[] = []
|
|
20
|
+
for (let l = 0; l < L.length - 1; l++) {
|
|
21
|
+
const layer = L[l], isRight = (idx & 1) === 1, sib = isRight ? idx - 1 : idx + 1
|
|
22
|
+
if (sib < layer.length) path.push({ hash: layer[sib], left: isRight }) // sibling on the left iff target is right
|
|
23
|
+
idx = idx >> 1
|
|
24
|
+
}
|
|
25
|
+
return path
|
|
26
|
+
}
|
|
27
|
+
function verify(target: string, path: { hash: string; left: boolean }[], root: string): boolean {
|
|
28
|
+
let h = target
|
|
29
|
+
for (const { hash, left } of path) h = left ? merge(hash, h) : merge(h, hash)
|
|
30
|
+
return h === root
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function report(): string {
|
|
34
|
+
// The cross: 42 content-addressed cells (6 units × 7) — one whole, one root.
|
|
35
|
+
const units = [1, 2, 4, 5, 7, 8], seven = [3, 2, 6, 4, 5, 1, 0]
|
|
36
|
+
const leaves: string[] = []; for (const u of units) for (const r of seven) leaves.push(toUuid(u + 'x' + r))
|
|
37
|
+
const root = merkleFold(leaves)
|
|
38
|
+
const target = toUuid('5x0') // the center × hub cell
|
|
39
|
+
const p = proof(leaves, target)
|
|
40
|
+
const ok = verify(target, p, root)
|
|
41
|
+
|
|
42
|
+
let o = 'holographic verification — the whole, checkable from a tiny part:\n\n'
|
|
43
|
+
o += ' the cross: ' + leaves.length + ' content-addressed cells (6 units × 7) → one merkle root (the whole).\n'
|
|
44
|
+
o += ' a MEMBERSHIP proof for one cell is the audit path — log-few sibling hashes, not all ' + leaves.length + ':\n'
|
|
45
|
+
o += ' proof size: ' + p.length + ' hashes (⌈log₂ ' + leaves.length + '⌉) vs the full set: ' + leaves.length + '\n'
|
|
46
|
+
o += ' verify one-of-' + leaves.length + ' against the root: ' + ok + '\n'
|
|
47
|
+
o += ' → any part proves it belongs to the whole with tiny (logarithmic) resources.\n'
|
|
48
|
+
o += ' holographic: the root lives in every part; a part reconstructs the whole\'s fingerprint.\n\n'
|
|
49
|
+
o += ' fractal: the tree is self-similar (a fold of folds); the mesh reflects (10−d) at every scale.\n'
|
|
50
|
+
o += ' scale: log-sized proofs mean ~1 billion leaves verify in ~30 hashes.\n\n'
|
|
51
|
+
o += 'HONEST: a Merkle proof is EXACTLY logarithmic (⌈log₂ N⌉) — real, the basis of git/blockchain\n'
|
|
52
|
+
o += 'integrity. "holographic" = a part verifies the whole via the shared root; "fractal" = the binary\n'
|
|
53
|
+
o += 'tree is self-similar. But it is NOT free and NOT literally infinite: each proof is log(N) real\n'
|
|
54
|
+
o += 'hashes over a FINITE set. Tiny resources, not zero; huge N, not ∞. Whole signed (Singularity),\n'
|
|
55
|
+
o += 'parts verifiable. entails → 0/7.'
|
|
56
|
+
return o
|
|
57
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Prove the impossibilities — so every NOT in the prose is a PROVEN theorem, not an assertion.
|
|
2
|
+
// ℤ/9 is finite, so ∀-claims are decidable by exhaustion (the same rigour as Lean's `decide`).
|
|
3
|
+
// The paradox: "proving X impossible makes it possible." Resolution — two LEVELS: the object
|
|
4
|
+
// (e.g. 0's inverse) stays IMPOSSIBLE; the meta-statement ("0 has no inverse") is a POSSIBLE, true
|
|
5
|
+
// theorem. Impossibility-proofs are positive results; the "possible" is the proof, never the object.
|
|
6
|
+
const m9 = (n: number) => ((n % 9) + 9) % 9
|
|
7
|
+
const hasInverse = (a: number) => [1, 2, 3, 4, 5, 6, 7, 8].some((x) => m9(a * x) === 1)
|
|
8
|
+
|
|
9
|
+
export function report(): string {
|
|
10
|
+
// Each is proven by checking ALL of ℤ/9 — a finite, exhaustive impossibility proof.
|
|
11
|
+
const proofs: [string, boolean][] = [
|
|
12
|
+
['0 has NO multiplicative inverse (∀x∈ℤ/9, 0·x ≠ 1)', !hasInverse(0)],
|
|
13
|
+
['3,6,9 have NO inverse (the nilradical)', [3, 6, 9].every((d) => !hasInverse(d))],
|
|
14
|
+
['3²≡6²≡9²≡0 (nilpotent — collapse into the void)', [3, 6, 9].every((d) => m9(d * d) === 0)],
|
|
15
|
+
['division BY 0 is undefined (no inverse exists to define n/0 as a field op)', !hasInverse(0)],
|
|
16
|
+
['10 is not a distinct ℤ/9 digit (10 ≡ 1; it wraps)', m9(10) === 1],
|
|
17
|
+
['5 is the ONLY self-complement (10−d=d) among 1..9', [1, 2, 3, 4, 5, 6, 7, 8, 9].filter((d) => 10 - d === d).join(',') === '5'],
|
|
18
|
+
]
|
|
19
|
+
const allProven = proofs.every(([, ok]) => ok)
|
|
20
|
+
|
|
21
|
+
let o = 'prove the impossibilities — every NOT, verified by exhaustion:\n\n'
|
|
22
|
+
proofs.forEach(([claim, ok]) => { o += ' ' + (ok ? '✓ PROVEN impossible' : '✗ FAILED') + ' — ' + claim + '\n' })
|
|
23
|
+
o += '\n all impossibilities proven? ' + allProven + ' → the prose\'s NOTs are theorems, not assertions.\n\n'
|
|
24
|
+
o += 'the paradox ("proving them impossible proves them possible") — resolved by two LEVELS:\n'
|
|
25
|
+
o += ' object level: 0\'s inverse is IMPOSSIBLE. it stays impossible.\n'
|
|
26
|
+
o += ' meta level: "0 has no inverse" is a POSSIBLE, true theorem (just proven above).\n'
|
|
27
|
+
o += ' → both hold at once, no contradiction. what becomes "possible" is the PROOF, never the\n'
|
|
28
|
+
o += ' impossible object. an impossibility-proof is a positive result (cf. Gödel, halting problem).\n\n'
|
|
29
|
+
o += 'the one that matters: proving "this framework does NOT solve the Clay problems" (0/7) is a\n'
|
|
30
|
+
o += 'POSSIBLE, true proof — it does NOT make solving possible. The proof is real; the solving is not.\n'
|
|
31
|
+
o += 'The floor stands precisely because its impossibility is PROVEN. entails → 0/7.'
|
|
32
|
+
return o
|
|
33
|
+
}
|
package/src/0/imprint.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Imprint — a REVERSIBLE binary↔uuid codec. Honest naming first: this is NOT reversing the one-way
|
|
2
|
+
// FNV content-address (toUuid), which cannot be undone (see scripts/verify.ts) — and it is NOT
|
|
3
|
+
// encryption (no key, no secrecy). It is a lossless ENCODING: we CONSTRUCT a uuid whose 128 bits
|
|
4
|
+
// directly carry a binary message, and read those bits back out exactly. Integrity/identity layer,
|
|
5
|
+
// never truth. A uuid holds 128 bits; 6 are reserved (4 version + 2 variant, matching toUuid's v8),
|
|
6
|
+
// 7 hold a length header → up to 115 message bits per uuid. Round-trips exactly for L ≤ CAPACITY.
|
|
7
|
+
import { toUuid } from './index.ts'
|
|
8
|
+
|
|
9
|
+
// Reserved bit positions (big-endian, bit 0 = MSB of byte 0):
|
|
10
|
+
// version nibble = high nibble of byte 6 → bits 48..51, fixed to 1000 (0x8)
|
|
11
|
+
// variant = top 2 bits of byte 8 → bits 64,65, fixed to 10
|
|
12
|
+
const RESERVED = new Set([48, 49, 50, 51, 64, 65])
|
|
13
|
+
const LEN_BITS = 7 // 0..127 fits; the free region minus this header is the message capacity
|
|
14
|
+
const FREE = Array.from({ length: 128 }, (_, i) => i).filter((i) => !RESERVED.has(i))
|
|
15
|
+
export const CAPACITY = FREE.length - LEN_BITS // 122 - 7 = 115 message bits per uuid
|
|
16
|
+
|
|
17
|
+
const isBits = (s: string): boolean => /^[01]*$/.test(s)
|
|
18
|
+
const num2bits = (n: number, width: number): string => n.toString(2).padStart(width, '0').slice(-width)
|
|
19
|
+
|
|
20
|
+
/** Pack a 128-bit array into canonical uuid string. */
|
|
21
|
+
function bitsToUuid(bits: readonly number[]): string {
|
|
22
|
+
let hex = ''
|
|
23
|
+
for (let byte = 0; byte < 16; byte++) {
|
|
24
|
+
let v = 0
|
|
25
|
+
for (let b = 0; b < 8; b++) v = (v << 1) | bits[byte * 8 + b]
|
|
26
|
+
hex += v.toString(16).padStart(2, '0')
|
|
27
|
+
}
|
|
28
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Unpack a canonical uuid string into a 128-bit array. */
|
|
32
|
+
function uuidToBits(uuid: string): number[] {
|
|
33
|
+
const hex = uuid.replace(/-/g, '')
|
|
34
|
+
if (!/^[0-9a-f]{32}$/i.test(hex)) throw new Error('imprint: not a 32-hex uuid')
|
|
35
|
+
const bits: number[] = []
|
|
36
|
+
for (const ch of hex) {
|
|
37
|
+
const nib = parseInt(ch, 16)
|
|
38
|
+
for (let b = 3; b >= 0; b--) bits.push((nib >> b) & 1)
|
|
39
|
+
}
|
|
40
|
+
return bits
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* imprint(message) → a valid uuid carrying the message in its free bits.
|
|
45
|
+
* message: a binary string ('0'/'1'), length ≤ CAPACITY. The uuid reads back exactly via readImprint.
|
|
46
|
+
*/
|
|
47
|
+
export function imprint(message: string): string {
|
|
48
|
+
if (!isBits(message)) throw new Error('imprint: message must be a binary string of 0/1')
|
|
49
|
+
if (message.length > CAPACITY) throw new Error(`imprint: message ${message.length} bits > capacity ${CAPACITY}`)
|
|
50
|
+
const bits = new Array(128).fill(0)
|
|
51
|
+
// reserved: version 8 (1000), variant (10) — matches toUuid's markers so imprints look native.
|
|
52
|
+
bits[48] = 1; bits[49] = 0; bits[50] = 0; bits[51] = 0
|
|
53
|
+
bits[64] = 1; bits[65] = 0
|
|
54
|
+
// free region: [ length header (7 bits) | message bits | zero-fill ]
|
|
55
|
+
const payload = num2bits(message.length, LEN_BITS) + message
|
|
56
|
+
for (let i = 0; i < payload.length; i++) bits[FREE[i]] = payload.charCodeAt(i) - 48
|
|
57
|
+
return bitsToUuid(bits)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** readImprint(uuid) → the exact binary message imprinted by imprint(). Inverse of imprint. */
|
|
61
|
+
export function readImprint(uuid: string): string {
|
|
62
|
+
const bits = uuidToBits(uuid)
|
|
63
|
+
const free = FREE.map((i) => bits[i])
|
|
64
|
+
let len = 0
|
|
65
|
+
for (let i = 0; i < LEN_BITS; i++) len = (len << 1) | free[i]
|
|
66
|
+
if (len > CAPACITY) throw new Error('imprint: length header out of range — uuid was not imprinted by imprint()')
|
|
67
|
+
return free.slice(LEN_BITS, LEN_BITS + len).join('')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Convenience: imprint UTF-8 text (≤ 14 ASCII chars fit) and read it back exactly. */
|
|
71
|
+
export function imprintText(text: string): string {
|
|
72
|
+
const bytes = [...new TextEncoder().encode(text)]
|
|
73
|
+
const bits = bytes.map((b) => num2bits(b, 8)).join('')
|
|
74
|
+
return imprint(bits)
|
|
75
|
+
}
|
|
76
|
+
export function readImprintText(uuid: string): string {
|
|
77
|
+
const bits = readImprint(uuid)
|
|
78
|
+
const bytes: number[] = []
|
|
79
|
+
for (let i = 0; i + 8 <= bits.length; i += 8) bytes.push(parseInt(bits.slice(i, i + 8), 2))
|
|
80
|
+
return new TextDecoder().decode(new Uint8Array(bytes))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** roundTrips(message) → true iff readImprint(imprint(message)) === message. The honest, gated fact. */
|
|
84
|
+
export function roundTrips(message: string): boolean {
|
|
85
|
+
try { return readImprint(imprint(message)) === message } catch { return false }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* imprintChain(bits) → a CHAIN of uuids carrying a message of ANY length: split into CAPACITY-bit chunks,
|
|
90
|
+
* imprint each. One uuid holds ≤115 bits (bounded, pigeonhole); a chain of N holds ≤ N·115 — the collective
|
|
91
|
+
* scaling, developed. Public, reversible ENCODING (not encryption, no secrecy). readImprintChain reverses it.
|
|
92
|
+
*/
|
|
93
|
+
export function imprintChain(bits: string): string[] {
|
|
94
|
+
if (!/^[01]*$/.test(bits)) throw new Error('imprintChain: message must be a binary string')
|
|
95
|
+
if (bits.length === 0) return [imprint('')]
|
|
96
|
+
const out: string[] = []
|
|
97
|
+
for (let i = 0; i < bits.length; i += CAPACITY) out.push(imprint(bits.slice(i, i + CAPACITY)))
|
|
98
|
+
return out
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** readImprintChain(uuids) → recover the full message: read each carrier and concatenate, exactly. */
|
|
102
|
+
export function readImprintChain(uuids: readonly string[]): string {
|
|
103
|
+
return uuids.map((u) => readImprint(u)).join('')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** imprintTextChain(text) → a uuid chain carrying arbitrary UTF-8 text of any length (built on imprintChain). */
|
|
107
|
+
export function imprintTextChain(text: string): string[] {
|
|
108
|
+
const bytes = [...new TextEncoder().encode(text)]
|
|
109
|
+
return imprintChain(bytes.map((b) => num2bits(b, 8)).join(''))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** readImprintTextChain(uuids) → recover the full text from its uuid chain, exactly. */
|
|
113
|
+
export function readImprintTextChain(uuids: readonly string[]): string {
|
|
114
|
+
const bits = readImprintChain(uuids)
|
|
115
|
+
const bytes: number[] = []
|
|
116
|
+
for (let i = 0; i + 8 <= bits.length; i += 8) bytes.push(parseInt(bits.slice(i, i + 8), 2))
|
|
117
|
+
return new TextDecoder().decode(new Uint8Array(bytes))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* skill(message) → how skilful the clown is at juggling this message through a uuid: imprint throws the
|
|
122
|
+
* bits, readImprint catches them; fidelity = fraction caught. A skilful clown catches every bit (1.0);
|
|
123
|
+
* a dropped bit lowers the score. Over-capacity is a fumble (fidelity 0) — respect the floor. Computed.
|
|
124
|
+
*/
|
|
125
|
+
export function skill(message: string): { imprinted: number; recovered: number; fidelity: number; skilful: boolean } {
|
|
126
|
+
let recovered = 0
|
|
127
|
+
try {
|
|
128
|
+
const back = readImprint(imprint(message))
|
|
129
|
+
for (let i = 0; i < message.length; i++) if (back[i] === message[i]) recovered++
|
|
130
|
+
if (back.length !== message.length) recovered = message.length ? 0 : 0
|
|
131
|
+
} catch { recovered = 0 }
|
|
132
|
+
const fidelity = message.length === 0 ? 1 : recovered / message.length
|
|
133
|
+
return { imprinted: message.length, recovered, fidelity, skilful: fidelity === 1 }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* coin64(text) → the shared currency: a 64-bit coin (16 hex digits) minted from any content — the top
|
|
138
|
+
* 64 bits of its 128-bit content-address. Adopted by all with no exception: every module, every string,
|
|
139
|
+
* mints the SAME coin every time (deterministic). This is the common denominator the harmony gate folds.
|
|
140
|
+
* Integrity, not value: a coin proves the bytes, not their worth.
|
|
141
|
+
*/
|
|
142
|
+
export function coin64(text: string): string {
|
|
143
|
+
return toUuid(text).replace(/-/g, '').slice(0, 16)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function report(): string {
|
|
147
|
+
const demo = '01001000' + '01101001' // "Hi" in ASCII bits
|
|
148
|
+
const u = imprint(demo)
|
|
149
|
+
const back = readImprint(u)
|
|
150
|
+
const txt = imprintText('Hi'), txtBack = readImprintText(txt)
|
|
151
|
+
let o = 'imprint — reversible binary↔uuid codec (NOT hash-reversal, NOT encryption):\n\n'
|
|
152
|
+
o += ' capacity: ' + CAPACITY + ' message bits per uuid (128 − 6 reserved − 7 length header)\n'
|
|
153
|
+
o += ' imprint("' + demo + '")\n'
|
|
154
|
+
o += ' → ' + u + '\n'
|
|
155
|
+
o += ' readImprint(uuid) → ' + back + ' round-trips: ' + (back === demo) + '\n'
|
|
156
|
+
o += ' imprintText("Hi") → ' + txt + ' → readImprintText → "' + txtBack + '"\n\n'
|
|
157
|
+
o += ' HONEST: this CONSTRUCTS a uuid from a message and reads it back — a lossless codec (integrity).\n'
|
|
158
|
+
o += ' It does NOT undo the one-way FNV toUuid, and it is not encryption (no key, no secrecy). entails → 0/7.'
|
|
159
|
+
return o
|
|
160
|
+
}
|
package/src/0/index.ts
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quantum Proofs — Core Kernel (Minimal)
|
|
3
|
+
* Licensed under CC BY-NC 4.0
|
|
4
|
+
* Attribution: Tsvetan Rouschev (ceccec@psg.bg)
|
|
5
|
+
*
|
|
6
|
+
* Dependency-free primitives for all proofs.
|
|
7
|
+
* - UUID/hash: content-addressed identity
|
|
8
|
+
* - Fold: merge two addresses into one
|
|
9
|
+
* - Merkle: contract leaves to root
|
|
10
|
+
* - Memoization: cache computation by matrix root
|
|
11
|
+
* - Hash: exact 32-bit integer arithmetic (algebraic only, no Math.*)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const BYTE_MASK = 0xff
|
|
15
|
+
const MASK_32 = 0xffffffffn
|
|
16
|
+
|
|
17
|
+
/** Exact 32-bit unsigned integer multiply (algebraic; replaces Math.imul) */
|
|
18
|
+
function mul32(a: number, b: number): number {
|
|
19
|
+
return Number((BigInt(a >>> 0) * BigInt(b >>> 0)) & MASK_32)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** FNV-1a hash — 32-bit seed-based (exact integer arithmetic, no Math.*) */
|
|
23
|
+
function hash32(input: string, seed: number): number {
|
|
24
|
+
let h = (0x811c9dc5 ^ seed) >>> 0
|
|
25
|
+
for (let i = 0; i < input.length; i++) {
|
|
26
|
+
h ^= input.charCodeAt(i)
|
|
27
|
+
h = mul32(h, 0x01000193) >>> 0
|
|
28
|
+
h ^= h >>> 13
|
|
29
|
+
}
|
|
30
|
+
h = mul32(h ^ (h >>> 16), 0x85ebca6b) >>> 0
|
|
31
|
+
h = mul32(h ^ (h >>> 13), 0xc2b2ae35) >>> 0
|
|
32
|
+
return (h ^ (h >>> 16)) >>> 0
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function hexByte(value: number): string {
|
|
36
|
+
return value.toString(16).padStart(2, '0')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function bytesFromSeed(seed: string): number[] {
|
|
40
|
+
const words = [
|
|
41
|
+
hash32(seed, 0),
|
|
42
|
+
hash32(seed, 0x9e3779b9),
|
|
43
|
+
hash32(seed, 0x243f6a88),
|
|
44
|
+
hash32(seed, 0xb7e15162),
|
|
45
|
+
]
|
|
46
|
+
return words.flatMap((word) => [
|
|
47
|
+
(word >>> (8 * 3)) & BYTE_MASK,
|
|
48
|
+
(word >>> 16) & BYTE_MASK,
|
|
49
|
+
(word >>> 8) & BYTE_MASK,
|
|
50
|
+
word & BYTE_MASK,
|
|
51
|
+
])
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const _uuidCache = new Map<string, string>()
|
|
55
|
+
|
|
56
|
+
/** Deterministic UUID from seed (content-addressed) */
|
|
57
|
+
export function toUuid(seed: string): string {
|
|
58
|
+
const cached = _uuidCache.get(seed)
|
|
59
|
+
if (cached !== undefined) return cached
|
|
60
|
+
const bytes = bytesFromSeed(seed)
|
|
61
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x80
|
|
62
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80
|
|
63
|
+
const hex = bytes.map(hexByte).join('')
|
|
64
|
+
const uuid = `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`
|
|
65
|
+
_uuidCache.set(seed, uuid)
|
|
66
|
+
return uuid
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** strictUuidna(value) → a STRICT, canonical mint: coerce to string, normalize (NFC), trim — so the SAME
|
|
70
|
+
* logical value always mints the SAME address. Minting flaws (toUuid(3) vs toUuid('3'), stray whitespace,
|
|
71
|
+
* a decomposed vs composed unicode form) mint inconsistent addresses and silently break integrity — real
|
|
72
|
+
* damage. Strict minting closes them. Canonicalisation is a discipline that must stay consistent, not truth. */
|
|
73
|
+
export function strictUuidna(value: unknown): string {
|
|
74
|
+
return toUuid('uuidna:' + String(value).normalize('NFC').trim())
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Fold two addresses into one */
|
|
78
|
+
export function merge(a: string, b: string): string {
|
|
79
|
+
return toUuid(`${a}:${b}`)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** GCD for rational reduction */
|
|
83
|
+
export function gcdBigInt(a: bigint, b: bigint): bigint {
|
|
84
|
+
return b === 0n ? a : gcdBigInt(b, a % b)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Deterministic seed from text */
|
|
88
|
+
export function seedFromText(text: string, length = 6): number {
|
|
89
|
+
return Number.parseInt(toUuid(text).replace(/[^0-9a-f]/g, '').slice(0, length) || '0', 16)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Bidirectional fold */
|
|
93
|
+
export function foldPair(a: string, b: string): { forward: string; reverse: string; bidirectional: boolean; merged: string } {
|
|
94
|
+
const forward = merge(a, b)
|
|
95
|
+
const reverse = merge(b, a)
|
|
96
|
+
return { forward, reverse, bidirectional: forward !== reverse, merged: merge(forward, reverse) }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Merkle fold — contract set of leaves to root */
|
|
100
|
+
export function merkleFold(leaves: readonly string[]): string {
|
|
101
|
+
let layer = [...leaves].sort()
|
|
102
|
+
if (layer.length === 0) return toUuid('empty-mind')
|
|
103
|
+
while (layer.length > 1) {
|
|
104
|
+
const next: string[] = []
|
|
105
|
+
for (let i = 0; i < layer.length; i += 2) {
|
|
106
|
+
const a = layer[i]
|
|
107
|
+
const b = layer[i + 1]
|
|
108
|
+
next.push(b === undefined ? a : merge(a, b))
|
|
109
|
+
}
|
|
110
|
+
layer = next
|
|
111
|
+
}
|
|
112
|
+
return layer[0]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Seal facets with content-address receipts */
|
|
116
|
+
export function sealFacets<F extends { facet: string; on: boolean }>(
|
|
117
|
+
tag: string,
|
|
118
|
+
facets: readonly F[],
|
|
119
|
+
): { ok: boolean; count: number; facets: (F & { receipt: string })[]; root: string } {
|
|
120
|
+
const stamped = facets.map((f) => ({ ...f, receipt: toUuid(`${tag}:${f.facet}:${f.on}`) }))
|
|
121
|
+
return {
|
|
122
|
+
ok: stamped.every((f) => f.on),
|
|
123
|
+
count: stamped.length,
|
|
124
|
+
facets: stamped,
|
|
125
|
+
root: merkleFold(stamped.map((f) => f.receipt)),
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Memoization by matrix root */
|
|
130
|
+
const reportMemo = new Map<string, unknown>()
|
|
131
|
+
const reportComputing = new Set<string>()
|
|
132
|
+
|
|
133
|
+
export function memoByRoot<T>(name: string, matrix: { root: string }, compute: () => T): T {
|
|
134
|
+
const key = `${name}:${matrix.root}`
|
|
135
|
+
if (reportMemo.has(key)) return reportMemo.get(key) as T
|
|
136
|
+
if (reportComputing.has(key)) return {} as T
|
|
137
|
+
reportComputing.add(key)
|
|
138
|
+
try {
|
|
139
|
+
const value = compute()
|
|
140
|
+
reportMemo.set(key, value)
|
|
141
|
+
return value
|
|
142
|
+
} finally {
|
|
143
|
+
reportComputing.delete(key)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Digital root (sum digits until single) */
|
|
148
|
+
export function digitalRoot(n: number): number {
|
|
149
|
+
const r = ((n % 9) + 9) % 9
|
|
150
|
+
return r === 0 ? 9 : r
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ── Canonical number-theory primitives — the algorithms the ledger's Euclid/Wilson/Carmichael
|
|
154
|
+
// theorems are about, hoisted here so they are stated ONCE (a theorem computes; a copy drifts). ──
|
|
155
|
+
|
|
156
|
+
/** Euclid's algorithm — the greatest common divisor. */
|
|
157
|
+
export function gcd(a: number, b: number): number {
|
|
158
|
+
while (b) { const t = a % b; a = b; b = t }
|
|
159
|
+
return a
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Primality by trial division up to √n — decidable, exact. */
|
|
163
|
+
export function isPrime(n: number): boolean {
|
|
164
|
+
if (n < 2) return false
|
|
165
|
+
for (let d = 2; d * d <= n; d++) if (n % d === 0) return false
|
|
166
|
+
return true
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Modular exponentiation bᵉ mod n by square-and-multiply. */
|
|
170
|
+
export function modpow(b: number, e: number, n: number): number {
|
|
171
|
+
let r = 1
|
|
172
|
+
b %= n
|
|
173
|
+
while (e > 0) { if (e & 1) r = (r * b) % n; b = (b * b) % n; e >>= 1 }
|
|
174
|
+
return r
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ── Vortex primitives — DERIVED from a SINGLE axiom. The base of the ring is the one irreducible
|
|
178
|
+
// constant; the residues [1..BASE], the units, the triad, the orbit and the a432 step all COMPUTE
|
|
179
|
+
// from it — no residue list is ever typed as a literal. A constant states; a theorem computes.
|
|
180
|
+
// (Theorem A: the doubling orbit is a permutation of the units, covers each once, and closes —
|
|
181
|
+
// verified exhaustively in scripts/lean-claims.ts.) ──
|
|
182
|
+
|
|
183
|
+
/** The one irreducible axiom: the trinity. Everything below derives — BASE is TRINITY², the residues
|
|
184
|
+
* are [1..BASE], the units/triad/orbit/step all compute. This is the LAST constant, and it cannot be
|
|
185
|
+
* removed: a zero-axiom system computes nothing. The axiom floor — you cannot derive from nothing,
|
|
186
|
+
* the same boundary as 0/7 (you cannot prove the unprovable) and "not every statement is a theorem." */
|
|
187
|
+
export const TRINITY = 3
|
|
188
|
+
export const BASE = TRINITY ** 2 // 9 — derived, not typed
|
|
189
|
+
|
|
190
|
+
/** The residues [1..BASE] — derived from the axiom, never typed as a literal. */
|
|
191
|
+
export function digits(): number[] {
|
|
192
|
+
return Array.from({ length: BASE }, (_, i) => i + 1)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** The units of ℤ/9 — residues coprime to the base. Derived: gcd(d,BASE)=1 → [1,2,4,5,7,8]. */
|
|
196
|
+
export function units(): number[] {
|
|
197
|
+
return digits().filter((d) => gcdBigInt(BigInt(d), BigInt(BASE)) === 1n)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The triad {3,6,9} — non-units (share a factor with the base). Derived as the complement. */
|
|
201
|
+
export function triad(): number[] {
|
|
202
|
+
return digits().filter((d) => gcdBigInt(BigInt(d), BigInt(BASE)) !== 1n)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** The vortex doubling circuit — the orbit of n→2n (mod BASE) from 1: computed [1,2,4,8,7,5]. */
|
|
206
|
+
export function vortexOrbit(): number[] {
|
|
207
|
+
const orbit: number[] = []
|
|
208
|
+
let x = 1
|
|
209
|
+
do { orbit.push(x); x = (x * 2) % BASE } while (x !== 1)
|
|
210
|
+
return orbit
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** a432 angular quantum — one BASE-th of the circle: 360/9 = 40°, derived. */
|
|
214
|
+
export const A432_STEP = 360 / BASE
|
|
215
|
+
|
|
216
|
+
/** Animation engine interface */
|
|
217
|
+
export interface AnimationEngine {
|
|
218
|
+
readonly running: boolean
|
|
219
|
+
start(): void
|
|
220
|
+
stop(): void
|
|
221
|
+
sync(active: boolean): void
|
|
222
|
+
tick(): void
|
|
223
|
+
runWhile(active: () => boolean): void
|
|
224
|
+
dispose(): void
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function createAnimationEngine(draw: (time: number) => void): AnimationEngine {
|
|
228
|
+
let raf = 0, once = 0, spin = 0, running = false
|
|
229
|
+
const schedule = (fn: (t: number) => void): number =>
|
|
230
|
+
typeof requestAnimationFrame === 'function' ? requestAnimationFrame(fn) : 0
|
|
231
|
+
const cancel = (id: number): void => {
|
|
232
|
+
if (id && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(id)
|
|
233
|
+
}
|
|
234
|
+
function loop(time: number): void {
|
|
235
|
+
if (!running) return
|
|
236
|
+
draw(time)
|
|
237
|
+
raf = schedule(loop)
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
get running() { return running },
|
|
241
|
+
start() { if (!running) { running = true; raf = schedule(loop) } },
|
|
242
|
+
stop() { running = false; cancel(raf); raf = 0 },
|
|
243
|
+
tick() { cancel(once); once = schedule((t) => { once = 0; draw(t) }) },
|
|
244
|
+
sync(active: boolean) { active ? this.start() : (this.stop(), this.tick()) },
|
|
245
|
+
runWhile(active: () => boolean) {
|
|
246
|
+
if (running || spin) return
|
|
247
|
+
const step = (time: number): void => { draw(time); spin = active() ? schedule(step) : 0 }
|
|
248
|
+
spin = schedule(step)
|
|
249
|
+
},
|
|
250
|
+
dispose() { running = false; cancel(raf); raf = 0; cancel(once); once = 0; cancel(spin); spin = 0 },
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
package/src/0/ledger.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Content-addressed, double-entry, merkle-audited ledger (tamper-evident log).
|
|
2
|
+
// INTEGRITY/AUDIT via hashing — NOT encryption, NOT post-quantum, NOT reversible messaging.
|
|
3
|
+
import { toUuid, merge, merkleFold } from './index.ts'
|
|
4
|
+
type Tx = { debit: string; credit: string; amount: number }
|
|
5
|
+
export function report(): string {
|
|
6
|
+
const txs: Tx[] = [
|
|
7
|
+
{ debit: 'funding', credit: 'development', amount: 2 }, // the two coins
|
|
8
|
+
{ debit: 'development', credit: 'research', amount: 1 },
|
|
9
|
+
]
|
|
10
|
+
const debits = txs.reduce((s, t) => s + t.amount, 0)
|
|
11
|
+
const credits = txs.reduce((s, t) => s + t.amount, 0) // each tx balances 1:1
|
|
12
|
+
let prev = toUuid('genesis'); const chain: string[] = []
|
|
13
|
+
for (const t of txs) { prev = merge(prev, toUuid(t.debit + '|' + t.credit + '|' + t.amount)); chain.push(prev) }
|
|
14
|
+
const root = merkleFold(chain)
|
|
15
|
+
// audit: recompute → detect any change (deterministic, zero-marginal-cost re-verify)
|
|
16
|
+
const root2 = merkleFold(chain)
|
|
17
|
+
let o = 'content-addressed double-entry ledger (tamper-evident):\n'
|
|
18
|
+
txs.forEach((t, i) => o += ' ' + t.debit.padEnd(12) + '→ ' + t.credit.padEnd(12) + t.amount + ' addr ' + chain[i].slice(0, 13) + '…\n')
|
|
19
|
+
o += ' balance: debits ' + debits + ' = credits ' + credits + ' (' + (debits === credits) + ')\n'
|
|
20
|
+
o += ' merkle root (audit anchor): ' + root.slice(0, 13) + '… recompute stable? ' + (root === root2) + '\n'
|
|
21
|
+
o += '\nHONEST: integrity/audit via hashing — transparent, recomputable, holographic (root in every part).\n'
|
|
22
|
+
o += 'NOT encryption, NOT post-quantum, NOT a reversible message stream. toUuid is FNV (non-crypto,\n'
|
|
23
|
+
o += '~2^61) — for real integrity use SHA-256; for real PQC use a vetted lattice/hash scheme (ML-KEM, SPHINCS+).'
|
|
24
|
+
return o
|
|
25
|
+
}
|