Each theory in the bounded arithmetic hierarchy can prove statements about numbers, but only using predicates from a matching complexity class. Pick a statement below and see which level of the hierarchy is strong enough to prove it — and which levels fall short.
<p class="hint">Each theory in the bounded arithmetic hierarchy can only prove statements about predicates up to a certain complexity level. Select a statement and explore which theory is strong enough to handle it — and which ones fall short.</p>
<div class="controls">
<label for="stmt-select">Choose a statement:</label>
<select id="stmt-select"></select>
</div>
<div class="hierarchy" id="hierarchy"></div>
<div class="detail-box" id="detail-box">
<div class="detail-title" id="detail-title"></div>
<div class="detail-body" id="detail-body"></div>
</div>
<div class="btns">
<button id="btn-check" type="button">Check which theories prove it</button>
<button id="btn-reset" type="button" class="ghost">Reset</button>
</div>
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; color: #222; margin: 0; font-size: 14px; }
.hint { font-size: .88rem; color: #444; margin: 0 0 .7rem; line-height: 1.45; }
.controls { margin-bottom: .8rem; }
label { font-weight: 600; margin-right: .5rem; }
select { font: 14px system-ui, sans-serif; padding: .35rem .5rem; border: 1px solid #aaa;
border-radius: 6px; background: #f8f9fa; cursor: pointer; max-width: 100%; }
.hierarchy { display: flex; gap: 6px; flex-wrap: wrap; margin: .6rem 0 .8rem; align-items: center; }
.theory { padding: .35rem .7rem; border-radius: 8px; border: 2px solid #cdd9e3;
background: #e8eef3; font-weight: 700; font-size: .85rem; cursor: pointer;
transition: all .18s; user-select: none; min-width: 52px; text-align: center; }
.theory:hover { border-color: #1d3557; }
.theory.can-prove { background: #0a7d33; border-color: #087d2f; color: #fff; }
.theory.cannot-prove { background: #e63946; border-color: #c92f3c; color: #fff; }
.theory.unknown { background: #f4a261; border-color: #e07b35; color: #fff; }
.arrow { color: #aaa; font-size: 1.1rem; line-height: 1; }
.detail-box { background: #f0f4f7; border: 1px solid #cdd9e3; border-radius: 8px;
padding: .6rem .8rem; min-height: 54px; margin-bottom: .7rem; }
.detail-title { font-weight: 700; margin-bottom: .25rem; color: #1d3557; font-size: .9rem; }
.detail-body { font-size: .85rem; line-height: 1.45; color: #333; }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: .5rem; }
.leg { display: flex; align-items: center; gap: .35rem; font-size: .78rem; }
.leg-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; }
button { font: 600 13px system-ui, sans-serif; padding: .45rem .9rem; border: 1px solid #1d3557;
background: #1d3557; color: #fff; border-radius: 8px; cursor: pointer; }
button.ghost { background: #fff; color: #1d3557; }
const fmt = (s, v) => s.replace(/%(\w+)%/g, (_, k) => String(v[k] ?? ''));
// Bounded Arithmetic Hierarchy Demo
// The Buss hierarchy: S2^1 ⊆ T2^1 ⊆ S2^2 ⊆ T2^2 ⊆ ...
// Each theory corresponds to a complexity class:
// S2^1 ↔ P (polynomial-time predicates, Σ1^b induction)
// T2^1 ↔ NP ∩ co-NP (NP predicates, Π1^b induction)
// S2^2 ↔ Σ2^p (NP^NP predicates)
// T2^2 ↔ Π2^p
// PV ↔ P (Cook’s equational theory, same power as S2^1)
const THEORIES = [
{ id: 'PV', label: 'PV', level: 0, cls: 'P', desc: `Cook’s equational theory PV — captures exactly polynomial-time (P) functions. Every provably total function is in P.` },
{ id: 'S21', label: 'S₂¹', level: 0, cls: 'P', desc: `Base theory S₂¹ (Buss 1986) — induction over Σ₁ᵇ formulas. Every provably total function lies in polynomial time (P).` },
{ id: 'T21', label: 'T₂¹', level: 1, cls: 'NP∩co-NP', desc: `Theory T₂¹ — adds Π₁ᵇ induction. Captures NP ∩ co-NP: problems whose YES and NO answers are both polynomially checkable.` },
{ id: 'S22', label: 'S₂²', level: 2, cls: 'Σ₂ᵖ', desc: `Theory S₂² — Σ₂ᵇ induction. Mirrors Σ₂ᵖ = NP^NP, problems solvable in NP with an NP oracle.` },
{ id: 'T22', label: 'T₂²', level: 3, cls: 'Π₂ᵖ', desc: `Theory T₂² — Π₂ᵇ induction. Mirrors Π₂ᵖ = co-NP^NP.` },
{ id: 'S2', label: 'S₂', level: 4, cls: 'PH', desc: `Full theory S₂ = ∪ Sᵢ² — union of all finite levels. Captures the entire polynomial hierarchy (PH).` },
];
// Statements with their minimum theory level needed, and whether the separation is known
const STATEMENTS = [
{
id: 'sort',
label: `Every finite list has a sorted permutation`,
minLevel: 0,
known: true,
explanation: `Sorting is in P (e.g., merge sort runs in O(n log n)). The existence of a sorted permutation is provable in PV and S₂¹ using Σ₁ᵇ induction — a polynomial-time witness can be constructed explicitly.`
},
{
id: 'pigeonhole',
label: `Pigeonhole: n+1 pigeons in n holes ⟹ some hole has ≥ 2`,
minLevel: 1,
known: true,
explanation: `The pigeonhole principle (PHP) is a classic benchmark. It is NOT provable in PV or S₂¹ — Paris & Wilkie (1985) showed PHP requires Π₁ᵇ induction. It IS provable in T₂¹ and above. The separation S₂¹ < T₂¹ on PHP is one of the few known results.`
},
{
id: 'sat-np',
label: `SAT is in NP (a satisfying assignment is polynomially verifiable)`,
minLevel: 1,
known: true,
explanation: `The statement that a satisfying assignment can be verified in polynomial time is captured by NP ∩ co-NP reasoning. T₂¹ can formalize this because it has Π₁ᵇ induction, which lets it reason about both NP witnesses and co-NP co-witnesses.`
},
{
id: 'sigma2',
label: `Every Σ₂ᵖ problem reduces to Σ₂-SAT`,
minLevel: 2,
known: true,
explanation: `Reasoning about reductions at the second level of the polynomial hierarchy requires Σ₂ᵇ induction — the strength of S₂². Lower theories lack the quantifier alternation needed to express these reductions internally.`
},
{
id: 'p-neq-np',
label: 'P ≠ NP',
minLevel: 5,
known: false,
explanation: `Nobody knows which theory (if any finite level) proves P ≠ NP. In fact, proving P ≠ NP likely requires a fundamentally new technique. It may not be provable even in S₂ without non-relativizing methods, making it independent of the current bounded arithmetic framework.`
},
{
id: 's21-neq-t21',
label: `S₂¹ ≠ T₂¹ (the base separation)`,
minLevel: 5,
known: false,
explanation: `The conjecture that S₂¹ is strictly weaker than T₂¹ is widely believed but unproven. Proving it would imply P ≠ NP. We know PHP separates them as a statement (PHP unprovable in S₂¹), but the full structural separation — that the two theories prove different sentences — remains open.`
},
];
const MAX_LEVEL = 4; // 0..4 correspond to THEORIES indices
function buildUI() {
const sel = document.getElementById('stmt-select');
STATEMENTS.forEach((s, i) => {
const opt = document.createElement('option');
opt.value = i;
opt.textContent = s.label;
sel.appendChild(opt);
});
const hier = document.getElementById('hierarchy');
THEORIES.forEach((t, i) => {
if (i > 0) {
const arr = document.createElement('span');
arr.className = 'arrow';
arr.textContent = '⊆';
hier.appendChild(arr);
}
const div = document.createElement('div');
div.className = 'theory';
div.id = 'theory-' + t.id;
div.textContent = t.label;
div.title = t.cls;
div.addEventListener('click', () => showTheoryDetail(t));
hier.appendChild(div);
});
// Legend
const leg = document.createElement('div');
leg.className = 'legend';
leg.innerHTML = "\n " + `<div class="leg"><div class="leg-dot" style="background:#0a7d33"></div> Proves it</div>
<div class="leg"><div class="leg-dot" style="background:#e63946"></div> Cannot prove it</div>
<div class="leg"><div class="leg-dot" style="background:#f4a261"></div> Unknown / open</div>
<div class="leg"><div class="leg-dot" style="background:#e8eef3;border:1px solid #cdd9e3"></div> Not checked yet</div>` + "\n ";
document.getElementById('hierarchy').parentNode.insertBefore(leg, document.getElementById('detail-box'));
}
function showTheoryDetail(t) {
document.getElementById('detail-title').textContent = fmt(`%label% — complexity class: %cls%`, { label: t.label, cls: t.cls });
document.getElementById('detail-body').textContent = t.desc;
}
function checkStatement() {
const idx = parseInt(document.getElementById('stmt-select').value);
const stmt = STATEMENTS[idx];
THEORIES.forEach((t, i) => {
const el = document.getElementById('theory-' + t.id);
el.classList.remove('can-prove', 'cannot-prove', 'unknown');
if (!stmt.known) {
el.classList.add('unknown');
} else if (t.level >= stmt.minLevel) {
el.classList.add('can-prove');
} else {
el.classList.add('cannot-prove');
}
});
document.getElementById('detail-title').textContent = '"' + stmt.label + '"';
document.getElementById('detail-body').textContent = stmt.explanation;
// Console output for verification
console.log(`Statement:`, stmt.label);
console.log(`Known result:`, stmt.known);
if (stmt.known) {
console.log(`Minimum level needed:`, stmt.minLevel,
'| First theory to prove it:', THEORIES.find(t => t.level >= stmt.minLevel)?.label);
} else {
console.log(`Status: OPEN — separation not yet proved`);
}
}
function reset() {
THEORIES.forEach(t => {
const el = document.getElementById('theory-' + t.id);
el.classList.remove('can-prove', 'cannot-prove', 'unknown');
});
document.getElementById('detail-title').textContent = '';
document.getElementById('detail-body').textContent = `Click "Check which theories prove it" to see results.`;
}
document.getElementById('btn-check').addEventListener('click', checkStatement);
document.getElementById('btn-reset').addEventListener('click', reset);
buildUI();
document.getElementById('detail-body').textContent = `Select a statement above and click the button to explore the hierarchy.`;
<p class="hint">Each theory in the bounded arithmetic hierarchy can only prove statements about predicates up to a certain complexity level. Select a statement and explore which theory is strong enough to handle it — and which ones fall short.</p>
<div class="controls">
<label for="stmt-select">Choose a statement:</label>
<select id="stmt-select"></select>
</div>
<div class="hierarchy" id="hierarchy"></div>
<div class="detail-box" id="detail-box">
<div class="detail-title" id="detail-title"></div>
<div class="detail-body" id="detail-body"></div>
</div>
<div class="btns">
<button id="btn-check" type="button">Check which theories prove it</button>
<button id="btn-reset" type="button" class="ghost">Reset</button>
</div>
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; color: #222; margin: 0; font-size: 14px; }
.hint { font-size: .88rem; color: #444; margin: 0 0 .7rem; line-height: 1.45; }
.controls { margin-bottom: .8rem; }
label { font-weight: 600; margin-right: .5rem; }
select { font: 14px system-ui, sans-serif; padding: .35rem .5rem; border: 1px solid #aaa;
border-radius: 6px; background: #f8f9fa; cursor: pointer; max-width: 100%; }
.hierarchy { display: flex; gap: 6px; flex-wrap: wrap; margin: .6rem 0 .8rem; align-items: center; }
.theory { padding: .35rem .7rem; border-radius: 8px; border: 2px solid #cdd9e3;
background: #e8eef3; font-weight: 700; font-size: .85rem; cursor: pointer;
transition: all .18s; user-select: none; min-width: 52px; text-align: center; }
.theory:hover { border-color: #1d3557; }
.theory.can-prove { background: #0a7d33; border-color: #087d2f; color: #fff; }
.theory.cannot-prove { background: #e63946; border-color: #c92f3c; color: #fff; }
.theory.unknown { background: #f4a261; border-color: #e07b35; color: #fff; }
.arrow { color: #aaa; font-size: 1.1rem; line-height: 1; }
.detail-box { background: #f0f4f7; border: 1px solid #cdd9e3; border-radius: 8px;
padding: .6rem .8rem; min-height: 54px; margin-bottom: .7rem; }
.detail-title { font-weight: 700; margin-bottom: .25rem; color: #1d3557; font-size: .9rem; }
.detail-body { font-size: .85rem; line-height: 1.45; color: #333; }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: .5rem; }
.leg { display: flex; align-items: center; gap: .35rem; font-size: .78rem; }
.leg-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; }
button { font: 600 13px system-ui, sans-serif; padding: .45rem .9rem; border: 1px solid #1d3557;
background: #1d3557; color: #fff; border-radius: 8px; cursor: pointer; }
button.ghost { background: #fff; color: #1d3557; }
const fmt = (s, v) => s.replace(/%(\w+)%/g, (_, k) => String(v[k] ?? ''));
// Bounded Arithmetic Hierarchy Demo
// The Buss hierarchy: S2^1 ⊆ T2^1 ⊆ S2^2 ⊆ T2^2 ⊆ ...
// Each theory corresponds to a complexity class:
// S2^1 ↔ P (polynomial-time predicates, Σ1^b induction)
// T2^1 ↔ NP ∩ co-NP (NP predicates, Π1^b induction)
// S2^2 ↔ Σ2^p (NP^NP predicates)
// T2^2 ↔ Π2^p
// PV ↔ P (Cook’s equational theory, same power as S2^1)
const THEORIES = [
{ id: 'PV', label: 'PV', level: 0, cls: 'P', desc: `Cook’s equational theory PV — captures exactly polynomial-time (P) functions. Every provably total function is in P.` },
{ id: 'S21', label: 'S₂¹', level: 0, cls: 'P', desc: `Base theory S₂¹ (Buss 1986) — induction over Σ₁ᵇ formulas. Every provably total function lies in polynomial time (P).` },
{ id: 'T21', label: 'T₂¹', level: 1, cls: 'NP∩co-NP', desc: `Theory T₂¹ — adds Π₁ᵇ induction. Captures NP ∩ co-NP: problems whose YES and NO answers are both polynomially checkable.` },
{ id: 'S22', label: 'S₂²', level: 2, cls: 'Σ₂ᵖ', desc: `Theory S₂² — Σ₂ᵇ induction. Mirrors Σ₂ᵖ = NP^NP, problems solvable in NP with an NP oracle.` },
{ id: 'T22', label: 'T₂²', level: 3, cls: 'Π₂ᵖ', desc: `Theory T₂² — Π₂ᵇ induction. Mirrors Π₂ᵖ = co-NP^NP.` },
{ id: 'S2', label: 'S₂', level: 4, cls: 'PH', desc: `Full theory S₂ = ∪ Sᵢ² — union of all finite levels. Captures the entire polynomial hierarchy (PH).` },
];
// Statements with their minimum theory level needed, and whether the separation is known
const STATEMENTS = [
{
id: 'sort',
label: `Every finite list has a sorted permutation`,
minLevel: 0,
known: true,
explanation: `Sorting is in P (e.g., merge sort runs in O(n log n)). The existence of a sorted permutation is provable in PV and S₂¹ using Σ₁ᵇ induction — a polynomial-time witness can be constructed explicitly.`
},
{
id: 'pigeonhole',
label: `Pigeonhole: n+1 pigeons in n holes ⟹ some hole has ≥ 2`,
minLevel: 1,
known: true,
explanation: `The pigeonhole principle (PHP) is a classic benchmark. It is NOT provable in PV or S₂¹ — Paris & Wilkie (1985) showed PHP requires Π₁ᵇ induction. It IS provable in T₂¹ and above. The separation S₂¹ < T₂¹ on PHP is one of the few known results.`
},
{
id: 'sat-np',
label: `SAT is in NP (a satisfying assignment is polynomially verifiable)`,
minLevel: 1,
known: true,
explanation: `The statement that a satisfying assignment can be verified in polynomial time is captured by NP ∩ co-NP reasoning. T₂¹ can formalize this because it has Π₁ᵇ induction, which lets it reason about both NP witnesses and co-NP co-witnesses.`
},
{
id: 'sigma2',
label: `Every Σ₂ᵖ problem reduces to Σ₂-SAT`,
minLevel: 2,
known: true,
explanation: `Reasoning about reductions at the second level of the polynomial hierarchy requires Σ₂ᵇ induction — the strength of S₂². Lower theories lack the quantifier alternation needed to express these reductions internally.`
},
{
id: 'p-neq-np',
label: 'P ≠ NP',
minLevel: 5,
known: false,
explanation: `Nobody knows which theory (if any finite level) proves P ≠ NP. In fact, proving P ≠ NP likely requires a fundamentally new technique. It may not be provable even in S₂ without non-relativizing methods, making it independent of the current bounded arithmetic framework.`
},
{
id: 's21-neq-t21',
label: `S₂¹ ≠ T₂¹ (the base separation)`,
minLevel: 5,
known: false,
explanation: `The conjecture that S₂¹ is strictly weaker than T₂¹ is widely believed but unproven. Proving it would imply P ≠ NP. We know PHP separates them as a statement (PHP unprovable in S₂¹), but the full structural separation — that the two theories prove different sentences — remains open.`
},
];
const MAX_LEVEL = 4; // 0..4 correspond to THEORIES indices
function buildUI() {
const sel = document.getElementById('stmt-select');
STATEMENTS.forEach((s, i) => {
const opt = document.createElement('option');
opt.value = i;
opt.textContent = s.label;
sel.appendChild(opt);
});
const hier = document.getElementById('hierarchy');
THEORIES.forEach((t, i) => {
if (i > 0) {
const arr = document.createElement('span');
arr.className = 'arrow';
arr.textContent = '⊆';
hier.appendChild(arr);
}
const div = document.createElement('div');
div.className = 'theory';
div.id = 'theory-' + t.id;
div.textContent = t.label;
div.title = t.cls;
div.addEventListener('click', () => showTheoryDetail(t));
hier.appendChild(div);
});
// Legend
const leg = document.createElement('div');
leg.className = 'legend';
leg.innerHTML = "\n " + `<div class="leg"><div class="leg-dot" style="background:#0a7d33"></div> Proves it</div>
<div class="leg"><div class="leg-dot" style="background:#e63946"></div> Cannot prove it</div>
<div class="leg"><div class="leg-dot" style="background:#f4a261"></div> Unknown / open</div>
<div class="leg"><div class="leg-dot" style="background:#e8eef3;border:1px solid #cdd9e3"></div> Not checked yet</div>` + "\n ";
document.getElementById('hierarchy').parentNode.insertBefore(leg, document.getElementById('detail-box'));
}
function showTheoryDetail(t) {
document.getElementById('detail-title').textContent = fmt(`%label% — complexity class: %cls%`, { label: t.label, cls: t.cls });
document.getElementById('detail-body').textContent = t.desc;
}
function checkStatement() {
const idx = parseInt(document.getElementById('stmt-select').value);
const stmt = STATEMENTS[idx];
THEORIES.forEach((t, i) => {
const el = document.getElementById('theory-' + t.id);
el.classList.remove('can-prove', 'cannot-prove', 'unknown');
if (!stmt.known) {
el.classList.add('unknown');
} else if (t.level >= stmt.minLevel) {
el.classList.add('can-prove');
} else {
el.classList.add('cannot-prove');
}
});
document.getElementById('detail-title').textContent = '"' + stmt.label + '"';
document.getElementById('detail-body').textContent = stmt.explanation;
// Console output for verification
console.log(`Statement:`, stmt.label);
console.log(`Known result:`, stmt.known);
if (stmt.known) {
console.log(`Minimum level needed:`, stmt.minLevel,
'| First theory to prove it:', THEORIES.find(t => t.level >= stmt.minLevel)?.label);
} else {
console.log(`Status: OPEN — separation not yet proved`);
}
}
function reset() {
THEORIES.forEach(t => {
const el = document.getElementById('theory-' + t.id);
el.classList.remove('can-prove', 'cannot-prove', 'unknown');
});
document.getElementById('detail-title').textContent = '';
document.getElementById('detail-body').textContent = `Click "Check which theories prove it" to see results.`;
}
document.getElementById('btn-check').addEventListener('click', checkStatement);
document.getElementById('btn-reset').addEventListener('click', reset);
buildUI();
document.getElementById('detail-body').textContent = `Select a statement above and click the button to explore the hierarchy.`;
Comments
Loading comments...