gdp-wired 0.36.0 → 0.38.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.
@@ -14,9 +14,10 @@
14
14
  // value before, shifts of it, the request's values and the state before; each is chosen to satisfy P at every
15
15
  // counterexample so far, per case of the step (the conditions its updates split on: the request's clause, say).
16
16
  // A law under a `forall` key takes witness terms only (a ghost per key would be a map).
17
- import { evalC, evalE, n as k, walk, x as v } from "./machine.js";
18
- import { clock, proveLaw, proveLaws, withinDeadline } from "../kernel/prove.js";
17
+ import { carriedView, evalC, evalE, interpret, n as k, walk, x as v } from "./machine.js";
18
+ import { clock, proveLaw, proveLaws, withDeadline, withinDeadline } from "../kernel/prove.js";
19
19
  import { env } from "./solver.js";
20
+ import { ghostedMachine, ghostedOk, substC } from "../kernel/kernel.js";
20
21
  const add = (a, b) => (a.op === 'const' && a.value === 0 ? b : b.op === 'const' && b.value === 0 ? a : { op: 'add', a, b });
21
22
  const sum = (es) => es.reduce((acc, e) => add(acc, e), k(0));
22
23
  const sub = (a, b) => (b.op === 'const' && b.value === 0 ? a : { op: 'sub', a, b });
@@ -152,6 +153,54 @@ function solved(atoms, g) {
152
153
  }
153
154
  return out;
154
155
  }
156
+ const atomsOf2 = (c) => (c.op === 'and' || c.op === 'or' ? c.xs.flatMap(atomsOf2) : c.op === 'not' ? atomsOf2(c.x) : [c]);
157
+ // --- the small instances (core/counts.ts's filter and the ghost maps' below) --------------------------------------------------------------------------------------------------
158
+ // Every state reached from the start with the params at `p`, each input below `b`, each carried map a subset of 0 .. b − 1.
159
+ // (at most `cap` states, and `work` steps tried: a wide request space ends the BFS early, its states still reachable)
160
+ export function small(m, p, b, cap = 3000, work = 300_000) {
161
+ const run = interpret(m), start = run.init(p);
162
+ const subsets = Array.from({ length: 1 << b }, (_, s) => new Map(Array.from({ length: b }, (_, i) => i).filter(i => (s >> i) & 1).map(i => [i, 1])));
163
+ // (an input the assumption keeps below a few values, an action's, over all of them; the rest below b)
164
+ const below = (i) => Math.max(b, ...(m.assume ? atomsOf2(m.assume) : []).flatMap(c => (c.op === '<' && c.a.op === 'var' && c.a.name === i && c.b.op === 'const' && c.b.value <= 8 ? [c.b.value] : [])));
165
+ let reqs = [{}];
166
+ for (const i of m.inputs)
167
+ reqs = reqs.flatMap(r => Array.from({ length: below(i) }, (_, x) => ({ ...r, [i]: x })));
168
+ for (const c of m.inputMaps ?? [])
169
+ reqs = reqs.flatMap(r => subsets.map(s => ({ ...r, [c]: s })));
170
+ const seen = new Map([[key(start), start]]), queue = [start];
171
+ while (queue.length && seen.size < cap && work > 0) {
172
+ const st = queue.shift();
173
+ for (const r of reqs) {
174
+ if (--work < 0)
175
+ break;
176
+ let next;
177
+ try {
178
+ next = run.step(p, st, r);
179
+ }
180
+ catch {
181
+ continue;
182
+ }
183
+ const id = key([next.scalars, Object.entries(next.maps).map(([n, cs]) => [n, [...cs].filter(([, x]) => x).sort((a, c) => a[0] - c[0])])]);
184
+ if (!seen.has(id)) {
185
+ seen.set(id, next);
186
+ queue.push(next);
187
+ }
188
+ }
189
+ }
190
+ return [...seen.values()];
191
+ }
192
+ // A law at a state, its counts the state's, at every key below b.
193
+ // (a state's view once: a law is read at every state, and every law at each)
194
+ const views = new WeakMap();
195
+ export function holdsAt(m, law, p, st, b) {
196
+ const empty = Object.fromEntries((m.inputMaps ?? []).map(c => [c, new Map()]));
197
+ let view = views.get(st);
198
+ if (!view)
199
+ views.set(st, (view = carriedView(m, st, empty, undefined, p)));
200
+ const keys = [law.forall, ...(law.keys ?? [])].filter((x) => !!x);
201
+ const go = (env, ks) => (ks.length ? Array.from({ length: b }, (_, x) => x).every(x => go({ ...env, [ks[0]]: x }, ks.slice(1))) : evalC(law.holds, { ...env, ...st.scalars }, view, m));
202
+ return go({ ...p }, keys);
203
+ }
155
204
  // --- evaluating ∃ on a state ----------------------------------------------------------------------------------------
