Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Pages (no proof, no publish)

# The verify job is the proof checker for the site itself. The deploy job
# needs it, so a broken claim graph cannot reach GitHub Pages: tier
# inflation, a cycle, a JS/Python disagreement, a surviving planted bug,
# or a non-reproducible build all stop publication.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions: {}

concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: false

jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "22"
- name: Python checker, three modes
run: |
python3 -I -B tools/verify.py --write-certificate
python3 -I -O -B tools/verify.py
python3 -I -B -W error tools/verify.py
- name: Certificate on disk matches a fresh one
run: git diff --exit-code -- docs/data/certificate.json
- name: Planted-bug suite (all corruptions must be rejected)
run: python3 -I -B tools/run_mutations.py
- name: JavaScript checker agrees with the Python certificate
run: node --test "test/*.test.mjs"
- name: Deterministic build, twice, byte-identical
run: |
python3 -I -B tools/build.py --verify
cp docs/index.html /tmp/index.first.html
cp docs/data/certificate.json /tmp/certificate.first.json
python3 -I -B tools/build.py --verify
cmp /tmp/index.first.html docs/index.html
cmp /tmp/certificate.first.json docs/data/certificate.json
git diff --exit-code -- docs/index.html docs/data/certificate.json
- uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && vars.PAGES_ENABLED == 'true'
with:
path: docs

