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
@@ -1,30 +1,43 @@
1
1
  const vars = (lin) => Object.keys(lin).filter(key => key !== '1');
2
- export function checkRefutation(constraints, steps) {
3
- const rows = [];
2
+ const exact = (lin) => Object.values(lin).every(c => Number.isSafeInteger(c));
3
+ export function checkRefutation(constraints, steps, integral = true) {
4
+ const rows = [], strict = [];
4
5
  for (const [i, s] of steps.entries()) {
5
6
  if (s.kind === 'input') {
6
- if (!(s.index >= 0 && s.index < constraints.length))
7
+ if (!(Number.isInteger(s.index) && s.index >= 0 && s.index < constraints.length))
7
8
  return false;
8
- rows.push(constraints[s.index].lin);
9
+ const c = constraints[s.index];
10
+ if (!integral && !exact(c.lin))
11
+ return false;
12
+ rows.push(c.lin);
13
+ strict.push(!integral && c.strict === true);
9
14
  }
10
15
  else if (s.kind === 'combine') {
11
16
  if (!(s.a < i && s.b < i && Number.isInteger(s.ma) && Number.isInteger(s.mb) && s.ma > 0 && s.mb > 0))
12
17
  return false;
18
+ if (!integral && !(Number.isInteger(s.a) && Number.isInteger(s.b) && s.a >= 0 && s.b >= 0))
19
+ return false;
13
20
  const out = {};
14
21
  for (const [lin, m] of [[rows[s.a], s.ma], [rows[s.b], s.mb]])
15
22
  for (const [key, c] of Object.entries(lin))
16
23
  out[key] = (out[key] ?? 0) + m * c;
24
+ if (!integral && !exact(out))
25
+ return false;
17
26
  rows.push(out);
27
+ strict.push(strict[s.a] || strict[s.b]);
18
28
  }
19
29
  else {
30
+ if (!integral)
31
+ return false;
20
32
  const row = rows[s.of];
21
33
  if (!(row !== undefined && s.of < i && Number.isInteger(s.g) && s.g > 0 && vars(row).every(key => row[key] % s.g === 0)))
22
34
  return false;
23
35
  rows.push({ ...Object.fromEntries(vars(row).map(key => [key, row[key] / s.g])), 1: Math.ceil((row['1'] ?? 0) / s.g) });
36
+ strict.push(false);
24
37
  }
25
38
  }
26
- const last = rows.at(-1);
27
- return last !== undefined && vars(last).every(key => last[key] === 0) && (last['1'] ?? 0) > 0;
39
+ const last = rows.at(-1), constant = last?.['1'] ?? 0;
40
+ return last !== undefined && vars(last).every(key => last[key] === 0) && (constant > 0 || (strict.at(-1) && constant >= 0));
28
41
  }
29
42
  export function checkWitness(constraints, witness) {
30
43
  return constraints.every(c => Object.entries(c.lin).reduce((sum, [key, a]) => sum + a * (key === '1' ? 1 : (witness[key] ?? NaN)), 0) <= 0);
@@ -2,6 +2,8 @@ import type { C, E, Law, Machine, Request } from './machine.js';
2
2
  import type { Liveness, Loop, Tree } from '../kernel/kernel.js';
3
3
  import { type Cyclic, type Fact } from '../kernel/cyclic.js';
4
4
  import { type NodeSpec } from './cyclic.js';
5
+ import { type Lin } from './solver.js';
6
+ import { type Relation } from './relation.js';
5
7
  import type { StepLaw } from '../kernel/kernel.js';
6
8
  export type Claim = {
7
9
  name: string;
@@ -48,8 +50,44 @@ export declare function ranksOfRuns(vars: string[], points: Env[], edges: {
48
50
  }[];
49
51
  left: number;
50
52
  };
53
+ export declare function ranksOfCalls(nodes: string[][], points: {
54
+ node: number;
55
+ env: Env;
56
+ }[], edges: {
57
+ from: number;
58
+ to: number;
59
+ s: Env;
60
+ t: Env;
61
+ }[], ms?: number): {
62
+ comps: {
63
+ coef: Record<string, number>;
64
+ c: number;
65
+ }[][];
66
+ left: number;
67
+ };
51
68
  export declare function claimInstances(facts: Fact[], claim: Claim, depth?: number): NodeSpec['insts'];
52
69
  export declare function findCycles(facts: Fact[], claims: Claim[], opts?: CycleOptions): CycleVerdict;
70
+ export declare function rankOfRelation(l: Loop, laws: Law[], until: number): {
71
+ rank: E[];
72
+ text: string;
73
+ blocks: number[];
74
+ } | {
75
+ why: string;
76
+ };
77
+ export declare function rankOfPaths(name: string, rel: Relation, until: number): {
78
+ forms: Lin[][];
79
+ values: number[];
80
+ } | {
81
+ why: string;
82
+ };
83
+ export declare function rankWithInvariants(l: Loop, laws: Law[], until: number): {
84
+ rank: E[];
85
+ text: string;
86
+ laws: Law[];
87
+ texts: string[];
88
+ } | {
89
+ why: string;
90
+ };
53
91
  export type RankVerdict = {
54
92
  proven: boolean;
55
93
  checked: boolean;