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.
Files changed (60) hide show
  1. package/README.md +27 -2
  2. package/dist/core/bmc.d.ts +49 -0
  3. package/dist/core/bmc.js +509 -0
  4. package/dist/core/check.d.ts +1 -1
  5. package/dist/core/check.js +19 -6
  6. package/dist/core/cycles.d.ts +38 -0
  7. package/dist/core/cycles.js +531 -43
  8. package/dist/core/data.d.ts +25 -1
  9. package/dist/core/data.js +984 -215
  10. package/dist/core/discover.js +8 -3
  11. package/dist/core/dsl.d.ts +17 -3
  12. package/dist/core/dsl.js +81 -15
  13. package/dist/core/extract-check.d.ts +77 -0
  14. package/dist/core/extract-check.js +785 -0
  15. package/dist/core/extract-ir.d.ts +139 -0
  16. package/dist/core/extract-ir.js +198 -0
  17. package/dist/core/extract-print.d.ts +30 -0
  18. package/dist/core/extract-print.js +426 -0
  19. package/dist/core/extract-read.d.ts +298 -0
  20. package/dist/core/extract-read.js +1298 -0
  21. package/dist/core/extract-shapes.d.ts +13 -0
  22. package/dist/core/extract-shapes.js +993 -0
  23. package/dist/core/extract-xstate.d.ts +34 -0
  24. package/dist/core/extract-xstate.js +320 -0
  25. package/dist/core/extract.d.ts +31 -0
  26. package/dist/core/extract.js +249 -0
  27. package/dist/core/infer.js +518 -5
  28. package/dist/core/kind.d.ts +30 -0
  29. package/dist/core/kind.js +81 -0
  30. package/dist/core/nonterm.d.ts +34 -0
  31. package/dist/core/nonterm.js +610 -0
  32. package/dist/core/q.d.ts +17 -0
  33. package/dist/core/q.js +52 -0
  34. package/dist/core/rationals.d.ts +112 -0
  35. package/dist/core/rationals.js +281 -0
  36. package/dist/core/relation.d.ts +28 -0
  37. package/dist/core/relation.js +483 -0
  38. package/dist/core/solver.d.ts +5 -2
  39. package/dist/core/solver.js +65 -20
  40. package/dist/core/transfer.d.ts +3 -3
  41. package/dist/core/transfer.js +69 -42
  42. package/dist/core/xstate.d.ts +6 -0
  43. package/dist/core/xstate.js +70 -12
  44. package/dist/kernel/cdcl.d.ts +13 -0
  45. package/dist/kernel/cdcl.js +307 -236
  46. package/dist/kernel/kernel.d.ts +106 -0
  47. package/dist/kernel/kernel.js +342 -0
  48. package/dist/kernel/prove.js +14 -3
  49. package/dist/kernel/qprove.d.ts +18 -0
  50. package/dist/kernel/qprove.js +157 -0
  51. package/dist/kernel/reader.d.ts +14 -0
  52. package/dist/kernel/reader.js +102 -14
  53. package/dist/kernel/simplex.d.ts +4 -0
  54. package/dist/kernel/simplex.js +38 -11
  55. package/dist/lean-kernel/emit.d.ts +46 -1
  56. package/dist/lean-kernel/emit.js +125 -16
  57. package/dist/lean-kernel/library.js +4 -1
  58. package/dist/lean-kernel/qlean.d.ts +26 -0
  59. package/dist/lean-kernel/qlean.js +105 -0
  60. package/package.json +16 -3
