gdp-wired 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -2
- package/dist/core/bmc.d.ts +49 -0
- package/dist/core/bmc.js +509 -0
- package/dist/core/check.d.ts +1 -1
- package/dist/core/check.js +19 -6
- package/dist/core/cycles.d.ts +38 -0
- package/dist/core/cycles.js +531 -43
- package/dist/core/data.d.ts +25 -1
- package/dist/core/data.js +984 -215
- package/dist/core/discover.js +8 -3
- package/dist/core/dsl.d.ts +17 -3
- package/dist/core/dsl.js +81 -15
- package/dist/core/extract-check.d.ts +77 -0
- package/dist/core/extract-check.js +785 -0
- package/dist/core/extract-ir.d.ts +139 -0
- package/dist/core/extract-ir.js +198 -0
- package/dist/core/extract-print.d.ts +30 -0
- package/dist/core/extract-print.js +426 -0
- package/dist/core/extract-read.d.ts +298 -0
- package/dist/core/extract-read.js +1298 -0
- package/dist/core/extract-shapes.d.ts +13 -0
- package/dist/core/extract-shapes.js +993 -0
- package/dist/core/extract-xstate.d.ts +34 -0
- package/dist/core/extract-xstate.js +320 -0
- package/dist/core/extract.d.ts +31 -0
- package/dist/core/extract.js +249 -0
- package/dist/core/infer.js +518 -5
- package/dist/core/kind.d.ts +30 -0
- package/dist/core/kind.js +81 -0
- package/dist/core/nonterm.d.ts +34 -0
- package/dist/core/nonterm.js +610 -0
- package/dist/core/q.d.ts +17 -0
- package/dist/core/q.js +52 -0
- package/dist/core/rationals.d.ts +112 -0
- package/dist/core/rationals.js +281 -0
- package/dist/core/relation.d.ts +28 -0
- package/dist/core/relation.js +483 -0
- package/dist/core/solver.d.ts +5 -2
- package/dist/core/solver.js +65 -20
- package/dist/core/transfer.d.ts +3 -3
- package/dist/core/transfer.js +69 -42
- package/dist/core/xstate.d.ts +6 -0
- package/dist/core/xstate.js +70 -12
- package/dist/kernel/cdcl.d.ts +13 -0
- package/dist/kernel/cdcl.js +307 -236
- package/dist/kernel/kernel.d.ts +106 -0
- package/dist/kernel/kernel.js +342 -0
- package/dist/kernel/prove.js +14 -3
- package/dist/kernel/qprove.d.ts +18 -0
- package/dist/kernel/qprove.js +157 -0
- package/dist/kernel/reader.d.ts +14 -0
- package/dist/kernel/reader.js +102 -14
- package/dist/kernel/simplex.d.ts +4 -0
- package/dist/kernel/simplex.js +38 -11
- package/dist/lean-kernel/emit.d.ts +46 -1
- package/dist/lean-kernel/emit.js +125 -16
- package/dist/lean-kernel/library.js +4 -1
- package/dist/lean-kernel/qlean.d.ts +26 -0
- package/dist/lean-kernel/qlean.js +105 -0
- package/package.json +16 -3
package/dist/lean-kernel/emit.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { atMost, n, not, pointWrite } from "../core/machine.js";
|
|
2
2
|
import { add, k, scale, sub } from "../core/solver.js";
|
|
3
|
-
import { boundOf, canon, factorsOf, isCell, isMonomial, columnTerm, stateName, termColumn, historyMachine, foldObligations, leafConstraints, loopLiveness, loopMachine, linear, livenessHelpful, livenessParts, livenessRanks, loopObligations, trueC, obligations, progressObligations, stepLawObligations, substC, witnessesOf, withProducts } from "../kernel/kernel.js";
|
|
3
|
+
import { boundOf, check, checkRecur, recurGoal, canon, factorsOf, isCell, isMonomial, columnTerm, stateName, termColumn, historyMachine, foldObligations, kInductionStart, kInductionSteps, leafConstraints, loopLiveness, loopMachine, linear, livenessHelpful, livenessParts, livenessRanks, loopObligations, trueC, obligations, progressObligations, stepLawObligations, substC, witnessesOf, withProducts } from "../kernel/kernel.js";
|
|
4
4
|
import { grow, minimal, proveBuilt, proveLaws, proveStepLaws, withDeadline } from "../kernel/prove.js";
|
|
5
5
|
import { refinement, refinementSides } from "../core/compose.js";
|
|
6
6
|
import { leanSurface, leanTerms } from "./lean-terms.js";
|
|
7
7
|
import { descentGoal, mainGoal, premiseGoal } from "../kernel/cyclic.js";
|
|
8
8
|
import { allowNode, certMs, closingInsts, reqTS, withWitness, foldNodes, certMode, quietly, uncoveredWhy, hasQuantified, kWhens, machineNodes, proveCyclic, routeOf, searchedStepNodes, skMachine, stepLawNodes, tBack, tSub } from "../core/cyclic.js";
|
|
9
9
|
import { leanLibrary } from "./library.js";
|
|
10
|
+
import { proveKInduction } from "../core/kind.js";
|
|
10
11
|
export { leanLibrary };
|
|
11
12
|
// --- to Lean ------------------------------------------------------------------------------------------------------------
|
|
12
13
|
const varsOf = (c) => [...JSON.stringify(c).matchAll(/"op":"var","name":"([^"]+)"/g)].map(m => m[1]);
|
|
@@ -226,7 +227,14 @@ export function encode(ex, tamper = false, dropStep = true, globalVars, globalMa
|
|
|
226
227
|
return `.combine ${s.a} ${s.b} ${int(s.ma)} ${int(s.mb)}`;
|
|
227
228
|
}
|
|
228
229
|
const from = replay[s.of];
|
|
229
|
-
|
|
230
|
+
// A cut's quotient is the row it divides (Cert.lean's cutOk: coefs = g · q over the integers). A tree read against a
|
|
231
|
+
// goal it doesn't refute can cut a row g doesn't divide: that is no derivation of this goal, and a quotient written
|
|
232
|
+
// as a fraction isn't Lean (Int has no fractional literal), so it is refused here, never printed.
|
|
233
|
+
const q = Object.fromEntries(Object.entries(from).filter(([key]) => key !== '1').map(([key, v]) => {
|
|
234
|
+
if (!Number.isInteger(v / s.g))
|
|
235
|
+
throw new Error(`${ex.name}: a cut by ${s.g} of a row it doesn't divide (${key}: ${v}); the tree doesn't refute this goal`);
|
|
236
|
+
return [key, v / s.g];
|
|
237
|
+
}));
|
|
230
238
|
const cc = Math.ceil((from['1'] ?? 0) / s.g);
|
|
231
239
|
replay.push({ ...q, 1: cc });
|
|
232
240
|
return `.cut ${s.of} ${int(s.g)} ${sparse(dense(q))} ${int(cc)}`;
|
|
@@ -336,6 +344,61 @@ export function loopToLean(id, l, laws, rank, tamper) {
|
|
|
336
344
|
loopObligations(l, laws, rank);
|
|
337
345
|
return smachineToLean(id, loopMachine(l), laws, { liveness: [loopLiveness(l, rank)], loop: { loop: l, ...(tamper ? { tamper } : {}) } });
|
|
338
346
|
}
|
|
347
|
+
// A loop with a run that never ends, through Kern.never_ends_of (NonTerm.lean): the loop, the recurrent set and its
|
|
348
|
+
// witness, the start and the stem as values, and the closure goal's table and tree; Lean evaluates the stem and builds
|
|
349
|
+
// the goal from the loop and the set (the certificate names no hypothesis, so the tree is read against Lean's goal).
|
|
350
|
+
// Each tampered certificate's check is computed to false.
|
|
351
|
+
export function neverEndsToLean(id, l, r, tampered = []) {
|
|
352
|
+
if (!checkRecur(l, r))
|
|
353
|
+
throw new Error(`${id}: the certificate does not check`);
|
|
354
|
+
const { vars, loop, recur } = recurLean(id, l, r);
|
|
355
|
+
return `-- ${l.name}: a run that never ends (variables ${vars.map((v2, j) => `${j} ${v2}`).join(', ')})
|
|
356
|
+
def ${id}_loop : Loop := ${loop}
|
|
357
|
+
def ${id}_recur : Recur := ${recur(r)}
|
|
358
|
+
/-- ${l.name} never ends: for some params meeting its precondition, a run of turns from the start goes on forever. -/
|
|
359
|
+
theorem ${id}_never_ends : NeverEnds ${id}_loop :=
|
|
360
|
+
never_ends_of ${id}_loop ${id}_recur (by ${checkBy})${tampered.map((t, j) => `
|
|
361
|
+
-- TAMPERED: ${t.what}. Lean computes the check to false.
|
|
362
|
+
def ${id}_tampered${j} : Recur := ${recur(t.recur)}
|
|
363
|
+
example : checkRecur ${id}_loop ${id}_tampered${j} = false := by ${checkBy}`).join('')}`;
|
|
364
|
+
}
|
|
365
|
+
// The loop and a certificate as NonTerm.lean's Loop and Recur (the domain every variable; a certificate whose tree
|
|
366
|
+
// doesn't refute its own goal carries `fallback`'s table and tree, which refutes `fallback`'s). lean-kernel/conformance.ts prints its cases with it.
|
|
367
|
+
export function recurLean(id, l, fallback) {
|
|
368
|
+
const vars = [...l.params, ...l.inputs, ...Object.keys(l.state)];
|
|
369
|
+
const { e, c } = leanTerms(vars, [], id);
|
|
370
|
+
const ix = (name) => { const j = vars.indexOf(name); if (j < 0)
|
|
371
|
+
throw new Error(`${id}: no variable for ${name}`); return j; };
|
|
372
|
+
const loop = `⟨${list(l.inputs.map(name => String(ix(name))))},
|
|
373
|
+
${list(Object.entries(l.state).map(([name, e2]) => `(${ix(name)}, ${e(e2)})`))},
|
|
374
|
+
${list(Object.entries(l.body).map(([name, e2]) => `(${ix(name)}, ${e(e2)})`))},
|
|
375
|
+
${c(l.while)},
|
|
376
|
+
${l.pre ? c(l.pre) : TRUE},
|
|
377
|
+
${l.assume ? c(l.assume) : TRUE}⟩`;
|
|
378
|
+
const vals = (o) => list(Object.entries(o).map(([name, v]) => `(${ix(name)}, ${v})`));
|
|
379
|
+
const recur = (rr) => {
|
|
380
|
+
const enc = (g) => encode({ name: `${id}: ${l.name} never ends`, goal: recurGoal(l, g), tree: g.tree }, false, true, vars, []);
|
|
381
|
+
// The tree is written against the goal it refutes: the certificate's own where kernel.ts's check accepts it there,
|
|
382
|
+
// else `fallback`'s (which must check), and Lean reads it against the goal it builds from `rr` either way. So every
|
|
383
|
+
// number written is one kernel.ts's check replayed: integers, every cut dividing its row.
|
|
384
|
+
const fits = (g) => { try {
|
|
385
|
+
return check(recurGoal(l, g), g.tree);
|
|
386
|
+
}
|
|
387
|
+
catch {
|
|
388
|
+
return false;
|
|
389
|
+
} };
|
|
390
|
+
// (neither refuting its goal, as a forged certificate's: a leaf with no step, the tree that refutes nothing)
|
|
391
|
+
const by = fits(rr) ? rr : fits(fallback) ? fallback : undefined;
|
|
392
|
+
const coded = by ? enc(by) : { tab: '[]', tree: '.leafAt [] [] [] []' };
|
|
393
|
+
return `⟨${list(vars.map((_, j) => String(j)))},
|
|
394
|
+
${vals(rr.start)},
|
|
395
|
+
${list(rr.stem.map(vals))},
|
|
396
|
+
${c(rr.set)},
|
|
397
|
+
${list(Object.entries(rr.wit).map(([name, t]) => `(${ix(name)}, ${e(t)})`))},
|
|
398
|
+
(${coded.tab}, [], ${coded.tree})⟩`;
|
|
399
|
+
};
|
|
400
|
+
return { vars, loop, recur };
|
|
401
|
+
}
|
|
339
402
|
// Folds through Kern.fold_sound: Lean builds the leaf and node goals; the trees are the kernel's.
|
|
340
403
|
export function foldToLean(id, f, laws, extra = '') {
|
|
341
404
|
const st = Object.keys(f.leaf);
|
|
@@ -756,15 +819,13 @@ export function smachineToLean(id, given, laws, opts = {}) {
|
|
|
756
819
|
const m = hplain ? hplain.machine : given;
|
|
757
820
|
const claims = [];
|
|
758
821
|
const claimSteps = () => claims.flatMap(cl => cl.steps);
|
|
759
|
-
//
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
return `-- Step law${kk > 1 ? ` over ${kk} steps` : ''}: ${sl.name}
|
|
767
|
-
def ${id}_step${j} : SKStep := ⟨⟨${list(Array.from({ length: kk }, (_, s2) => (whens[s2] ? c(inline(whens[s2])) : TRUE)))},
|
|
822
|
+
// A step law's SKStep literal: its whens, then, the names its later requests and states are read by, its proof.
|
|
823
|
+
const skLit = (h, sl) => {
|
|
824
|
+
const { pr, inst } = h.step(sl), kk = sl.steps ?? 1;
|
|
825
|
+
const whens = sl.when === undefined ? [] : Array.isArray(sl.when) ? sl.when : [sl.when];
|
|
826
|
+
const ren = Array.from({ length: kk }, (_, s2) => (s2 === 0 ? '[]' : list(ext.map(v => `(${ix(v)}, ${ix(`${v}@${s2 + 1}`)})`))));
|
|
827
|
+
const mren = Array.from({ length: kk }, (_, s2) => (s2 === 0 ? '[]' : list(carried.map(mp => `(${mx(mp)}, ${mx(`${mp}@${s2 + 1}`)})`))));
|
|
828
|
+
return `⟨⟨${list(Array.from({ length: kk }, (_, s2) => (whens[s2] ? c(inline(whens[s2])) : TRUE)))},
|
|
768
829
|
${c(inline(sl.then))},
|
|
769
830
|
${list(ren)},
|
|
770
831
|
${list(Object.keys(m.state).map(s2 => `(${ix(s2)}, ${ix(`${s2}'`)})`))},
|
|
@@ -777,10 +838,39 @@ def ${id}_step${j} : SKStep := ⟨⟨${list(Array.from({ length: kk }, (_, s2) =
|
|
|
777
838
|
${list(pinsts(inst))},
|
|
778
839
|
${list(pfinsts(inst))},
|
|
779
840
|
${pr.hyps},
|
|
780
|
-
${list(Array.from({ length: kk - 1 }, (_, s2) => list(Object.keys(m.state).map(n2 => `(${ix(n2)}, ${ix(stateName(n2, s2 + 1))})`))))}
|
|
841
|
+
${list(Array.from({ length: kk - 1 }, (_, s2) => list(Object.keys(m.state).map(n2 => `(${ix(n2)}, ${ix(stateName(n2, s2 + 1))})`))))}⟩`;
|
|
842
|
+
};
|
|
843
|
+
// The machine's own step laws, one step or k (Sets.lean's skstep_sound).
|
|
844
|
+
if (!rf)
|
|
845
|
+
stepLaws.forEach((sl, j) => claims.push({ steps: [sl], allows: [], render: h => `-- Step law${(sl.steps ?? 1) > 1 ? ` over ${sl.steps} steps` : ''}: ${sl.name}
|
|
846
|
+
def ${id}_step${j} : SKStep := ${skLit(h, sl)}
|
|
781
847
|
theorem ${id}_step${j}_holds : SKStepHolds ${id}_machine ${id}_step${j} :=
|
|
782
|
-
skstep_sound ${id}_machine ${id}_proof ${id}_step${j} ${id}_check (by ${checkBy})
|
|
783
|
-
|
|
848
|
+
skstep_sound ${id}_machine ${id}_proof ${id}_step${j} ${id}_check (by ${checkBy})` }));
|
|
849
|
+
// k-induction (KInd.lean's kind_sound): Lean builds each base goal's and the step's whens and then from the law; the
|
|
850
|
+
// trees, instances and names are the k-step laws' kernel.ts made (kInductionSteps), the start goal's tree its own.
|
|
851
|
+
const kd = opts.kind;
|
|
852
|
+
if (kd) {
|
|
853
|
+
const kSteps = kInductionSteps(m, kd.kl);
|
|
854
|
+
claims.push({ steps: kSteps, allows: [], render: h => {
|
|
855
|
+
const st = enc(kd.start.goal, kd.start.tree), kid = `${id}_kind`, k = kd.kl.k, base = kSteps.slice(0, -1);
|
|
856
|
+
const lit = (law, k2, bases) => `⟨${c(law)}, ${k2},
|
|
857
|
+
${list(Object.keys(m.state).map(s2 => `(${ix(s2)}, ${ix(`${s2}'`)})`))},
|
|
858
|
+
${list(Object.keys(m.maps ?? {}).map(mp => `(${mx(mp)}, ${mx(`${mp}'`)})`))},
|
|
859
|
+
${list(finsts(kd.start.inst))},
|
|
860
|
+
${list(pfinsts(kd.start.inst))},
|
|
861
|
+
(${st.tab}, ${st.hyps}, ${st.tree}),
|
|
862
|
+
${list(bases.map(sl => skLit(h, sl)))},
|
|
863
|
+
${skLit(h, kSteps.at(-1))}⟩`;
|
|
864
|
+
return `-- k-induction, k = ${k}: ${kd.kl.law.name}
|
|
865
|
+
def ${kid} : KInd := ${lit(kd.kl.law.holds, k, base)}
|
|
866
|
+
theorem ${kid}_check : checkKInd ${id}_machine ${id}_proof ${kid} = true := by ${checkBy}
|
|
867
|
+
/-- ${kd.kl.law.name}, by k-induction (k = ${k}): it holds in every reachable state. -/
|
|
868
|
+
theorem ${kid}_holds : ∀ ρ M, SReach ${id}_machine ρ M → evalC ρ M ${kid}.law = true :=
|
|
869
|
+
kind_sound ${id}_machine ${id}_proof ${kid} ${id}_check ${kid}_check${(kd.tampers ?? []).map(t => `
|
|
870
|
+
-- TAMPERED: ${t.what}. Lean computes the check to ${t.expect}, kernel.ts's answer.
|
|
871
|
+
example : checkKInd ${id}_machine ${id}_proof ${lit(t.law ?? kd.kl.law.holds, t.k, t.base.map(j => base[j]))} = ${t.expect} := by ${checkBy}`).join('')}`;
|
|
872
|
+
} });
|
|
873
|
+
}
|
|
784
874
|
// A refinement (Refine.lean's SRefined): its step law, that the spec stutters or allows the request it is sent; srefines
|
|
785
875
|
// says what the whole means.
|
|
786
876
|
if (rf)
|
|
@@ -920,7 +1010,7 @@ theorem ${id}_orig_laws : ∀ ρ M, SReach ${id}_ghosted.orig ρ M → ∀ e ∈
|
|
|
920
1010
|
})]));
|
|
921
1011
|
const allowGoals = [...allowed.values()].flatMap(a => (a ? [a.out.goal] : []));
|
|
922
1012
|
const named = machineNames(m, laws, allSteps, stepLaws, { ...opts, ...(hm ? { record: hm.history.record } : {}) });
|
|
923
|
-
const vars = [...new Set([...named.vars, ...[...goalsL, ...goalsS, ...allowGoals, ...(hplain?.goals ?? [])].flatMap(g => g.hyps.flatMap(varsOf))])];
|
|
1013
|
+
const vars = [...new Set([...named.vars, ...[...goalsL, ...goalsS, ...allowGoals, ...(hplain?.goals ?? []), ...(opts.kind ? [opts.kind.start.goal] : [])].flatMap(g => g.hyps.flatMap(varsOf))])];
|
|
924
1014
|
const mapNames = [...new Set([...named.maps, ...[...JSON.stringify([...goalsL, ...goalsS, ...allowGoals]).matchAll(/"op":"get","map":"([^"]+)"/g)].map(x2 => x2[1])])];
|
|
925
1015
|
const enc = (g, tree) => encode({ name: `${id}: ${g.name}`, goal: g, tree }, false, true, vars, mapNames);
|
|
926
1016
|
const { e, c } = leanTerms(vars, mapNames, id);
|
|
@@ -1052,6 +1142,8 @@ function proveStepLawsOnce(m, laws, stepLaws) {
|
|
|
1052
1142
|
usualMade.set(key, r);
|
|
1053
1143
|
return r;
|
|
1054
1144
|
}
|
|
1145
|
+
// A proof made elsewhere (core/kind.ts's k-induction search), as the one the export reads for these step laws.
|
|
1146
|
+
export const seedStepProof = (m, laws, stepLaws, r) => { usualMade.set(JSON.stringify([m, laws, stepLaws]), r); };
|
|
1055
1147
|
const envOf = () => globalThis.process?.env;
|
|
1056
1148
|
export const cyclicCerts = certMode;
|
|
1057
1149
|
let certsOn = false, cycTexts = 0;
|
|
@@ -1729,12 +1821,27 @@ function toLeanWith(items, opts) {
|
|
|
1729
1821
|
parts.push(`-- ${item.id}\n${cyc && 'text' in cyc ? cyc.text : loopToLean(id, item.loop, item.laws ?? [], item.rank)}`);
|
|
1730
1822
|
theorems.push(`${id}_halts`);
|
|
1731
1823
|
}
|
|
1824
|
+
else if ('neverEnds' in item) {
|
|
1825
|
+
parts.push(`-- ${item.id}\n${neverEndsToLean(id, item.neverEnds, item.recur, item.tampered ?? [])}`);
|
|
1826
|
+
theorems.push(`${id}_never_ends`);
|
|
1827
|
+
}
|
|
1732
1828
|
else if ('cyclic' in item) {
|
|
1733
1829
|
parts.push(`-- ${item.id}\n${cyclicToLean(id, item.cyclic, item.tampered ?? [], item.after, item.bridge, item.recur, item.fold)}`);
|
|
1734
1830
|
theorems.push(`${id}_sound`, ...(item.bridge?.laws ?? item.fold?.laws ?? []).map((_, j) => `${id}_law${j}_holds`), ...(item.recur ? [`${id}_values`] : []), ...(item.recur ? [...item.recur.lemmas.map((_, j) => `${id}_lemma${j}`), ...item.recur.between.map((_, j) => `${id}_between${j}`)] : []),
|
|
1735
1831
|
// A datatype law's theorem is in a namespace of the item's (its datatypes and functions are named as declared).
|
|
1736
1832
|
...(item.after ? (ts => (item.data ? ts.slice(-1).map(t => `${id}.${t}`) : ts))([...item.after(() => 0, () => 0).matchAll(/^theorem (\S+)/gm)].map(x2 => x2[1])) : []));
|
|
1737
1833
|
}
|
|
1834
|
+
else if ('kInduction' in item) {
|
|
1835
|
+
const { machine: m, laws, law, k, ms } = item.kInduction;
|
|
1836
|
+
const f = proveKInduction(m, laws, law, { ms: ms ?? 30_000, from: k ?? 1, to: k ?? 64 });
|
|
1837
|
+
if (!f.proven || !f.checked || !f.proof || !f.kl)
|
|
1838
|
+
throw new Error(`${item.id}: not proven by k-induction (${f.why ?? ''})`);
|
|
1839
|
+
const plain = m.history ? historyMachine(m).machine : m;
|
|
1840
|
+
seedStepProof(plain, f.laws, kInductionSteps(m, f.kl), { proven: true, checked: true, nodes: 0, leaves: 0, proof: f.proof });
|
|
1841
|
+
const start = kInductionStart(m, f.kl, {});
|
|
1842
|
+
parts.push(`-- ${item.id}\n${recurDefs(plain)}${smachineToLean(id, plain, f.laws, { kind: { kl: f.kl, start: { goal: start, tree: f.proof.trees[start.name], inst: {} } } })}`);
|
|
1843
|
+
theorems.push(`${id}_laws`, `${id}_kind_holds`);
|
|
1844
|
+
}
|
|
1738
1845
|
else if ('fold' in item) {
|
|
1739
1846
|
const cyc = certsOn ? cycFoldToLean(id, item.fold, item.laws) : undefined;
|
|
1740
1847
|
if (cyc && 'text' in cyc)
|
|
@@ -1755,7 +1862,7 @@ function toLeanWith(items, opts) {
|
|
|
1755
1862
|
}
|
|
1756
1863
|
// The file the items need: Live.lean for a liveness or a loop, Sets.lean (which imports Steps.lean) for any machine.
|
|
1757
1864
|
return `import History
|
|
1758
|
-
${cycTexts ? 'import BridgeRules\n' : ''}${items.some(item => 'cyclic' in item) ? (items.some(item => 'cyclic' in item && (item.bridge || item.recur || item.fold)) ? 'import Bridge\n' : 'import Cyclic\n') : ''}${items.some(item => 'cyclic' in item && item.data) ? 'import Data\n' : ''}import ${items.some(item => 'refinement' in item) ? 'Refine' : items.some(item => 'machine' in item && (item.ghosts?.length || item.laws.some(l => l.some?.length))) ? 'Ghost' : items.some(item => ('machine' in item && item.liveness?.length) || 'loop' in item) ? 'Live' : items.some(item => 'machine' in item) ? 'Sets' : 'Steps'}
|
|
1865
|
+
${items.some(item => 'neverEnds' in item) ? 'import NonTerm\n' : ''}${items.some(item => 'kInduction' in item) ? 'import KInd\n' : ''}${cycTexts ? 'import BridgeRules\n' : ''}${items.some(item => 'cyclic' in item) ? (items.some(item => 'cyclic' in item && (item.bridge || item.recur || item.fold)) ? 'import Bridge\n' : 'import Cyclic\n') : ''}${items.some(item => 'cyclic' in item && item.data) ? 'import Data\n' : ''}import ${items.some(item => 'refinement' in item) ? 'Refine' : items.some(item => 'machine' in item && (item.ghosts?.length || item.laws.some(l => l.some?.length))) ? 'Ghost' : items.some(item => ('machine' in item && item.liveness?.length) || 'loop' in item) ? 'Live' : items.some(item => 'machine' in item) ? 'Sets' : 'Steps'}
|
|
1759
1866
|
open Kern Cert
|
|
1760
1867
|
set_option maxRecDepth 100000
|
|
1761
1868
|
set_option maxHeartbeats 0
|
|
@@ -1768,6 +1875,8 @@ ${parts.join('\n\n')}
|
|
|
1768
1875
|
${theorems.map(t => `#print axioms ${t}`).join('\n')}
|
|
1769
1876
|
`;
|
|
1770
1877
|
}
|
|
1878
|
+
// Rules over the rationals (core/rationals.ts), each through Rationals.lean's Q.machine_sound: lean-kernel/qlean.ts.
|
|
1879
|
+
export { rationalsToLean } from "./qlean.js";
|
|
1771
1880
|
// A Lake project that builds the twin and the file: `lake build` in its folder checks every proof.
|
|
1772
1881
|
export function leanProject(file, opts = {}) {
|
|
1773
1882
|
const name = opts.name ?? 'Proofs';
|