gdp-wired 0.23.0 → 0.25.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 (47) hide show
  1. package/README.md +12 -2
  2. package/dist/core/accel.d.ts +44 -0
  3. package/dist/core/accel.js +720 -0
  4. package/dist/core/bmc.d.ts +13 -2
  5. package/dist/core/bmc.js +390 -18
  6. package/dist/core/cycles.d.ts +23 -0
  7. package/dist/core/cycles.js +527 -146
  8. package/dist/core/data.d.ts +17 -0
  9. package/dist/core/data.js +1177 -213
  10. package/dist/core/discover.js +8 -3
  11. package/dist/core/dsl.d.ts +7 -2
  12. package/dist/core/dsl.js +47 -9
  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.d.ts +1 -0
  28. package/dist/core/infer.js +298 -28
  29. package/dist/core/kind.d.ts +30 -0
  30. package/dist/core/kind.js +81 -0
  31. package/dist/core/nonterm.d.ts +4 -1
  32. package/dist/core/nonterm.js +98 -2
  33. package/dist/core/relation.js +82 -7
  34. package/dist/core/transfer.js +1 -1
  35. package/dist/core/xstate.d.ts +6 -0
  36. package/dist/core/xstate.js +70 -12
  37. package/dist/kernel/cdcl.d.ts +15 -0
  38. package/dist/kernel/cdcl.js +331 -244
  39. package/dist/kernel/kernel.d.ts +15 -0
  40. package/dist/kernel/kernel.js +32 -0
  41. package/dist/kernel/prove.js +20 -7
  42. package/dist/kernel/reader.d.ts +14 -0
  43. package/dist/kernel/reader.js +102 -14
  44. package/dist/lean-kernel/emit.d.ts +28 -1
  45. package/dist/lean-kernel/emit.js +56 -15
  46. package/dist/lean-kernel/library.js +2 -1
  47. package/package.json +12 -3
package/README.md CHANGED
@@ -68,7 +68,16 @@ All of these are proven automatically, and each proof is also a Lean theorem:
68
68
  - **XState machines** (`gdp-wired/xstate`): `fromXState(machine, {guards, actions})` builds the chart an XState v5
69
69
  machine runs as, with each guard and action it names given again in gdp-wired's terms, and `conforms(chart, machine,
70
70
  createActor)` drives XState's own actor and the compiled rule with the same random events, comparing every state and
71
- context; what a chart can't run the same way is refused when built, with the reason (`examples/xstate.ts`).
71
+ context; what a chart can't run the same way, and any key it doesn't read, is refused when built, with the reason
72
+ (`examples/xstate.ts`). A v4 machine's `cond` is read as its guard.
73
+ - **Rules read from the code** (`gdp-wired/extract`): `extract(code, {entry})` reads a reducer, `useReducer`'s, functions
74
+ over one record, or a class whose methods write its fields, and returns the rule that steps the same way, as a builder
75
+ value and as source to keep (`toSource`); `extractXState` reads an XState machine's guards and actions, named or
76
+ inline, for `fromXState`. The extractor is untrusted: each rule is run beside the code it was read from (requests
77
+ from the start, steps from drawn states and from the prover's counterexamples, every state, cell, result and refusal
78
+ compared, the code's branches counted), and a difference refuses it. Its subset (integers, booleans, string-literal
79
+ unions, records, Map and Record keyed state, branches and early returns, throws as refusals, `Date.now()` as an
80
+ input) and what it refuses, each with the place and the reason, are in `core/extract.ts`.
72
81
  - **What nobody stated, looked for when the prover alone stops**: where `proveRule` or `proveSteps` doesn't prove the laws
73
82
  and no run breaks them, it looks for lemmas about the rule's recurrences and lists (`discover`), lemmas about the
74
83
  functions it knows by their facts (`cycleLemmas`, each proven by a cyclic proof) and then invariants (`inferLaws`),
@@ -455,7 +464,8 @@ The npm package is built from `core/`, `kernel/` and `lean-kernel/` alone; nothi
455
464
  ## Running
456
465
 
457
466
  The npm package is the library: the builders (`gdp-wired`), the runtimes (`gdp-wired/machine`), composition
458
- (`gdp-wired/compose`), XState machines as charts (`gdp-wired/xstate`), lemmas nobody stated (`gdp-wired/discover`), invariant
467
+ (`gdp-wired/compose`), XState machines as charts (`gdp-wired/xstate`), rules read from the code (`gdp-wired/extract`, with
468
+ `typescript` installed), lemmas nobody stated (`gdp-wired/discover`), invariant
459
469
  inference (`gdp-wired/infer`), the
460
470
  Lean export (`gdp-wired/lean`), the kernel (`gdp-wired/kernel`), the prover (`gdp-wired/prove`), the derivation checker
461
471
  and solver (`gdp-wired/check`, `gdp-wired/solver`). Everything else here (examples, comparisons, the Lean twin, the GPU
@@ -0,0 +1,44 @@
1
+ import type { C, E } from './machine.js';
2
+ import type { Loop } from '../kernel/kernel.js';
3
+ import { type Lin } from './solver.js';
4
+ export type Target = {
5
+ loc: number;
6
+ rows: Lin[];
7
+ };
8
+ export type Accelerated = {
9
+ set: C;
10
+ wit: Record<string, E>;
11
+ cycle: number[];
12
+ locs: number[];
13
+ targets: Target[];
14
+ };
15
+ export type AccelOptions = {
16
+ now: () => number;
17
+ until: number;
18
+ maxLen?: number;
19
+ maxCycles?: number;
20
+ runs?: {
21
+ params: Record<string, number>;
22
+ inputs: Record<string, number>[];
23
+ }[];
24
+ io?: StemIO;
25
+ };
26
+ export declare function accelerated(l: Loop, opts: AccelOptions): Generator<Accelerated>;
27
+ type Env = Record<string, number>;
28
+ export type StemIO = {
29
+ start: (params: Env) => Env;
30
+ turn: (st: Env, input: Env) => Env | undefined;
31
+ };
32
+ export declare function stemsTo(l: Loop, targets: Target[], io: StemIO, opts: {
33
+ now: () => number;
34
+ until: number;
35
+ depth?: number;
36
+ calls?: number;
37
+ report?: {
38
+ exhausted: boolean;
39
+ };
40
+ }): Generator<{
41
+ params: Env;
42
+ stem: Env[];
43
+ }>;
44
+ export {};