snapkitty
agents
idris2
lean4
File size: 4,549 Bytes
1cdfc83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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();