@@ -0,0 +1,157 @@
1
+ // Untrusted, like prove.ts: the tree search for goals over the rationals (kernel.ts's QGoal). A node reads its rows
2
+ // as the kernel does (qLeafRows); the incremental simplex (simplex.ts, over the rationals) picks a conflict's rows, the
3
+ // elimination (solver.ts, no cut) refutes them exactly, and that derivation is the leaf. A node it can't refute is
4
+ // split on an open atom: a choice a term leaves open (min, max, if), or a comparison a hypothesis needs decided before
5
+ // it gives rows (a disjunction, ≠). With no atom open, every hypothesis' rows say all it says under the path, so the
6
+ // elimination decides the node: refuted, or a model, exact (a counterexample to the goal, checked by evaluation).
7
+ // Linear arithmetic over ℚ is decidable and this search is complete for it: every split is on a finite set of atoms,
8
+ // and each leaf is decided.
9
+ import { solve, work } from "../core/solver.js";
10
+ import { canon, qdec, qdif, qLeafRows, qLin, qlinear, qtruth } from "./kernel.js";
11
+ import { Simplex } from "./simplex.js";
12
+ // The open atoms of a term: its undecided choices (and those inside), and an if's condition's while it is open.
13
+ function openE(e, path, out) {
14
+ switch (e.op) {
15
+ case 'var':
16
+ case 'const': return;
17
+ case 'mul': return openE(e.a, path, out);
18
+ case 'add':
19
+ case 'sub':
20
+ openE(e.a, path, out);
21
+ openE(e.b, path, out);
22
+ return;
23
+ case 'min':
24
+ case 'max': {
25
+ openE(e.a, path, out);
26
+ openE(e.b, path, out);
27
+ const a = qlinear(e.a, path), b = qlinear(e.b, path);
28
+ if (a && b)
29
+ push(qdif(a, b), path, out);
30
+ return;
31
+ }
32
+ case 'if': {
33
+ const t = qtruth(e.c, path);
34
+ if (t === undefined)
35
+ openC(e.c, path, out);
36
+ else
37
+ openE(t ? e.then : e.else, path, out);
38
+ return;
39
+ }
40
+ }
41
+ }
42
+ const push = (row, path, out) => { if (qdec(path, row) === undefined) {
43
+ const lin = qLin(row);
44
+ if (lin)
45
+ out.push(lin);
46
+ } };
47
+ const forms = (c, path) => { const a = qlinear(c.a, path), b = qlinear(c.b, path); return a && b ? [a, b] : undefined; };
48
+ // The atoms that decide a condition's truth.
49
+ function openC(c, path, out) {
50
+ switch (c.op) {
51
+ case 'not': return openC(c.x, path, out);
52
+ case 'and':
53
+ case 'or':
54
+ openC(c.a, path, out);
55
+ openC(c.b, path, out);
56
+ return;
57
+ case '<=':
58
+ case '<':
59
+ case '=': {
60
+ openE(c.a, path, out);
61
+ openE(c.b, path, out);
62
+ const f = forms(c, path);
63
+ if (!f)
64
+ return;
65
+ if (c.op !== '<')
66
+ push(qdif(f[0], f[1]), path, out);
67
+ if (c.op !== '<=')
68
+ push(qdif(f[1], f[0]), path, out);
69
+ }
70
+ }
71
+ }
72
+ // The atoms a hypothesis needs decided before its rows (kernel.ts's qfacts) say all it says: none for a comparison
73
+ // whose terms are decided, both parts of a conjunction, and for a disjunction the atoms that decide its parts.
74
+ function openH(c, path, out, pos = true) {
75
+ switch (c.op) {
76
+ case 'not': return openH(c.x, path, out, !pos);
77
+ case 'and':
78
+ case 'or': {
79
+ if ((c.op === 'and') === pos) {
80
+ openH(c.a, path, out, pos);
81
+ openH(c.b, path, out, pos);
82
+ return;
83
+ }
84
+ if (qtruth(c.a, path) === !pos)
85
+ return openH(c.b, path, out, pos);
86
+ if (qtruth(c.b, path) === !pos)
87
+ return openH(c.a, path, out, pos);
88
+ openC(c.a, path, out);
89
+ openC(c.b, path, out);
90
+ return;
91
+ }
92
+ case '<=':
93
+ case '<':
94
+ case '=': {
95
+ const f = forms(c, path);
96
+ if (!f) {
97
+ openE(c.a, path, out);
98
+ openE(c.b, path, out);
99
+ return;
100
+ }
101
+ if (c.op === '=' && !pos && qdec(path, qdif(f[0], f[1])) !== true && qdec(path, qdif(f[1], f[0])) !== true)
102
+ push(qdif(f[0], f[1]), path, out);
103
+ }
104
+ }
105
+ }
106
+ export function openQ(goal, path) {
107
+ const out = [], last = goal.hyps.length - 1;
108
+ if (last >= 0)
109
+ openH(goal.hyps[last], path, out);
110
+ for (let i = 0; i < last; i++)
111
+ openH(goal.hyps[i], path, out);
112
+ const seen = new Set();
113
+ return out.filter(lin => { const key = canon(lin); return !seen.has(key) && (seen.add(key), true); });
114
+ }
115
+ // A derivation of the rows, by the simplex's conflict (its rows refuted exactly) or else the elimination over all.
116
+ function refute(rows, sx, whole) {
117
+ let lp = sx.load(rows);
118
+ if (lp.kind === 'sat')
119
+ lp = sx.check();
120
+ if (lp.kind === 'conflict') {
121
+ const support = lp.rows.sort((x, y) => x - y), out = solve(support.map(i => rows[i]), 20_000, false);
122
+ if (out.kind === 'refuted')
123
+ return { steps: out.steps.map(s => (s.kind === 'input' ? { ...s, index: support[s.index] } : s)) };
124
+ }
125
+ if (!whole && lp.kind === 'sat')
126
+ return {};
127
+ const verdict = solve(rows, 20_000, false);
128
+ return verdict.kind === 'refuted' ? { steps: verdict.steps } : { verdict };
129
+ }
130
+ export function growQ(goal, opts = {}) {
131
+ const until = opts.until ?? performance.now() + 20_000, maxNodes = opts.maxNodes ?? 100_000;
132
+ let nodes = 0;
133
+ const sx = new Simplex(false);
134
+ const go = (path) => {
135
+ if (++nodes > maxNodes || performance.now() > until)
136
+ return { stuck: 'unknown', path, why: nodes > maxNodes ? 'nodes' : 'time' };
137
+ const rows = qLeafRows(goal, path);
138
+ work.n += 1 + rows.length;
139
+ const open = openQ(goal, path);
140
+ const r = refute(rows, sx, open.length === 0);
141
+ if (r.steps)
142
+ return { tree: { leaf: r.steps }, nodes };
143
+ if (!open.length) {
144
+ const v = r.verdict;
145
+ return v?.kind === 'sat' ? { stuck: 'sat', witness: v.witness, ...(v.rational ? { rational: v.rational } : {}), path } : { stuck: 'unknown', path, why: 'no split' };
146
+ }
147
+ const lin = open[0], key = canon(lin);
148
+ const yes = go(new Map(path).set(key, { lin, holds: true }));
149
+ if (!('tree' in yes))
150
+ return yes;
151
+ const no = go(new Map(path).set(key, { lin, holds: false }));
152
+ if (!('tree' in no))
153
+ return no;
154
+ return { tree: { split: lin, yes: yes.tree, no: no.tree }, nodes };
155
+ };
156
+ return go(new Map());
157
+ }
@@ -51,8 +51,20 @@ export declare class Reader {
51
51
  private ls;
52
52
  private ts;
53
53
  private fs;
54
+ private os;
54
55
  constructor(goal: Goal, trail: Trail);
55
56
  begin(): void;
57
+ private up;
58
+ private byAtom;
59
+ private clean;
60
+ private frame;
61
+ private factKeys;
62
+ private openKeys;
63
+ private lastUp;
64
+ private read;
65
+ private readAtom;
66
+ private within;
67
+ touch(name: string): void;
56
68
  private ok;
57
69
  private kept;
58
70
  private units;
@@ -61,8 +73,10 @@ export declare class Reader {
61
73
  t: boolean | undefined;
62
74
  };
63
75
  linear(e: E): LV;
76
+ private linear0;
64
77
  private atoms;
65
78
  truth(c: C): TV;
79
+ private truth0;
66
80
  private factsOf;
67
81
  facts(i: number): FV;
68
82
  termRows(name: string): Row[];
@@ -36,6 +36,8 @@ function same(site, owner, a, b, c, make) {
36
36
  m.set(owner, { a, b, c, out });
37
37
  return out;
38
38
  }
39
+ // GDP_READER_CLEAN=0: values with an open read found again at every node, as before (for comparing).
40
+ const keepClean = globalThis.process?.env?.GDP_READER_CLEAN !== '0';
39
41
  export class Reader {
40
42
  goal;
41
43
  trail;
@@ -45,16 +47,71 @@ export class Reader {
45
47
  ls = new Map();
46
48
  ts = new Map();
47
49
  fs = [];
50
+ os = [];
48
51
  constructor(goal, trail) {
49
52
  this.goal = goal;
50
53
  this.trail = trail;
51
54
  }
52
- // A new node: values with an open read are found again.
55
+ // A new node: values with an open read are found again, unless nothing they read has changed.
53
56
  begin() { this.node++; }
54
- ok(x) {
55
- if (x.node === this.node)
57
+ // The reads: a value's key (its term, condition, or a hypothesis' facts or open atoms) → the keys of the values that
58
+ // read it; an atom's name → the keys of the values that read it. A clean key's value stands.
59
+ up = new Map();
60
+ byAtom = new Map();
61
+ clean = new Set();
62
+ frame;
63
+ factKeys = [];
64
+ openKeys = [];
65
+ lastUp = new WeakMap();
66
+ read(key) {
67
+ if (!this.frame || this.lastUp.get(key) === this.frame)
68
+ return;
69
+ this.lastUp.set(key, this.frame);
70
+ let s = this.up.get(key);
71
+ if (!s)
72
+ this.up.set(key, (s = new Set()));
73
+ s.add(this.frame);
74
+ }
75
+ readAtom(name) {
76
+ if (!this.frame)
77
+ return;
78
+ let s = this.byAtom.get(name);
79
+ if (!s)
80
+ this.byAtom.set(name, (s = new Set()));
81
+ s.add(this.frame);
82
+ }
83
+ within(key, f) {
84
+ const was = this.frame;
85
+ this.frame = key;
86
+ try {
87
+ return f();
88
+ }
89
+ finally {
90
+ this.frame = was;
91
+ }
92
+ }
93
+ // The trail changed at this atom (decided, or taken back): every value that read it, and every reader of those, all
94
+ // the way up (a value kept as final reads below it values that are not clean).
95
+ touch(name) {
96
+ const todo = [...(this.byAtom.get(name) ?? [])], seen = new Set();
97
+ while (todo.length) {
98
+ const key = todo.pop();
99
+ if (seen.has(key))
100
+ continue;
101
+ seen.add(key);
102
+ this.clean.delete(key);
103
+ for (const p of this.up.get(key) ?? [])
104
+ todo.push(p);
105
+ }
106
+ }
107
+ ok(x, key) {
108
+ if ((keepClean && this.clean.has(key)) || x.node === this.node)
109
+ return true;
110
+ if (x.fin && (x.pos < 0 || (x.pos < this.trail.size() && this.trail.stamp(x.pos) === x.stamp))) {
111
+ this.clean.add(key);
56
112
  return true;
57
- return x.fin && (x.pos < 0 || (x.pos < this.trail.size() && this.trail.stamp(x.pos) === x.stamp));
113
+ }
114
+ return false;
58
115
  }
59
116
  kept(r) { return { pos: r.pos, stamp: r.pos < 0 ? 0 : this.trail.stamp(r.pos), node: this.node }; }
60
117
  units = new Map();
@@ -73,7 +130,10 @@ export class Reader {
73
130
  let names = namePair.get(lin);
74
131
  if (!names)
75
132
  namePair.set(lin, (names = [canon(lin), canonFlip(lin)]));
76
- const [a, f] = names, x = this.trail.get(a);
133
+ const [a, f] = names;
134
+ this.readAtom(a);
135
+ this.readAtom(f);
136
+ const x = this.trail.get(a);
77
137
  if (x && x.val !== undefined)
78
138
  return { t: x.val, w: this.unit(a), pos: x.at, fin: true };
79
139
  const y = this.trail.get(f);
@@ -82,9 +142,13 @@ export class Reader {
82
142
  return { t: undefined, w: none, pos: -1, fin: false };
83
143
  }
84
144
  linear(e) {
145
+ this.read(e);
85
146
  const had = this.ls.get(e);
86
- if (had && this.ok(had))
147
+ if (had && this.ok(had, e))
87
148
  return had;
149
+ return this.within(e, () => this.linear0(e));
150
+ }
151
+ linear0(e) {
88
152
  let lin, r = R0;
89
153
  switch (e.op) {
90
154
  case 'var':
@@ -152,6 +216,7 @@ export class Reader {
152
216
  // (an open value's reason is what its decided parts need: only the column's own value is open)
153
217
  const out = { lin, w: r.w, fin: r.fin, ...this.kept(r) };
154
218
  this.ls.set(e, out);
219
+ this.clean.add(e);
155
220
  return out;
156
221
  }
157
222
  atoms(c) {
@@ -170,9 +235,13 @@ export class Reader {
170
235
  return { ...atoms, r };
171
236
  }
172
237
  truth(c) {
238
+ this.read(c);
173
239
  const had = this.ts.get(c);
174
- if (had && this.ok(had))
240
+ if (had && this.ok(had, c))
175
241
  return had;
242
+ return this.within(c, () => this.truth0(c));
243
+ }
244
+ truth0(c) {
176
245
  let t, r;
177
246
  switch (c.op) {
178
247
  case 'flag': throw new Error('flags are inlined before the kernel sees them');
@@ -241,6 +310,7 @@ export class Reader {
241
310
  // once the column's choice is decided, so a value through an open term is found again at each node).
242
311
  const out = { t, w: r.w, fin: t !== undefined && r.fin, ...this.kept(r) };
243
312
  this.ts.set(c, out);
313
+ this.clean.add(c);
244
314
  return out;
245
315
  }
246
316
  // kernel.ts's facts, each row with its reason; final when nothing it read is open.
@@ -316,13 +386,18 @@ export class Reader {
316
386
  }
317
387
  }
318
388
  facts(i) {
389
+ const key = (this.factKeys[i] ??= {});
390
+ this.read(key);
319
391
  const had = this.fs[i];
320
- if (had && this.ok(had))
392
+ if (had && this.ok(had, key))
321
393
  return had;
322
- const rows = [], r = this.factsOf(this.goal.hyps[i], true, rows);
323
- const out = { rows, fin: r.fin, ...this.kept(r) };
324
- this.fs[i] = out;
325
- return out;
394
+ return this.within(key, () => {
395
+ const rows = [], r = this.factsOf(this.goal.hyps[i], true, rows);
396
+ const out = { rows, fin: r.fin, ...this.kept(r) };
397
+ this.fs[i] = out;
398
+ this.clean.add(key);
399
+ return out;
400
+ });
326
401
  }
327
402
  // kernel.ts's termRows, each row with its reason (the forms made again only when a part's form is a new object).
328
403
  termRows(name) {
@@ -429,9 +504,22 @@ export class Reader {
429
504
  }
430
505
  // prove.ts's open atoms of a hypothesis (openH), in its order; none for a hypothesis whose facts are final.
431
506
  open(i, out) {
432
- if (this.facts(i).fin)
507
+ const key = (this.openKeys[i] ??= {}), had = this.os[i];
508
+ if (had && ((keepClean && this.clean.has(key)) || had.node === this.node)) {
509
+ for (const lin of had.lins)
510
+ out.push(lin);
433
511
  return;
434
- this.openH(this.goal.hyps[i], out, true);
512
+ }
513
+ const lins = this.within(key, () => {
514
+ const mine = [];
515
+ if (!this.facts(i).fin)
516
+ this.openH(this.goal.hyps[i], mine, true);
517
+ return mine;
518
+ });
519
+ this.os[i] = { lins, node: this.node };
520
+ this.clean.add(key);
521
+ for (const lin of lins)
522
+ out.push(lin);
435
523
  }
436
524
  openE(e, out) {
437
525
  switch (e.op) {
@@ -8,6 +8,8 @@ export type SimplexVerdict = {
8
8
  kind: 'unknown';
9
9
  };
10
10
  export declare class Simplex {
11
+ readonly integral: boolean;
12
+ constructor(integral?: boolean);
11
13
  private index;
12
14
  private lo;
13
15
  private hi;
@@ -22,10 +24,12 @@ export declare class Simplex {
22
24
  private slackOf;
23
25
  load(rows: {
24
26
  lin: Lin;
27
+ strict?: boolean;
25
28
  }[]): SimplexVerdict;
26
29
  private shift;
27
30
  check(maxPivots?: number): SimplexVerdict;
28
31
  private pivot;
32
+ holds(lin: Lin): boolean | undefined;
29
33
  get size(): number;
30
34
  get nnz(): number;
31
35
  get vars(): number;
@@ -25,6 +25,10 @@ function formOf(lin) {
25
25
  return out;
26
26
  }
27
27
  export class Simplex {
28
+ integral;
29
+ constructor(integral = true) {
30
+ this.integral = integral;
31
+ }
28
32
  index = new Map();
29
33
  lo = [];
30
34
  hi = [];
@@ -102,27 +106,37 @@ export class Simplex {
102
106
  this.loWhy[j] = why;
103
107
  }
104
108
  };
109
+ const integral = this.integral;
110
+ // c·x + k <= 0: x <= −k/c (c > 0) or x >= k/−c (c < 0); rounded to integers, or over the rationals moved in when
111
+ // strict.
112
+ const bound = (c, j, k, i, strict) => {
113
+ const b = c > 0 ? -k / c : k / -c;
114
+ if (integral) {
115
+ if (c > 0)
116
+ tighten(j, true, Math.floor(b + eps), i);
117
+ else
118
+ tighten(j, false, Math.ceil(b - eps), i);
119
+ return;
120
+ }
121
+ const d = strict ? 1e-7 * Math.max(1, Math.abs(b)) : 0;
122
+ if (c > 0)
123
+ tighten(j, true, b - d, i);
124
+ else
125
+ tighten(j, false, b + d, i);
126
+ };
105
127
  for (const [i, r] of rows.entries()) {
106
128
  const f = formOf(r.lin), k = r.lin['1'] ?? 0;
107
129
  if (f === null) {
108
- if (k > 0)
130
+ if (k > 0 || (!integral && r.strict && k >= 0))
109
131
  return { kind: 'conflict', rows: [i] };
110
132
  continue;
111
133
  }
112
134
  if ('single' in f) {
113
- const j = this.varOf(f.single);
114
- if (f.c > 0)
115
- tighten(j, true, Math.floor(-k / f.c + eps), i);
116
- else
117
- tighten(j, false, Math.ceil(k / -f.c - eps), i);
135
+ bound(f.c, this.varOf(f.single), k, i, !integral && r.strict);
118
136
  continue;
119
137
  }
120
- const s = this.slackOf(f);
121
138
  // g·form + k <= 0
122
- if (f.g > 0)
123
- tighten(s, true, Math.floor(-k / f.g + eps), i);
124
- else
125
- tighten(s, false, Math.ceil(k / -f.g - eps), i);
139
+ bound(f.g, this.slackOf(f), k, i, !integral && r.strict);
126
140
  }
127
141
  for (let j = 0; j < this.val.length; j++)
128
142
  if (this.lo[j] > this.hi[j] + eps)
@@ -225,6 +239,19 @@ export class Simplex {
225
239
  for (const j of ecoef.keys())
226
240
  this.colOf[j].add(r);
227
241
  }
242
+ // Whether a row (lin <= 0) holds at the current point, or undefined where it reads a variable the tableau hasn't met.
243
+ holds(lin) {
244
+ let x = lin['1'] ?? 0;
245
+ for (const key in lin) {
246
+ if (key === '1')
247
+ continue;
248
+ const j = this.index.get(key);
249
+ if (j === undefined)
250
+ return undefined;
251
+ x += lin[key] * this.val[j];
252
+ }
253
+ return x <= tol(x);
254
+ }
228
255
  get size() { return this.rows.length; }
229
256
  get nnz() { let n = 0; for (const r of this.rows)
230
257
  n += r.coef.size; return n; }
@@ -1,6 +1,7 @@
1
1
  import type { C, E, Law, Machine, Recurrence } from '../core/machine.js';
2
2
  import { type Lin, type Step } from '../core/solver.js';
3
- import { type Fold, type Goal, type Instances, type Liveness, type Loop, type Path, type StepLaw, type Tree } from '../kernel/kernel.js';
3
+ import { type Fold, type Goal, type Instances, type KInduction, type Liveness, type Loop, type Path, type Recur, type StepLaw, type Tree } from '../kernel/kernel.js';
4
+ import { proveStepLaws } from '../kernel/prove.js';
4
5
  import { type Cyclic } from '../kernel/cyclic.js';
5
6
  import { leanLibrary } from './library.js';
6
7
  export { leanLibrary };
@@ -33,6 +34,15 @@ export declare function loopToLean(id: string, l: Loop, laws: Law[], rank: E | E
33
34
  what: string;
34
35
  loop: Loop;
35
36
  }): string;
37
+ export declare function neverEndsToLean(id: string, l: Loop, r: Recur, tampered?: {
38
+ what: string;
39
+ recur: Recur;
40
+ }[]): string;
41
+ export declare function recurLean(id: string, l: Loop, fallback: Recur): {
42
+ vars: string[];
43
+ loop: string;
44
+ recur: (r: Recur) => string;
45
+ };
36
46
  export declare function foldToLean(id: string, f: Fold, laws: Law[], extra?: string): string;
37
47
  export declare function readable(id: string, laws: Law[], vars: string[], maps: string[], reach: {
38
48
  binders: string;
@@ -69,6 +79,21 @@ export declare function machineLit(mm: Machine, t: {
69
79
  e: (x: E) => string;
70
80
  c: (x: C) => string;
71
81
  }, ix: (name: string) => number, mx: (name: string) => number): string;
82
+ export type KindLean = {
83
+ kl: KInduction;
84
+ start: {
85
+ goal: Goal;
86
+ tree: Tree;
87
+ inst: Instances;
88
+ };
89
+ tampers?: {
90
+ what: string;
91
+ k: number;
92
+ base: number[];
93
+ law?: C;
94
+ expect: boolean;
95
+ }[];
96
+ };
72
97
  export declare function smachineToLean(id: string, given: Machine, laws: Law[], opts?: {
73
98
  stepLaws?: StepLaw[];
74
99
  liveness?: Liveness[];
@@ -103,7 +128,9 @@ export declare function smachineToLean(id: string, given: Machine, laws: Law[],
103
128
  };
104
129
  };
105
130
  noFacts?: boolean;
131
+ kind?: KindLean;
106
132
  }): string;
133
+ export declare const seedStepProof: (m: Machine, laws: Law[], stepLaws: StepLaw[], r: ReturnType<typeof proveStepLaws>) => void;
107
134
  export declare const cyclicCerts: () => boolean;
108
135
  export declare const certReport: {
109
136
  cyclic: string[];
@@ -178,10 +205,27 @@ export type LeanItem = {
178
205
  loop: Loop;
179
206
  rank: E | E[];
180
207
  laws?: Law[];
208
+ } | {
209
+ id: string;
210
+ neverEnds: Loop;
211
+ recur: Recur;
212
+ tampered?: {
213
+ what: string;
214
+ recur: Recur;
215
+ }[];
181
216
  } | {
182
217
  id: string;
183
218
  fold: Fold;
184
219
  laws: Law[];
220
+ } | {
221
+ id: string;
222
+ kInduction: {
223
+ machine: Machine;
224
+ laws: Law[];
225
+ law: Law;
226
+ k?: number;
227
+ ms?: number;
228
+ };
185
229
  } | {
186
230
  id: string;
187
231
  goal: Goal;
@@ -206,6 +250,7 @@ export declare function toLean(items: LeanItem[], opts?: {
206
250
  native?: boolean;
207
251
  cyclic?: boolean;
208
252
  }): string;
253
+ export { rationalsToLean } from './qlean.js';
209
254
  export declare function leanProject(file: string, opts?: {
210
255
  name?: string;
211
256
  }): Record<string, string>;