156
205
  // Whether ∃ vars. P holds where env and st give every other value, with a witness: exact when the bound values are one
157
206
  // natural or one integer read linearly (P's truth changes only next to the values its atoms solve for, so those, their
@@ -359,14 +408,75 @@ function planOf(m, law) {
359
408
  groups.forEach((g, i) => { terms[i] = [g.map(n => w.terms[n] ?? k(0))]; });
360
409
  if (w?.ghost)
361
410
  groups.forEach((g, i) => { starts[i] = [g.map(n => w.ghost[n]?.start ?? k(0))]; steps[i] = [g.map(n => w.ghost[n]?.step ?? v(n))]; });
362
- return { law, groups, terms, starts, steps, pick: w?.ghost ? { mode: 'ghost', start: groups.map(() => 0), cases: new Map() } : { mode: 'term', at: groups.map(() => 0) }, seen: { term: [], start: [], step: new Map() }, given };
411
+ return { law, groups, terms, starts, steps, maps: [], pick: w?.ghost ? { mode: 'ghost', start: groups.map(() => 0), cases: new Map() } : { mode: 'term', at: groups.map(() => 0) }, seen: { term: [], start: [], step: new Map() }, given };
363
412
  }
413
+ function mapGhostsOf(m, law, taken) {
414
+ const x = law.some[0], names = [law.forall, ...(law.keys ?? [])];
415
+ const xs = law.holds.op === 'or' ? law.holds.xs : [law.holds], P = xs.filter(d => namesOf(d).includes(x)), rest = xs.filter(d => !namesOf(d).includes(x));
416
+ const guards = rest.flatMap(d => (d.op === 'not' ? (d.x.op === 'and' ? d.x.xs : [d.x]) : [])).filter(c => !readsMaps(c));
417
+ if (law.some.length !== 1 || x.endsWith('$neg') || !P.length)
418
+ return [];
419
+ const out = [];
420
+ for (const [mp, w] of Object.entries(m.step.maps ?? {})) {
421
+ if ('each' in w)
422
+ continue;
423
+ const kv = namesOf(w.key);
424
+ if (!kv.length || !kv.every(n => m.inputs.includes(n)) || kv.length > names.length)
425
+ continue;
426
+ const set = substC({ op: '<=', a: k(1), b: w.value }, { vars: {}, maps: { [mp]: () => k(0) }, flags: Object.fromEntries(Object.keys(m.step.flags ?? {}).map(f => [f, { op: 'flag', name: f }])) });
427
+ // (each write key's input at a different one of the law's keys)
428
+ const injections = kv.reduce((acc) => acc.flatMap(a => names.filter(n => !a.includes(n)).map(n => [...a, n])), [[]]);
429
+ // (a value an action selects, compared with constants alone, is no witness)
430
+ const keyed = new Set();
431
+ walk([m.step, m.assume ?? null], o => { if (o.op === 'get')
432
+ for (const n of namesOf(o.key))
433
+ keyed.add(n); });
434
+ for (const w2 of Object.values(m.step.maps ?? {}))
435
+ if (!('each' in w2))
436
+ for (const n of namesOf(w2.key))
437
+ keyed.add(n);
438
+ const action = (i) => !keyed.has(i);
439
+ for (const inj of injections)
440
+ for (const val of m.inputs.filter(i => !kv.includes(i) && !action(i))) {
441
+ let name = `${mp}$w`;
442
+ for (let j = 2; taken.has(name); j++)
443
+ name = `${mp}$w${j}`;
444
+ const at = substVarsE(w.key, Object.fromEntries(kv.map((n, j) => [n, v(inj[j])]))), atW = { op: 'get', map: name, key: at };
445
+ const Pw = substVars(P.length === 1 ? P[0] : { op: 'or', xs: P }, { [x]: atW }), has = { op: '<=', a: k(1), b: { op: 'get', map: mp, key: at } };
446
+ out.push({ name, write: { key: w.key, value: { op: 'if', c: set, then: v(val), else: { op: 'get', map: name, key: w.key } } }, at,
447
+ holds: substVars(law.holds, { [x]: atW }),
448
+ inv: { name: `${law.name}: ${name} where ${mp} is set`, forall: law.forall, ...(law.keys ? { keys: law.keys } : {}), holds: { op: 'or', xs: [{ op: 'not', x: { op: 'and', xs: [...guards, has] } }, Pw] } } });
449
+ }
450
+ }
451
+ return out;
452
+ }
453
+ const takenOf = (m) => new Set([...Object.keys(m.maps ?? {}), ...(m.inputMaps ?? []), ...Object.keys(m.fns ?? {})]);
454
+ const firstPicks = new Map();
455
+ // The machine with a ghost map (kernel.ts's ghostedMachine of Ghosted, whose ghostedOk it must pass).
456
+ const withMap = (m, g) => {
457
+ const o = { orig: m, vars: {}, maps: { [g.name]: { start: 0, write: g.write } } };
458
+ if (!ghostedOk(o))
459
+ throw new Error(`${g.name}: not a ghost of ${m.name}`);
460
+ return ghostedMachine(o);
461
+ };
364
462
  // The machine with every ghost the plans have chosen, and each law as the kernel proves it.