deploy:
needs: verify
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && vars.PAGES_ENABLED == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
repo for the formal verification MDE
a formal verification domain for models to operate within
repo for the formal verification MDE
a formal verification domain for models to operate within
goal is to have them apply concepts to unlock scientific/mathematic progress, similar to the way it has been done in [f0](https://github.com/Foundation-0)

blueprint:
[# mcproof](https://github.com/siliconcordat/mde/issues/4)

## The site is a proof

The GitHub Pages site in `docs/` is written as a formal derivation. Every
claim on it is one record in `docs/data/claims.json`, with a kind (axiom,
definition, lemma, theorem, obligation, hazard guard), a certainty tier
(`OPEN` to `PROVEN`), its dependencies, and its evidence. Tiers are never
typed into the page by hand. Two checkers that share no code recompute
them from the tier rules in `docs/data/RULES.md`:

- `tools/verify.py` (Python) writes `docs/data/certificate.json`.
- `docs/assets/proof-core.js` (JavaScript) runs under Node in CI and
again in the visitor's browser, where it rehashes `claims.json` and
compares its verdict with the certificate.

The main claim, Theorem T0, computes to `CONJECTURE` while obligations
O1 to O5 are open. The checkers cap it there, so the site cannot upgrade
its own headline. The page figure, stats, colours, and background weave
are all deterministic functions of the claim graph and its SHA-256.

CI is the gate: the Pages workflow runs the Python checker three ways,
rejects planted corruptions of the graph (`tools/run_mutations.py`),
checks the JavaScript checker against the certificate and runs checker
parity tests (`node --test "test/*.test.mjs"`), and builds the page twice
to prove the output is byte-identical. Upload and deploy run only on
`main` when the repository variable `PAGES_ENABLED` is set to `true`
(Settings → Secrets and variables → Actions → Variables); until then
verify still runs on every push but Pages is not published. No proof, no
publish.

`tools/build.py --verify` rebuilds prerendered regions from
`claims.json`; the workflow's `git diff` step is what catches edits
outside those regions.

Work on it locally:

```sh
python3 -I -B tools/build.py --verify # rebuild docs/index.html
python3 -m http.server -d docs 8000 # then open http://localhost:8000
```

Design lineage: the record-keeping discipline and instrument framing of
[Foundation0](https://fdn0.org), and the style-as-a-point design language
of [Eido](https://github.com/Moissanite-Labs/weft-eido) by Moissanite
Labs. The simplex mixer, circular hue blending, and `data-eido-skip`
condense refusal on proof blocks follow Eido's published modules and
guides.
Empty file added docs/.nojekyll
Empty file.
26 changes: 26 additions & 0 deletions docs/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<base href="/mcproof/">
<title>Not derivable · mcproof</title>
<meta name="robots" content="noindex">
<link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
<style>
body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #f4f1e8; color: #24313c; font: 17px/1.6 ui-sans-serif, system-ui, sans-serif; }
@media (prefers-color-scheme: dark) { body { background: #0d161c; color: #d9e4ea; } a { color: #7fc4d8; } }
main { max-width: 34em; padding: 24px; }
.mark { font-size: 44px; font-family: Georgia, serif; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.92em; }
</style>
</head>
<body>
<main>
<p class="mark" aria-hidden="true">&#8869;</p>
<h1>This page is not derivable.</h1>
<p>The address you asked for is not in the claim graph, and this site does not invent pages outside it. In proof notation: &#8869;, no derivation exists.</p>
<p><a href="./">Return to the axioms</a> &middot; <a href="data/claims.json">Read the graph itself</a></p>
</main>
</body>
</html>
6 changes: 6 additions & 0 deletions docs/assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/og.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
190 changes: 190 additions & 0 deletions docs/assets/proof-core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/* mcproof proof core: pure functions, no DOM, no clock, no randomness.
Implements docs/data/RULES.md. Tested in Node (test/proof-core.test.mjs)
and run live in the browser by site.js. Input is the parsed claims.json. */

export const TIER_RANK = { OPEN: 0, CONJECTURE: 1, KNOWN: 2, VERIFIED: 3, PROVEN: 4 };
export const KINDS = ["axiom", "definition", "lemma", "theorem", "obligation", "hazard"];
export const SECTIONS = ["axioms", "definitions", "baseline", "theorem", "obligations", "hazards"];
/** R2-URL: same rule as tools/verify.py url_ok (docs/data/RULES.md). */
const HOST_RE = /^[A-Za-z0-9.-]+(:[0-9]+)?$/;
const HTTPS_TAIL_RE = /^(\/[A-Za-z0-9_./:@%?&=-]*)?([?#][A-Za-z0-9_./:@%?&=-]*)?$/;
const REL_URL_RE = /^[A-Za-z0-9_./-]+$/;

export function urlOk(u) {
if (typeof u !== "string" || !u) return false;
if (u.startsWith("//")) return false;
if (u.startsWith("https://")) {
const rest = u.slice(8);
if (!rest) return false;
let authEnd = rest.length;
for (const sep of ["/", "?", "#"]) {
const i = rest.indexOf(sep);
if (i !== -1) authEnd = Math.min(authEnd, i);
}
const authority = rest.slice(0, authEnd);
if (!authority || !HOST_RE.test(authority)) return false;
const tail = rest.slice(authEnd);
if (tail && !HTTPS_TAIL_RE.test(tail)) return false;
return true;
}
if (u.split("/").includes("..")) return false;
return REL_URL_RE.test(u);
}
const URL_OK = urlOk;
const ASCII_WS = new Set("\t\n\v\f\r ");

/** R-Text: same rule as tools/verify.py has_text / is_blank_text. */
export function isBlankText(s) {
if (typeof s !== "string" || s.length === 0) return true;
for (const c of s) {
if (!ASCII_WS.has(c)) return false;
}
return true;
}

export function hasText(s) {
return typeof s === "string" && !isBlankText(s);
}

export function checkGraph(doc) {
const errors = [];
const claims = doc && Array.isArray(doc.claims) ? doc.claims : null;
if (!claims || claims.length === 0) return { ok: false, errors: ["claims: missing, not a list, or empty (R1)"], computed: Object.create(null), order: [], openObligations: [] };
const byId = new Map();
for (const c of claims) {
if (!c || typeof c.id !== "string" || !c.id) { errors.push("claim with missing id (R1)"); continue; }
if (byId.has(c.id)) errors.push(`${c.id}: duplicate id`);
if (typeof c.kind !== "string" || !KINDS.includes(c.kind)) errors.push(`${c.id}: unknown kind ${JSON.stringify(c.kind)} (R1)`);
if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(c.id)) errors.push(`${c.id}: id must match ^[A-Za-z][A-Za-z0-9_-]*$ (R1)`);
if (!hasText(c.title)) errors.push(`${c.id}: missing title (R1)`);
if (!hasText(c.statement)) errors.push(`${c.id}: missing statement (R1)`);
if (typeof c.section !== "string" || !SECTIONS.includes(c.section)) errors.push(`${c.id}: unknown section ${JSON.stringify(c.section)} (R1)`);
if (typeof c.asserted_tier !== "string" || !Object.hasOwn(TIER_RANK, c.asserted_tier)) errors.push(`${c.id}: unknown tier ${JSON.stringify(c.asserted_tier)} (R1)`);
if (!Array.isArray(c.depends_on)) errors.push(`${c.id}: depends_on is not a list`);
if (Object.hasOwn(c, "evidence") && !Array.isArray(c.evidence)) errors.push(`${c.id}: evidence is not a list (R2)`);
byId.set(c.id, c);
}
for (const c of claims) {
if (!c || typeof c.id !== "string" || !byId.has(c.id)) continue;
for (const d of Array.isArray(c.depends_on) ? c.depends_on : []) {
if (!byId.has(d)) errors.push(`${c.id}: depends on missing claim ${JSON.stringify(d)} (R1)`);
}
if (Object.hasOwn(c, "evidence") && !Array.isArray(c.evidence)) continue;
const ev = Array.isArray(c.evidence) ? c.evidence : [];
for (const e of ev) {
if (!e || typeof e !== "object" || !hasText(e.label) || !URL_OK(e.url)) {
errors.push(`${c.id}: evidence must be {label, https-or-relative url} (R2)`);
}
}
for (const d of Array.isArray(c.depends_on) ? c.depends_on : []) {
if (typeof d !== "string") errors.push(`${c.id}: depends_on entries must be strings (R1)`);
}
if ((c.asserted_tier === "VERIFIED" || c.asserted_tier === "PROVEN") && ev.length === 0) {
errors.push(`${c.id}: asserted ${c.asserted_tier} with no evidence (R2)`);
}
if (c.kind === "obligation" && c.asserted_tier === "OPEN" && ev.length > 0) {
errors.push(`${c.id}: OPEN obligation carries evidence (R2)`);
}
}
// Topological order, deterministic: Kahn with lexicographic tie-break.
const indeg = new Map(), dependents = new Map();
for (const id of byId.keys()) { indeg.set(id, 0); dependents.set(id, []); }
for (const c of byId.values()) {
for (const d of Array.isArray(c.depends_on) ? c.depends_on : []) {
if (byId.has(d)) { indeg.set(c.id, indeg.get(c.id) + 1); dependents.get(d).push(c.id); }
}
}
const ready = [...byId.keys()].filter((id) => indeg.get(id) === 0).sort();
const order = [];
while (ready.length) {
const id = ready.shift();
order.push(id);
for (const nxt of dependents.get(id).slice().sort()) {
indeg.set(nxt, indeg.get(nxt) - 1);
if (indeg.get(nxt) === 0) { ready.push(nxt); ready.sort(); }
}
}
if (order.length !== byId.size) errors.push("dependency graph has a cycle (R1)");

const computed = Object.create(null);
for (const id of order) {
const c = byId.get(id);
const tierKey = c.asserted_tier;
const asserted = typeof tierKey === "string" ? TIER_RANK[tierKey] : undefined;
if (asserted === undefined) { computed[id] = "OPEN"; continue; }
let allowed = asserted;
if (c.kind !== "axiom" && c.kind !== "definition") {
const depTiers = (Array.isArray(c.depends_on) ? c.depends_on : [])
.filter((d) => byId.has(d)).map((d) => ({ id: d, tier: computed[d], rank: TIER_RANK[computed[d]] }));
if (depTiers.some((d) => d.rank <= 1)) allowed = Math.min(allowed, 1);
if (tierKey === "PROVEN") {
const weak = depTiers.filter((d) => {
const k = byId.get(d.id).kind;
return !(d.rank >= 3 || k === "axiom" || k === "definition");
});
if (weak.length) allowed = Math.min(allowed, 3);
}
}
if (asserted > allowed) {
errors.push(`${id}: asserted ${tierKey} exceeds allowed tier (R3)`);
computed[id] = "OPEN";
} else {
computed[id] = tierKey;
}
}
const open = order.filter((id) => byId.get(id).kind === "obligation" && computed[id] === "OPEN");
return { ok: errors.length === 0, errors, computed, order, openObligations: open };
}

/* Deterministic layout of the proof DAG: layer = longest path from a root.
Same graph, same coordinates, on every machine. */
export function layoutGraph(doc, order) {
const byId = new Map(doc.claims.map((c) => [c.id, c]));
const layer = {};
for (const id of order) {
const deps = (byId.get(id).depends_on || []).filter((d) => byId.has(d));
layer[id] = deps.length ? Math.max(...deps.map((d) => layer[d])) + 1 : 0;
}
const rows = new Map();
for (const id of order) {
if (!rows.has(layer[id])) rows.set(layer[id], []);
rows.get(layer[id]).push(id);
}
const pos = {};
for (const [lv, ids] of rows) ids.forEach((id, i) => { pos[id] = { layer: lv, index: i, rowSize: ids.length }; });
return { pos, layers: rows.size };
}

/* Seeded PRNG (mulberry32) so the decorative weave is a function of the
graph hash, never of the clock. Seed from the first 8 hex chars of a hash. */
export function seededRand(seedHex) {
let a = parseInt(String(seedHex).slice(0, 8), 16) >>> 0;
if (!Number.isFinite(a)) a = 0;
return function () {
a |= 0; a = (a + 0x6D2B79F5) | 0;
let t = Math.imul(a ^ (a >>> 15), 1 | a);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}

/* Style as a point in space, after Eido's aesthetic mixer: linear tokens
average linearly, hue averages on the circle so 0.95 and 0.05 stay red. */
export function mixPresets(presets, weights) {
const out = {};
let hx = 0, hy = 0, total = 0;
for (const [name, w] of Object.entries(weights)) {
const p = presets[name];
if (!p || !(w > 0)) continue;
total += w;
for (const [k, v] of Object.entries(p)) {
if (k === "hue") { hx += w * Math.cos(v * 2 * Math.PI); hy += w * Math.sin(v * 2 * Math.PI); }
else out[k] = (out[k] || 0) + w * v;
}
}
if (total === 0) return out;
for (const k of Object.keys(out)) out[k] /= total;
let hue = Math.atan2(hy, hx) / (2 * Math.PI);
out.hue = ((hue % 1) + 1) % 1;
return out;
}
Loading
Loading