// Cross-check isitsolved lean-open Erdős main statements against teorth/erdosproblems status and current FC category. // usage: node crosscheck.js lo_all.json problems.yaml fcDir out.csv const fs = require("fs"), path = require("path"); const [loFile, yFile, fcDir, out] = process.argv.slice(2); const st = {}; for (const b of fs.readFileSync(yFile, "utf8").split(/\n- number: /)) { const n = (b.match(/^"?(\d+)"?/) || [])[1]; const m = b.match(/informal_status:\s*\n\s*state: "([^"]+)"\s*\n\s*last_update: "([^"]+)"/); if (n && m) st[n] = { s: m[1], u: m[2] }; } const rows = []; for (const x of JSON.parse(fs.readFileSync(loFile, "utf8"))) { if (!x.erdos || x.source_id !== `Erdos${x.erdos}.erdos_${x.erdos}`) continue; const t = fs.readFileSync(path.join(fcDir, x.erdos + ".lean"), "utf8"); const i = t.search(new RegExp("\\n\\s*theorem erdos_" + x.erdos + "(\\s|:)")); let cat = "NOT_FOUND"; if (i >= 0) { const before = t.slice(Math.max(0, i - 600), i); const a = before.lastIndexOf("@["); cat = a >= 0 ? ((before.slice(a).match(/category ([a-z ]+?)\s*[,\]]/) || [])[1] || "none") : "no-attr"; } const s = st[x.erdos] || { s: "", u: "" }; rows.push([x.id, x.erdos, s.s, s.u, cat]); } rows.sort((p, q) => p[1] - q[1]); fs.writeFileSync(out, "longlist_id,erdos,erdosproblems_informal_status,status_last_update,fc_main_category\n" + rows.map(r => r.join(",")).join("\n") + "\n"); const c = {}; rows.forEach(r => (c[r[4]] = (c[r[4]] || 0) + 1)); const d = {}; rows.forEach(r => (d[r[2]] = (d[r[2]] || 0) + 1)); console.log(rows.length, JSON.stringify(c), JSON.stringify(d));