gdp-wired 0.31.0 → 0.31.1

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.
@@ -188,29 +188,54 @@ export function cdclSession(goal, root, opts = {}) {
188
188
  // trail leaves open (that atom, or its flip where the trail decides it one way); made again only where the live cells
189
189
  // or the decisions about pairs have changed.
190
190
  let cellsAt = [-1, -1], cellsOpen = [];
191
- const truthOf = (lin) => { const x = recOf(lin).x; return x?.val === undefined ? undefined : x.name === canon(lin) ? x.val : !x.val; };
191
+ const pairRecs = new Map();
192
+ let flat = [], flatAt = -1;
193
+ const valOf = (x, same) => (x?.val === undefined ? undefined : same ? x.val : !x.val);
192
194
  const openCellsLive = () => {
193
195
  if (cellsAt[0] === reader.cellsChanged && cellsAt[1] === pairsChanged)
194
196
  return cellsOpen;
195
- const out = [];
196
- for (const names of reader.cells.values()) {
197
- const ns = [...names];
198
- for (let i = 0; i < ns.length; i++)
199
- for (let j = i + 1; j < ns.length; j++) {
200
- const pair = cellPair(ns[i], ns[j]);
201
- if (pairedKeys.skip && Object.keys(pair.d).some(isMonomial))
202
- continue;
203
- for (const lin of [pair.d, pair.neg]) {
204
- const x = recOf(lin).x;
205
- if (x)
206
- x.pair = true;
197
+ // (the pairs in order, made again only where the live cells changed; a decision about a pair reads them again)
198
+ if (flatAt !== reader.cellsChanged) {
199
+ flat = [];
200
+ for (const names of reader.cells.values()) {
201
+ const ns = [...names];
202
+ for (let i = 0; i < ns.length; i++) {
203
+ let row = pairRecs.get(ns[i]);
204
+ if (!row)
205
+ pairRecs.set(ns[i], (row = new Map()));
206
+ for (let j = i + 1; j < ns.length; j++) {
207
+ let r = row.get(ns[j]);
208
+ if (!r) {
209
+ const pair = cellPair(ns[i], ns[j]);
210
+ row.set(ns[j], (r = { d: pair.d, neg: pair.neg, mono: Object.keys(pair.d).some(isMonomial) }));
211
+ }
212
+ flat.push(r);
207
213
  }
208
- const a = truthOf(pair.d), b = truthOf(pair.neg);
209
- if (a === undefined)
210
- out.push(pair.d);
211
- else if (a === true && b === undefined)
212
- out.push(pair.neg);
213
214
  }
215
+ }
216
+ flatAt = reader.cellsChanged;
217
+ }
218
+ const out = [];
219
+ for (const r of flat) {
220
+ if (pairedKeys.skip && r.mono)
221
+ continue;
222
+ if (!r.read) {
223
+ for (const lin of [r.d, r.neg]) {
224
+ const x = recOf(lin).x;
225
+ if (x)
226
+ x.pair = true;
227
+ }
228
+ r.xd = recOf(r.d).x;
229
+ r.sd = r.xd?.name === canon(r.d);
230
+ r.xn = recOf(r.neg).x;
231
+ r.sn = r.xn?.name === canon(r.neg);
232
+ r.read = true;
233
+ }
234
+ const a = valOf(r.xd, r.sd), b = valOf(r.xn, r.sn);
235
+ if (a === undefined)
236
+ out.push(r.d);
237
+ else if (a === true && b === undefined)
238
+ out.push(r.neg);
214
239
  }
215
240
  cellsAt = [reader.cellsChanged, pairsChanged];
216
241
  return (cellsOpen = out);
@@ -97,15 +97,22 @@ function openH(c, path, out, positive = true) {
97
97
  export const pairedKeys = { skip: false };
98
98
  // (each cell's map and key, and each pair's difference both ways, made once: the pairs are quadratic in the names, and
99
99
  // the same forms at every node keep what is remembered per form)
100
+ // (by the first cell, then the second: no key text made per lookup, the search's nodes ask for every pair again)
100
101
  const cellKeys = new Map(), cellPairs = new Map();
102
+ let cellPairsN = 0;
101
103
  export const cellPair = (a, b) => {
102
- const pk = `${a}\u0000${b}`;
103
- let pair = cellPairs.get(pk);
104
+ let row = cellPairs.get(a);
105
+ if (!row)
106
+ cellPairs.set(a, (row = new Map()));
107
+ let pair = row.get(b);
104
108
  if (!pair) {
105
- if (cellPairs.size > 200_000)
109
+ if (++cellPairsN > 200_000) {
106
110
  cellPairs.clear();
111
+ cellPairsN = 1;
112
+ cellPairs.set(a, (row = new Map()));
113
+ }
107
114
  const d = sub(cellKey(a).key, cellKey(b).key);
108
- cellPairs.set(pk, (pair = { d, neg: scale(d, -1) }));
115
+ row.set(b, (pair = { d, neg: scale(d, -1) }));
109
116
  }
110
117
  return pair;
111
118
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdp-wired",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "An automatic prover for stateful rules (budgets, caps, windows, workflows, policies): laws proven with no proof to write, checked again in Lean, counterexamples found on the GPU, the rule shipped as code",
5
5
  "keywords": [
6
6
  "verification",
@@ -112,16 +112,12 @@
112
112
  },
113
113
  "peerDependencies": {
114
114
  "@gdp-ts/core": ">=0.1.0",
115
- "effect": "^3.22.0 || ^4.0.0",
116
115
  "typescript": ">=5.0.0"
117
116
  },
118
117
  "peerDependenciesMeta": {
119
118
  "@gdp-ts/core": {
120
119
  "optional": true
121
120
  },
122
- "effect": {
123
- "optional": true
124
- },
125
121
  "typescript": {
126
122
  "optional": true
127
123
  }