365
- function built(m, plans, cases) {
463
+ function built(m0, plans, cases) {
464
+ let m = m0;
465
+ const invs = [];
466
+ for (const p of plans)
467
+ if (p.pick.mode === 'map') {
468
+ const g = p.maps[p.pick.at];
469
+ m = withMap(m, g);
470
+ invs.push(g.inv);
471
+ }
366
472
  const state = { ...m.state }, step = { ...m.step.state }, ghosts = [];
367
473
  const laws = plans.map(p => {
368
474
  const { law } = p, ex = { vars: law.some, body: law.holds };
369
475
  const plain = { name: law.name, holds: law.holds, ...(law.forall ? { forall: law.forall } : {}), ...(law.keys ? { keys: law.keys } : {}), stated: law.stated ?? law.holds };
476
+ if (p.pick.mode === 'map') {
477
+ const g = p.maps[p.pick.at];
478
+ return { ...plain, holds: g.holds, ex: { ...ex, map: { name: g.name, at: g.at } } };
479
+ }
370
480
  if (p.pick.mode === 'term') {
371
481
  const pick = p.pick.at, sub = {};
372
482
  p.groups.forEach((g, i) => g.forEach((n, j) => { sub[n] = p.terms[i][pick[i]][j]; }));
@@ -381,7 +491,7 @@ function built(m, plans, cases) {
381
491
  }));
382
492
  return { ...plain, ex: { ...ex, ghost: true } };
383
493
  });
384
- return { machine: { ...m, state, step: { ...m.step, state: step } }, laws, ghosts };
494
+ return { machine: { ...m, state, step: { ...m.step, state: step } }, laws, ghosts, invs };
385
495
  }
386
496
  // A state's values for every name, 0 for a name it doesn't give (as the prover reads a model).
387
497
  const total = (w) => new Proxy(w, { get: (t, n) => (typeof n === 'string' ? (t[n] ?? 0) : undefined) });
