gdp-wired 0.59.0 → 0.59.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.
Files changed (2) hide show
  1. package/dist/core/infer.js +12 -11
  2. package/package.json +1 -1
@@ -2145,7 +2145,8 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
2145
2145
  }
2146
2146
  return broke;
2147
2147
  };
2148
- const houdiniUntil = opts.cubes || relStep ? 0 : Math.min(until, now() + Math.max(500, (until - now()) / 4));
2148
+ const hasRelations = !!Object.keys(m.relations ?? {}).length;
2149
+ const houdiniUntil = opts.cubes || relStep || hasRelations ? 0 : Math.min(until, now() + Math.max(500, (until - now()) / 4));
2149
2150
  for (let quiet = 0; samples.length && now() < houdiniUntil && !stop() && quiet < 3;) {
2150
2151
  const killed = new Set();
2151
2152
  for (let tries = 0; tries < 400 && now() < houdiniUntil && !stop(); tries++) {
@@ -2330,7 +2331,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
2330
2331
  if (joinOn && NS)
2331
2332
  try {
2332
2333
  // (a rule of relations: no round of the join, whose hulls and bounds state no law of a relation's tuples; the engine's)
2333
- const noJoin = opts.join === 0 || !!Object.keys(m.relations ?? {}).length;
2334
+ const noJoin = opts.join === 0 || hasRelations;
2334
2335
  const jT0 = countedSearchNow(), jUntil = Math.min(until, now() + (until - now()) * (noJoin ? 0 : opts.join ?? joinShare));
2335
2336
  // The control state: the choice (loc) and, where they are few, the yes/nos (a program counter in bits), each of its
2336
2337
  // values reached a part of its own.
@@ -2370,7 +2371,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
2370
2371
  // Where no key is composed but a caller's law is about several keys (two counted approvals by distinct reviewers, two
2371
2372
  // holders of one lock), the same space over two distinct keys x ≠ y: the cells at x and at y (`n` 0, no third place).
2372
2373
  const pairing = mapNames.length ? pairingOf(m) ?? ([...laws, ...stepLaws].some(l => l.keys?.length) ? { n: 0, c: 0, frame: not(same(x(KEY), x(KEY2))) } : undefined) : undefined;
2373
- const cellLevels = pairing ? levelsOf(cellAtoms.filter(i => !atoms[i].int), valsK) : [];
2374
+ const cellLevels = !noJoin && pairing ? levelsOf(cellAtoms.filter(i => !atoms[i].int), valsK) : [];
2374
2375
  // A view's atoms (each map at each place it is read at there) and rows: each assignment of its keys to keys a state
2375
2376
  // holds (by sort: the keys of the maps read at the key's place, the parts of composed keys there, and a fresh one;
2376
2377
  // per key at most `per`), the frame met, each map's cell at each of its places.
@@ -2498,7 +2499,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
2498
2499
  const sorts = mapNames.length ? keySorts(m, callerLaws, pairing) : undefined;
2499
2500
  // (the maps keyed by tuples are read at their tuples, in the engine's views alone)
2500
2501
  const flat = mapNames.filter(mp => !sorts?.tupled.has(mp));
2501
- if (pairing && flat.length) {
2502
+ if (!noJoin && pairing && flat.length) {
2502
2503
  const P = pairing, composed = plus(times(P.n, x(KEY)), x(KEY2)), places = P.n ? [x(KEY), x(KEY2), P.c ? plus(composed, n(P.c)) : composed] : [x(KEY), x(KEY2)];
2503
2504
  // (by sort, where the rule composes: a row's maps at x, a column's at y, the composed maps at the composed key)
2504
2505
  const sorted = P.n && sorts ? [sorts.plainMaps(sorts.find('hi')), sorts.plainMaps(sorts.find('lo')), sorts.composedMaps] : undefined;
@@ -2522,7 +2523,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
2522
2523
  // (keySorts: a sort is the places a key is read at, the rule's keys read alike as one), its places the composed keys
2523
2524
  // its reads name and each map read at a plain key of a key's sort, its frame its own guards on its keys and the keys
2524
2525
  // of one sort distinct.
2525
- if (sorts) {
2526
+ if (!noJoin && sorts) {
2526
2527
  const seen = new Set();
2527
2528
  for (const l of callerLaws) {
2528
2529
  const bound = l.forall ? [l.forall, ...(l.keys ?? [])] : [];
@@ -2835,7 +2836,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
2835
2836
  };
2836
2837
  return { cells, add, forms, refine, deepen, coords, control: () => `${ctl.map(c => nameOf(c.atom)).join(' ')} (${scored.join(' ')})`, groups };
2837
2838
  };
2838
- const spaces = [space('state'), ...(mapNames.length && cellAtoms.length ? [space('cells')] : []), ...views.flatMap((v, i) => (v.rows.length ? [space(i)] : []))];
2839
+ const spaces = noJoin ? [] : [space('state'), ...(mapNames.length && cellAtoms.length ? [space('cells')] : []), ...views.flatMap((v, i) => (v.rows.length ? [space(i)] : []))];
2839
2840
  const formsNow = () => {
2840
2841
  const out = [], seenT = new Set();
2841
2842
  const push = (f) => { const t = textOf(f); if (!seenT.has(t) && !names.has(t)) {
@@ -2979,17 +2980,17 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
2979
2980
  // (the rule's own comparisons first, then each value, then pairs: of two directions that leave out as many samples
2980
2981
  // the first is taken, so a bound the runs' depth sets, i0 <= 1 where they went 1 deep, gives way to the relation
2981
2982
  // that holds at every depth, i0 <= i1)
2982
- const lc = plain.filter(i => !atoms[i].param && !ctrl.includes(i)), D0 = directions(lc), own = 2 * lc.length + (lc.length <= joinPairs ? 2 * lc.length * (lc.length - 1) : 0);
2983
+ const lc = plain.filter(i => !atoms[i].param && !ctrl.includes(i)), D0 = noJoin ? [] : directions(lc), own = 2 * lc.length + (lc.length <= joinPairs ? 2 * lc.length * (lc.length - 1) : 0);
2983
2984
  const D = [...D0.slice(own), ...D0.slice(0, own)];
2984
2985
  const dot = (t, v) => { let s2 = 0; for (const [i, c] of t)
2985
2986
  s2 += c * v[i]; return s2; };
2986
2987
  const litHolds = (l, v) => ('at' in l ? v[l.at.atom] === l.at.value : dot(l.lin.coef, v) <= l.lin.d);
2987
2988
  const inCube = (c, v) => c.every(l => litHolds(l, v));
2988
2989
  const vecKey = (v) => v instanceof Float64Array ? v.join(',') : Array.from(v).join(',');
2989
- const S = rowsS.map(r => valuesOf(r)), sampled = new Set(S.map(vecKey));
2990
+ const S = noJoin ? [] : rowsS.map(r => valuesOf(r)), sampled = new Set(S.map(vecKey));
2990
2991
  let initVec;
2991
2992
  try {
2992
- if (!m.params.length)
2993
+ if (!noJoin && !m.params.length)
2993
2994
  initVec = valuesOf(pointOf({}, run.init({})).scalar);
2994
2995
  }
2995
2996
  catch {
@@ -3020,7 +3021,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
3020
3021
  // predecessors take it back to the samples; the comparisons are what a predecessor's guards say, as Spacer's
3021
3022
  // projections read them), then the direction that leaves out the most samples still in, its bound as weak as
3022
3023
  // leaves them out, until none is in (undefined: none leaves out the rest).
3023
- const ruleLits = joinAtoms ? comparisons(m, laws, atoms, lc).map(lin => ({ lin })) : [];
3024
+ const ruleLits = !noJoin && joinAtoms ? comparisons(m, laws, atoms, lc).map(lin => ({ lin })) : [];
3024
3025
  const cubeOf = (v) => {
3025
3026
  const lits = ctrl.map(i => ({ at: { atom: i, value: v[i] } }));
3026
3027
  for (const l of ruleLits)
@@ -3234,7 +3235,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
3234
3235
  // bounds that leave the samples' rows out), blocked as the state's cubes are (its negation proven relative to the
3235
3236
  // set, the literals it doesn't need taken out): a law at every tuple of the view's keys. The disjunctions a hull
3236
3237
  // can't say (two waiting threads' tickets differ) are such cubes.
3237
- const viewSpaces = views.map(v => {
3238
+ const viewSpaces = noJoin ? [] : views.map(v => {
3238
3239
  const R = v.rows.slice(0, 3000).map(valuesOf), seen = new Set(R.map(vecKey)), mapOf = (i) => atoms[i].parts[0][0].slice(2, atoms[i].parts[0][0].lastIndexOf(AT));
3239
3240
  const own = v.atoms.filter(i => !atoms[i].int), few = own.filter(i => new Set(R.map(r => r[i])).size <= 3);
3240
3241
  const eqs = own.flatMap((i, a2) => own.slice(a2 + 1).filter(j => mapOf(i) === mapOf(j) && !few.includes(i)).flatMap(j => [{ lin: { coef: [[i, 1], [j, -1]], d: 0 } }, { lin: { coef: [[j, 1], [i, -1]], d: 0 } }]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdp-wired",
3
- "version": "0.59.0",
3
+ "version": "0.59.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",