snapkitty
agents
idris2
lean4
SNAPKITTYWEST's picture
push from SNAPKITTYWEST/sovereign-agi-kernel
1cdfc83 verified
Raw History Blame Contribute Delete
4.55 kB
#!/usr/bin/env node
// Erdos-Straus DSS Runtime — Full Demonstration
// Computes the greedy sequence, verifies the quadratic bound,
// then runs all four application simulations.
import { computeGreedySequence, verifyQuadraticBound, isDSS } from './greedy.mjs';
import { runFaultIsolationDemo } from './fault-isolation.mjs';
import { runNetworkTomographyDemo } from './network-tomography.mjs';
import { runThresholdCryptoDemo } from './threshold-crypto.mjs';
import { runFinancialForensicsDemo } from './financial-forensics.mjs';
console.log();
console.log('#'.repeat(70));
console.log('# ERDOS-STRAUS DSS GREEDY BOUND — RUNTIME DEMONSTRATION');
console.log('# Paper: "An Elementary Quadratic Lower Bound for the Greedy Sequence"');
console.log('# Author: Ahmad Parr');
console.log('#'.repeat(70));
console.log();
// Phase 1: Compute and verify the greedy sequence
console.log('PHASE 1: GREEDY SEQUENCE COMPUTATION');
console.log('='.repeat(70));
console.log();
const K = 15;
console.log(`Computing first ${K} terms of the greedy DSS sequence...`);
const start = performance.now();
const seq = computeGreedySequence(K);
const elapsed = (performance.now() - start).toFixed(1);
console.log(`Done in ${elapsed}ms`);
console.log();
console.log(`Greedy sequence g(1)..g(${K}):`);
console.log(` [${seq.join(', ')}]`);
console.log();
// Verify DSS property
console.log('Verifying DSS property on full sequence...');
const dssValid = isDSS(seq);
console.log(` isDSS([${seq.join(',')}]) = ${dssValid}`);
console.log();
// Phase 2: Verify quadratic bound
console.log('PHASE 2: QUADRATIC BOUND VERIFICATION');
console.log('='.repeat(70));
console.log();
console.log('Theorem: g(k) >= (k^2 + 1) / 2 for all k >= 1');
console.log();
const bounds = verifyQuadraticBound(seq);
console.log(' k | g(k) | (k^2+1)/2 | holds | ratio');
console.log(' ---+------+-----------+-------+------');
for (const b of bounds) {
console.log(` ${String(b.k).padStart(2)} | ${String(b.greedy).padStart(3)} | ${String(b.bound).padStart(4)} | ${b.holds ? 'YES' : ' NO'} | ${b.ratio}`);
}
console.log();
const allHold = bounds.every(b => b.holds);
console.log(`All bounds hold: ${allHold ? 'VERIFIED' : 'FAILED'}`);
console.log();
// Phase 3: Gap lemma verification
console.log('PHASE 3: GAP LEMMA VERIFICATION');
console.log('='.repeat(70));
console.log();
console.log('Lemma: g(k+1) - g(k) >= k for all k >= 1');
console.log();
const gaps = [];
for (let k = 1; k < seq.length; k++) {
const gap = seq[k] - seq[k-1];
const required = k;
gaps.push({ k, gap, required, holds: gap >= required });
console.log(` g(${k+1}) - g(${k}) = ${seq[k]} - ${seq[k-1]} = ${gap} >= ${required} : ${gap >= required ? 'YES' : 'NO'}`);
}
const gapHolds = gaps.every(g => g.holds);
console.log(`\nAll gap inequalities hold: ${gapHolds ? 'VERIFIED' : 'FAILED'}`);
console.log();
// Phase 4: Applications
console.log();
console.log('#'.repeat(70));
console.log('# APPLICATIONS OF THE DSS PROPERTY');
console.log('#'.repeat(70));
console.log();
runFaultIsolationDemo();
console.log();
runNetworkTomographyDemo();
console.log();
runThresholdCryptoDemo();
console.log();
runFinancialForensicsDemo();
// Summary
console.log();
console.log('#'.repeat(70));
console.log('# SUMMARY');
console.log('#'.repeat(70));
console.log();
console.log('The Erdos-Straus DSS property provides a CARDINALITY ORACLE:');
console.log('from a single aggregate number, determine HOW MANY components');
console.log('contributed to it — without knowing WHICH ones.');
console.log();
console.log('Applications demonstrated:');
console.log(' 1. Fault Isolation — interaction order from test signal');
console.log(' 2. Network Tomography — packet count from aggregate ACK');
console.log(' 3. Threshold Crypto — signer count without identity');
console.log(' 4. Financial Forensics — channel count for anti-structuring');
console.log();
console.log('Quadratic bound g(k) >= (k^2+1)/2 means:');
console.log(` k=10 components need weights up to ~${Math.floor(10*10/2)} (4 bits)`);
console.log(` k=50 components need weights up to ~${Math.floor(50*50/2)} (11 bits)`);
console.log(` k=100 components need weights up to ~${Math.floor(100*100/2)} (13 bits)`);
console.log(` k=1000 components need weights up to ~${Math.floor(1000*1000/2)} (20 bits)`);
console.log();
console.log('All practical applications sit well within 32-bit integer range.');
console.log();