@@ -474,15 +584,71 @@ export function proveSome(m, laws, opts = {}) {
474
584
  const current = () => {
475
585
  const b = built(m, [...plans.values()], cases);
476
586
  const out = laws.map((l, i) => (plans.has(i) ? b.laws[[...plans.keys()].indexOf(i)] : l));
477
- return { machine: b.machine, laws: out, ghosts: b.ghosts };
587
+ return { machine: b.machine, laws: [...out, ...b.invs], ghosts: b.ghosts };
478
588
  };
479
589
  const rounds = opts.rounds ?? 24;
590
+ // (a law about every key with no witness term: the next ghost map past `from` that keeps its law and the ghost's own
591
+ // on every state of the small instances, each param 2 and 3)
592
+ const smallOk = (mm, ls) => [2, 3].every(x => { const ps = Object.fromEntries(m.params.map(q => [q, x])); return small(mm, ps, 2, 1500, 100_000).every(st => ls.every(l => holdsAt(mm, l, ps, st, 2))); });
593
+ const toMap = (p, from) => {
594
+ if (from < 0)
595
+ p.maps = mapGhostsOf(m, p.law, takenOf(m));
596
+ const others = [...plans.values()].filter(q => q !== p && q.pick.mode === 'map');
597
+ for (let j = from + 1; j < p.maps.length; j++) {
598
+ const g = p.maps[j];
599
+ try {
600
+ const mm = withMap(others.reduce((acc, q) => withMap(acc, q.maps[q.pick.at]), m), g);
601
+ const ok = smallOk(mm, [g.inv, { ...p.law, holds: g.holds, some: undefined }]);
602
+ if (log)
603
+ console.error(`exists: map ${g.name} at ${showE(g.at)} := ${showE(g.write.value)}: ${ok ? 'kept' : 'false on the small instances'}`);
604
+ if (ok) {
605
+ p.pick = { mode: 'map', at: j };
606
+ return true;
607
+ }
608
+ }
609
+ catch (e) {
610
+ if (log)
611
+ console.error(`exists: map ${g.name}: ${String(e).slice(0, 120)}`);
612
+ }
613
+ }
614
+ return false;
615
+ };
480
616
  const log = env.GDP_EXISTS_LOG === '1';
481
617
  // Each law's witness until its goals are proven with every law assumed (choose); then the whole set, and where a
482
618
  // later choice broke a law proven before (a witness term is a hypothesis of every law), that law's again.
483
619
  const choose = (i, p, pass, first) => {
620
+ // (a law about every key over maps, one value bound: its first witness term one the small instances keep, else a
621
+ // ghost map at once; none of either, no witness)
622
+ if (p.law.forall && !p.given && p.groups.length === 1 && p.groups[0].length === 1 && mapsRead(p.law) && p.pick.mode === 'term' && !first) {
623
+ // (the first pick a machine's law got, again: a search asks the same law with each candidate set)
624
+ const id = key([m.step, m.assume ?? null, m.maps ?? null, p.law.holds]), had = firstPicks.get(id);
625
+ if (had?.mode === 'map') {
626
+ p.maps = mapGhostsOf(m, p.law, takenOf(m));
627
+ p.pick = { ...had };
628
+ }
629
+ else if (had)
630
+ p.pick = { mode: 'term', at: [...had.at] };
631
+ }
632
+ if (p.law.forall && !p.given && p.groups.length === 1 && p.groups[0].length === 1 && mapsRead(p.law) && p.pick.mode === 'term' && !first && !firstPicks.has(key([m.step, m.assume ?? null, m.maps ?? null, p.law.holds]))) {
633
+ const x = p.groups[0][0], at = p.terms[0].findIndex(t => { try {
634
+ return smallOk(m, [{ ...p.law, holds: substVars(p.law.holds, { [x]: t[0] }), some: undefined }]);
635
+ }
636
+ catch {
637
+ return false;
638
+ } });
639
+ if (log)
640
+ console.error(`exists: first term on the small instances: ${at < 0 ? 'none' : describe({ ...p, pick: { mode: 'term', at: [at] } }, cases)}`);
641
+ if (at >= 0)
642
+ p.pick = { mode: 'term', at: [at] };
643
+ else if (!toMap(p, -1))
644
+ return { proven: false, nodes: 0, leaves: 0, checked: false, failed: { goal: `${p.law.name} @step`, stuck: 'unknown', why: `no witness for "${p.law.name}" holds on the small instances` } };
645
+ const pk = p.pick;
646
+ firstPicks.set(key([m.step, m.assume ?? null, m.maps ?? null, p.law.holds]), pk.mode === 'map' ? { mode: 'map', at: pk.at } : { mode: 'term', at: [...pk.at] });
647
+ }
484
648
  for (let round = 0;; round++) {
485
- const now = current(), t0 = performance.now(), r = round === 0 && first ? { proven: false, ...first } : proveLaw(now.machine, now.laws, i);
649
+ const now = current(), t0 = performance.now(), r = round === 0 && first ? { proven: false, ...first }
650
+ // (a ghost map's goals within 2 s: a search asks them with every candidate set, and one without its supports can take minutes)
651
+ : p.pick.mode === 'map' ? withDeadline(clock() + 2_000, () => proveLaw(now.machine, now.laws, i)) : proveLaw(now.machine, now.laws, i);
486
652
  if (log)
487
653
  console.error(`exists: pass ${pass} round ${round} "${p.law.name}" ${p.pick.mode} ${describe(p, cases).slice(0, 160)}: ${r.proven ? 'proven' : `${r.goal} ${r.stuck}`} (${Math.round(performance.now() - t0)} ms)`);
488
654
  if (r.proven)
@@ -500,6 +666,8 @@ export function proveSome(m, laws, opts = {}) {
500
666
  p.pick = { mode: 'ghost', start: p.groups.map(() => 0), cases: new Map() };
501
667
  continue;
502
668
  }
669
+ if (p.law.forall && !p.given && p.pick.mode !== 'ghost' && toMap(p, p.pick.mode === 'map' ? p.pick.at : -1))
670
+ continue;
503
671
  return fail(r.stuck);
504
672
  }
505
673
  const w = r.witness, atStart = r.goal.endsWith('@start'), blind = mapsRead(p.law);
@@ -529,8 +697,15 @@ export function proveSome(m, laws, opts = {}) {
529
697
  p.pick = { mode: 'ghost', start: p.groups.map(() => 0), cases: new Map() };
530
698
  continue;
531
699
  }
700
+ if (p.law.forall && !p.given && toMap(p, -1))
701
+ continue;
532
702
  return fail(`no witness term found for "${p.law.name}" (${r.goal}): name one (exists(kind, f, witness))`);
533
703
  }
704
+ if (p.pick.mode === 'map') {
705
+ if (toMap(p, p.pick.at))
706
+ continue;
707
+ return fail(`no ghost map found for "${p.law.name}" (${r.goal})`);
708
+ }
534
709
  if (atStart) {
535
710
  p.seen.start.push(after);
536
711
  const old = p.pick.start;
@@ -598,6 +773,10 @@ function describe(p, cases) {
598
773
  const at = p.pick.at;
599
774
  return p.groups.map((g, i) => `${name(g)} = ${show(p.terms[i][at[i]])}`).join(', ');
600
775
  }
776
+ if (p.pick.mode === 'map') {
777
+ const g = p.maps[p.pick.at];
778
+ return `${name(p.groups[0])} = ${g.name}[${showE(g.at)}], ${g.name}[${showE(g.write.key)}] := ${showE(g.write.value)}`;
779
+ }
601
780
  const { start, cases: cs } = p.pick;
602
781
  return p.groups.map((g, i) => `${name(g)} starts at ${show(p.starts[i][start[i]])}; after a step ${[...cs.entries()].filter(([c]) => c >= 0).map(([c, at]) => `${show(p.steps[i][at[i]])} where ${showC(cases[c])}`).join(', ')}${cs.size > (cs.has(-1) ? 1 : 0) ? ', else ' : ''}${show(p.steps[i][cs.get(-1)?.[i] ?? 0])}`).join('; ');
603
782
  }
@@ -78,7 +78,7 @@ export type CheckOptions = {
78
78
  states?: number;
79
79
  seed?: number;
80
80
  bound?: number;
81
- probes?: boolean;
81
+ probes?: boolean | 'writes';
82
82
  probeMs?: number;
83
83
  modules?: Record<string, unknown>;
84
84
  files?: Record<string, string>;
@@ -123,7 +123,7 @@ export declare function check(code: string, file: string, m: Model, r: Rule, sor
123
123
  export declare function drive(m: Model, r: Rule, sorts: Sorts, code: CodeSide, opts?: CheckOptions & {
124
124
  given?: Record<string, 'nat' | 'int'>;
125
125
  }): Evidence;
126
- export declare function conditionsOf(m: Model): B[];
126
+ export declare function conditionsOf(m: Model, writes?: boolean): B[];
127
127
  export declare function condAt(c: B, env: Record<string, unknown>): ReturnType<Term['lt']>;
128
128
  export declare function evalTerm(t: N | B | I.L, env: Record<string, Raw>, cell?: (map: string, key: Raw, field: string) => Raw): Raw;
129
129
  export {};
@@ -771,7 +771,7 @@ export function drive(m, r, sorts, code, opts = {}) {
771
771
  // Steps from the prover's counterexamples: each condition of the step, refuted as "never holds". (Not where the
772
772
  // rule carries folds: their equations, quantified over every pass, make each probe slow, and a witness's lists empty.)
773
773
  if (opts.probes !== false && !m.folds?.length) {
774
- const conds = conditionsOf(m);
774
+ const conds = conditionsOf(m, opts.probes === 'writes');
775
775
  for (const [i, c] of conds.entries()) {
776
776
  ev.probes.conditions++;
777
777
  let law;
@@ -821,7 +821,9 @@ export function drive(m, r, sorts, code, opts = {}) {
821
821
  }
822
822
  const mapReplacer = (_, v) => (isMap(v) ? { $map: [...v.entries()] } : v);
823
823
  // The conditions a step reads (each branch's, each refusal's), as a probe asks the prover to reach.
824
- export function conditionsOf(m) {
824
+ // ('writes': the branches' only; a refusal's condition holds at no step the rule takes, so where the rule is large its
825
+ // probe is a proof the kernel may take long over)
826
+ export function conditionsOf(m, writes = false) {
825
827
  const out = [], seen = new Set();
826
828
  const add = (c) => { if (c.op === 'const')
827
829
  return; const k = I.keyOf(c); if (!seen.has(k) && !hasCell(c)) {
@@ -830,8 +832,9 @@ export function conditionsOf(m) {
830
832
  } };
831
833
  walk([m.writes, m.mapWrites], o => { if ((o.op === 'ite' || o.op === 'kite') && o.c)
832
834
  add(o.c); });
833
- for (const d of m.refuse.op === 'or' ? m.refuse.xs : [m.refuse])
834
- add(d);
835
+ if (!writes)
836
+ for (const d of m.refuse.op === 'or' ? m.refuse.xs : [m.refuse])
837
+ add(d);
835
838
  return out.slice(0, 48);
836
839
  }
837
840
  const hasCell = (c) => I.varsOf(c).maps.size > 0;
@@ -279,10 +279,10 @@ export function sortsOf(m, given = {}) {
279
279
  }
280
280
  for (const d of m.maps)
281
281
  for (const f of d.fields) {
282
- const n = `${d.name}.${f.name}`, w = m.mapWrites[d.name]?.vals[f.name];
282
+ const n = `${d.name}.${f.name}`, mw = m.mapWrites[d.name];
283
283
  if (f.sort.k !== 'num' || sorts.get(n) === 'int' || given[n])
284
284
  continue;
285
- if (w && w.s === 'num' && !natOK(w.e, withAtom(ctx0(), m.mapWrites[d.name].has))) {
285
+ if (mw && [...(mw.pre ?? []), mw].some(x => { const w = x.vals[f.name]; return w && w.s === 'num' && !natOK(w.e, withAtom(ctx0(), x.has)); })) {
286
286
  sorts.set(n, 'int');
287
287
  changed = true;
288
288
  }
@@ -384,7 +384,9 @@ function pcmp(rel, a, b, P, ctx) {
384
384
  const op = rel === '<' ? 'lt' : rel === '<=' ? 'atMost' : 'eq', flip = rel === '<' ? 'gt' : rel === '<=' ? 'atLeast' : 'eq';
385
385
  const nat = natOK(a, ctx) && natOK(b, ctx);
386
386
  const [x, y, o] = a.op === 'const' && b.op !== 'const' ? [b, a, flip] : [a, b, op];
387
- return `${pn(x, P, ctx, nat ? 'nat' : 'int', true)}.${o}(${pn(y, P, ctx, nat || natOK(y, ctx) ? 'nat' : 'int')})`;
387
+ // (a natural by cases compared with an integer: its when(...) is a natural's, made an integer to compare from)
388
+ const left = !nat && x.op === 'ite' && natOK(x, ctx) ? `Int.of(${pn(x, P, ctx, 'nat')})` : pn(x, P, ctx, nat ? 'nat' : 'int', true);
389
+ return `${left}.${o}(${pn(y, P, ctx, nat || natOK(y, ctx) ? 'nat' : 'int')})`;
388
390
  }
389
391
  export function pb(c, P, ctx) {
390
392
  const h = P.hoisted.get(I.keyOf(c));
@@ -115,6 +115,8 @@ export type MapWrite = {
115
115
  key: K;
116
116
  has: B;
117
117
  vals: Record<string, Term>;
118
+ pre?: MapWrite[];
119
+ when?: B;
118
120
  };
119
121
  export type ListOp = {
120
122
  op: 'push';
@@ -0,0 +1,91 @@
1
+ import { type Extraction } from './extract.js';
2
+ import { type FileURL } from './extract-read.js';
3
+ import { type SModule, type SType, type StepOptions, type StepRead } from './extract-step.js';
4
+ export { proveRule, proveSteps } from './dsl.js';
5
+ export type SolOptions = StepOptions & {
6
+ root?: string;
7
+ remappings?: string[];
8
+ reentrant?: boolean;
9
+ solc?: string;
10
+ anvil?: string;
11
+ python?: string;
12
+ };
13
+ type Ast = {
14
+ nodeType: string;
15
+ id: number;
16
+ src: string;
17
+ [k: string]: any;
18
+ };
19
+ export declare const MOD = "W256$";
20
+ export type Compiled = {
21
+ main: number;
22
+ ast: Map<number, Ast>;
23
+ text: Map<number, string>;
24
+ paths: Map<number, string>;
25
+ contracts: Record<string, Record<string, {
26
+ abi: unknown[];
27
+ evm: {
28
+ bytecode: {
29
+ object: string;
30
+ };
31
+ deployedBytecode: {
32
+ object: string;
33
+ };
34
+ methodIdentifiers: Record<string, string>;
35
+ };
36
+ storageLayout: {
37
+ storage: {
38
+ label: string;
39
+ slot: string;
40
+ offset: number;
41
+ type: string;
42
+ }[];
43
+ types: Record<string, {
44
+ encoding: string;
45
+ numberOfBytes: string;
46
+ key?: string;
47
+ value?: string;
48
+ label: string;
49
+ }>;
50
+ };
51
+ }>>;
52
+ };
53
+ export declare function compile(file: string, o: SolOptions): Compiled;
54
+ type Field = {
55
+ name: string;
56
+ t: SType;
57
+ decl: Ast;
58
+ sol: string;
59
+ };
60
+ export type SolMeta = {
61
+ leftOut: string[];
62
+ calls: boolean;
63
+ resumes: string[];
64
+ addrBits: number;
65
+ contract: string;
66
+ source: string;
67
+ fields: Field[];
68
+ fns: Record<string, Ast>;
69
+ payable: string[];
70
+ minW: number;
71
+ nested: string[];
72
+ entries: Record<string, {
73
+ sig: string;
74
+ inputs: string[];
75
+ payable: boolean;
76
+ out?: string;
77
+ }>;
78
+ ctor: {
79
+ inputs: string[];
80
+ payable: boolean;
81
+ };
82
+ ether: boolean;
83
+ };
84
+ export declare function readSolidity(file: string, o?: SolOptions, reenter?: boolean, compiled?: Compiled): {
85
+ mod: SModule;
86
+ meta: SolMeta;
87
+ c: Compiled;
88
+ };
89
+ export declare function extractSolidity(at: string | FileURL, opts?: SolOptions): Extraction & {
90
+ read?: StepRead;
91
+ };