gdp-wired 0.24.0 → 0.26.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.
- package/README.md +14 -9
- package/dist/core/accel.d.ts +44 -0
- package/dist/core/accel.js +955 -0
- package/dist/core/bmc.d.ts +8 -0
- package/dist/core/bmc.js +263 -97
- package/dist/core/cycles.d.ts +2 -3
- package/dist/core/cycles.js +409 -174
- package/dist/core/cyclic.d.ts +4 -1
- package/dist/core/cyclic.js +86 -64
- package/dist/core/data.d.ts +9 -1
- package/dist/core/data.js +872 -168
- package/dist/core/discover.js +2 -3
- package/dist/core/dsl.d.ts +3 -2
- package/dist/core/dsl.js +21 -18
- package/dist/core/exists.js +7 -14
- package/dist/core/extract-check.d.ts +3 -2
- package/dist/core/extract-check.js +137 -50
- package/dist/core/extract-print.d.ts +1 -0
- package/dist/core/extract-print.js +26 -3
- package/dist/core/extract-read.d.ts +85 -4
- package/dist/core/extract-read.js +295 -34
- package/dist/core/extract-shapes.d.ts +14 -0
- package/dist/core/extract-shapes.js +608 -78
- package/dist/core/extract-xstate.d.ts +5 -1
- package/dist/core/extract-xstate.js +618 -184
- package/dist/core/extract.js +73 -27
- package/dist/core/infer.d.ts +1 -0
- package/dist/core/infer.js +364 -40
- package/dist/core/machine.d.ts +6 -0
- package/dist/core/machine.js +35 -3
- package/dist/core/nonterm.d.ts +9 -2
- package/dist/core/nonterm.js +173 -9
- package/dist/core/q.d.ts +1 -0
- package/dist/core/q.js +2 -2
- package/dist/core/relation.d.ts +1 -0
- package/dist/core/relation.js +95 -39
- package/dist/core/solver.d.ts +12 -0
- package/dist/core/solver.js +76 -30
- package/dist/core/transfer.js +23 -14
- package/dist/core/translate.d.ts +1 -1
- package/dist/core/translate.js +22 -49
- package/dist/core/xstate.d.ts +6 -1
- package/dist/core/xstate.js +336 -55
- package/dist/kernel/cdcl.d.ts +5 -0
- package/dist/kernel/cdcl.js +44 -8
- package/dist/kernel/prove.d.ts +6 -1
- package/dist/kernel/prove.js +101 -85
- package/dist/kernel/reader.d.ts +1 -0
- package/dist/kernel/reader.js +4 -3
- package/dist/kernel/simplex.d.ts +1 -1
- package/dist/kernel/simplex.js +13 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -63,21 +63,26 @@ All of these are proven automatically, and each proof is also a Lean theorem:
|
|
|
63
63
|
- **Statecharts**: `chart(name).states({...}).on(event, {from, to, when, set})`, with states nested to any depth,
|
|
64
64
|
parallel regions (at the top of the chart), a compound's history (deep), guards and extended state, compiled to a rule;
|
|
65
65
|
`check()` shows every state reached by a run (or proves it unreachable), no state stuck and no event ambiguous, and its
|
|
66
|
-
laws prove like any rule's (`examples/charts.ts`). Not yet: parallel regions inside a state
|
|
67
|
-
eventless and delayed transitions.
|
|
66
|
+
laws prove like any rule's (`examples/charts.ts`). Not yet: parallel regions inside a state (XState's entry and exit
|
|
67
|
+
actions, eventless and delayed transitions are read by `fromXState`, below).
|
|
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
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.
|
|
72
|
+
(`examples/xstate.ts`). A v4 machine's `cond` is read as its guard. An invoked actor's done and error and a timer
|
|
73
|
+
firing are events from outside, taken only where they can come (each once a visit; one timer at a time), and
|
|
74
|
+
eventless transitions and entry and exit actions that write the context are read into each transition as XState's
|
|
75
|
+
macrostep.
|
|
73
76
|
- **Rules read from the code** (`gdp-wired/extract`): `extract(code, {entry})` reads a reducer, `useReducer`'s, functions
|
|
74
|
-
over one record,
|
|
75
|
-
|
|
77
|
+
over one record, a class whose methods write its fields (with the classes it extends), or the object of functions a
|
|
78
|
+
factory returns, and returns the rule that steps the same way, as a builder value and as source to keep
|
|
79
|
+
(`toSource`); `extractXState` reads an XState machine, or a function that makes one, its guards and actions named or
|
|
76
80
|
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
|
|
78
|
-
compared, the code's branches counted), and a difference refuses it. Its subset (integers, booleans,
|
|
79
|
-
unions, records, Map and Record keyed state,
|
|
80
|
-
|
|
81
|
+
from the start, steps from drawn states and from the prover's counterexamples, every state, cell, list, result and
|
|
82
|
+
refusal compared, the code's branches counted), and a difference refuses it. Its subset (integers, booleans, strings
|
|
83
|
+
and string-literal unions, values that may be null, records, Map and Record keyed state, arrays as lists, Dates as
|
|
84
|
+
their time, branches and early returns, throws as refusals, `Date.now()` as an input) and what it refuses, each with
|
|
85
|
+
the place and the reason, are in `core/extract.ts`.
|
|
81
86
|
- **What nobody stated, looked for when the prover alone stops**: where `proveRule` or `proveSteps` doesn't prove the laws
|
|
82
87
|
and no run breaks them, it looks for lemmas about the rule's recurrences and lists (`discover`), lemmas about the
|
|
83
88
|
functions it knows by their facts (`cycleLemmas`, each proven by a cyclic proof) and then invariants (`inferLaws`),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type C, type 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 {};
|