gdp-wired 0.25.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 +1 -1
- package/dist/core/accel.js +336 -101
- 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 +35 -131
- package/dist/core/cyclic.d.ts +4 -1
- package/dist/core/cyclic.js +86 -64
- package/dist/core/data.d.ts +1 -1
- package/dist/core/data.js +89 -118
- 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.js +72 -18
- package/dist/core/machine.d.ts +6 -0
- package/dist/core/machine.js +35 -3
- package/dist/core/nonterm.d.ts +5 -1
- package/dist/core/nonterm.js +109 -41
- 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 +20 -36
- package/dist/core/solver.d.ts +12 -0
- package/dist/core/solver.js +76 -30
- package/dist/core/transfer.js +22 -13
- 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.js +1 -2
- package/dist/kernel/prove.d.ts +6 -1
- package/dist/kernel/prove.js +96 -82
- 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
|
@@ -221,6 +221,12 @@ export function sortsOf(m, given = {}) {
|
|
|
221
221
|
sorts.set(v.name, given[v.name] ?? 'nat');
|
|
222
222
|
for (const c of cellNums)
|
|
223
223
|
sorts.set(c, given[c] ?? 'nat');
|
|
224
|
+
// A list's length is a natural; its items naturals until one written may be below 0.
|
|
225
|
+
for (const d of m.lists ?? []) {
|
|
226
|
+
sorts.set(`${d.name}_len`, 'nat');
|
|
227
|
+
if (d.fields[0].sort.k === 'num')
|
|
228
|
+
sorts.set(`${d.name}.$item`, given[`${d.name}.$item`] ?? 'nat');
|
|
229
|
+
}
|
|
224
230
|
for (let changed = true; changed;) {
|
|
225
231
|
changed = false;
|
|
226
232
|
for (const v of nums(m.state)) {
|
|
@@ -242,6 +248,15 @@ export function sortsOf(m, given = {}) {
|
|
|
242
248
|
changed = true;
|
|
243
249
|
}
|
|
244
250
|
}
|
|
251
|
+
for (const d of m.lists ?? []) {
|
|
252
|
+
const n = `${d.name}.$item`;
|
|
253
|
+
if (d.fields[0].sort.k !== 'num' || sorts.get(n) === 'int' || given[n])
|
|
254
|
+
continue;
|
|
255
|
+
if ((m.listWrites?.[d.name] ?? []).some(o => o.op !== 'pop' && o.x.s === 'num' && !natOK(o.x.e, withAtom(ctx0(), o.when)))) {
|
|
256
|
+
sorts.set(n, 'int');
|
|
257
|
+
changed = true;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
245
260
|
}
|
|
246
261
|
for (const v of nums(m.state))
|
|
247
262
|
if (sorts.get(v.name) === 'int')
|
|
@@ -310,7 +325,7 @@ function pn(e, P, ctx, mode, recv = false) {
|
|
|
310
325
|
return `when(${pb(e.c, P, ctx)}, ${side(e.a, ca)}, ${side(e.b, cb)})`;
|
|
311
326
|
}
|
|
312
327
|
case 'cell': {
|
|
313
|
-
const v =
|
|
328
|
+
const v = cellText(e, P, ctx);
|
|
314
329
|
return !nat && recv && P.sorts.get(`${e.map}.${e.field}`) === 'nat' ? `Int.of(${v})` : v;
|
|
315
330
|
}
|
|
316
331
|
}
|
|
@@ -355,9 +370,17 @@ export function pb(c, P, ctx) {
|
|
|
355
370
|
const s = (k) => (k.op === 'svar' ? k.name : k.op === 'slit' ? q(k.value) : pk(k, P, ctx));
|
|
356
371
|
return c.a.op === 'svar' ? `${c.a.name}.eq(${s(c.b)})` : c.b.op === 'svar' ? `${c.b.name}.eq(${s(c.a)})` : `${pk(c.a, P, ctx)}.eq(${pk(c.b, P, ctx)})`;
|
|
357
372
|
}
|
|
358
|
-
case 'cell': return
|
|
373
|
+
case 'cell': return cellText(c, P, ctx);
|
|
359
374
|
}
|
|
360
375
|
}
|
|
376
|
+
// A map's cell field, or a list's item (read where the index is within it: an integer index is at least 0 there).
|
|
377
|
+
function cellText(c, P, ctx) {
|
|
378
|
+
if (c.field !== '$item')
|
|
379
|
+
return `${c.map}.at(${pk(c.key, P, ctx)}).${c.field}`;
|
|
380
|
+
return `${c.map}.at(${c.key.op === 'num' ? pidx(c.key.e, P, ctx) : pk(c.key, P, ctx)})`;
|
|
381
|
+
}
|
|
382
|
+
// A list's index, where it is read or set within the list: a natural, or an integer clamped at 0 (the same there).
|
|
383
|
+
export const pidx = (i, P, ctx) => (natOK(i, ctx) ? pn(i, P, ctx, 'nat') : `${pn(i, P, ctx, 'int', true)}.clamped`);
|
|
361
384
|
// A choice: a literal is written as the choice's own value where nothing else gives the choice (`status.of('open')`).
|
|
362
385
|
export function pl(l, P, ctx, bare = false) {
|
|
363
386
|
switch (l.op) {
|
|
@@ -371,7 +394,7 @@ export function pl(l, P, ctx, bare = false) {
|
|
|
371
394
|
return `${w}.of(${q(l.value)})`;
|
|
372
395
|
}
|
|
373
396
|
case 'ite': return `when(${pb(l.c, P, ctx)}, ${pl(l.a, P, ctx, l.b.op !== 'lit')}, ${pl(l.b, P, ctx, l.a.op !== 'lit' || l.b.op !== 'lit' ? l.a.op !== 'lit' : false)})`;
|
|
374
|
-
case 'cell': return
|
|
397
|
+
case 'cell': return cellText(l, P, ctx);
|
|
375
398
|
}
|
|
376
399
|
}
|
|
377
400
|
export function pk(k, P, ctx) {
|
|
@@ -12,6 +12,7 @@ export declare class Retype extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
export type Sort = {
|
|
14
14
|
k: 'num';
|
|
15
|
+
date?: true;
|
|
15
16
|
} | {
|
|
16
17
|
k: 'bool';
|
|
17
18
|
} | {
|
|
@@ -28,6 +29,9 @@ export type Shape = Sort | {
|
|
|
28
29
|
key: 'num' | 'str';
|
|
29
30
|
val: Shape;
|
|
30
31
|
js: 'Map' | 'record';
|
|
32
|
+
} | {
|
|
33
|
+
k: 'list';
|
|
34
|
+
of: Sort;
|
|
31
35
|
};
|
|
32
36
|
export type Var = {
|
|
33
37
|
name: string;
|
|
@@ -52,6 +56,9 @@ export type Layout = {
|
|
|
52
56
|
} | {
|
|
53
57
|
k: 'map';
|
|
54
58
|
name: string;
|
|
59
|
+
} | {
|
|
60
|
+
k: 'list';
|
|
61
|
+
name: string;
|
|
55
62
|
} | {
|
|
56
63
|
k: 'const';
|
|
57
64
|
value: Term;
|
|
@@ -94,6 +101,32 @@ export type MapWrite = {
|
|
|
94
101
|
has: B;
|
|
95
102
|
vals: Record<string, Term>;
|
|
96
103
|
};
|
|
104
|
+
export type ListOp = {
|
|
105
|
+
op: 'push';
|
|
106
|
+
x: V;
|
|
107
|
+
when: B;
|
|
108
|
+
} | {
|
|
109
|
+
op: 'pop';
|
|
110
|
+
when: B;
|
|
111
|
+
} | {
|
|
112
|
+
op: 'set';
|
|
113
|
+
i: N;
|
|
114
|
+
x: V;
|
|
115
|
+
when: B;
|
|
116
|
+
};
|
|
117
|
+
export type ListWrite = ({
|
|
118
|
+
op: 'push';
|
|
119
|
+
x: Term;
|
|
120
|
+
when: B;
|
|
121
|
+
} | {
|
|
122
|
+
op: 'pop';
|
|
123
|
+
when: B;
|
|
124
|
+
} | {
|
|
125
|
+
op: 'set';
|
|
126
|
+
i: N;
|
|
127
|
+
x: Term;
|
|
128
|
+
when: B;
|
|
129
|
+
})[];
|
|
97
130
|
export type Model = {
|
|
98
131
|
name: string;
|
|
99
132
|
shape: 'reducer' | 'functions' | 'class';
|
|
@@ -108,6 +141,8 @@ export type Model = {
|
|
|
108
141
|
writes: Record<string, Term>;
|
|
109
142
|
mapWrites: Record<string, MapWrite>;
|
|
110
143
|
outputs: string[];
|
|
144
|
+
lists?: MapDecl[];
|
|
145
|
+
listWrites?: Record<string, ListWrite>;
|
|
111
146
|
refuse: B;
|
|
112
147
|
pre: B;
|
|
113
148
|
layout: Layout;
|
|
@@ -121,6 +156,22 @@ export type Model = {
|
|
|
121
156
|
}>;
|
|
122
157
|
initSource?: string;
|
|
123
158
|
spans?: [number, number][];
|
|
159
|
+
factory?: {
|
|
160
|
+
at: number;
|
|
161
|
+
text: string;
|
|
162
|
+
};
|
|
163
|
+
results?: Record<string, {
|
|
164
|
+
k: 'scalar';
|
|
165
|
+
name: string;
|
|
166
|
+
} | {
|
|
167
|
+
k: 'rec';
|
|
168
|
+
fields: [string, string][];
|
|
169
|
+
} | {
|
|
170
|
+
k: 'maybe';
|
|
171
|
+
name: string;
|
|
172
|
+
missing: string;
|
|
173
|
+
null: boolean;
|
|
174
|
+
}>;
|
|
124
175
|
};
|
|
125
176
|
type V = {
|
|
126
177
|
t: 'num';
|
|
@@ -147,8 +198,16 @@ type V = {
|
|
|
147
198
|
t: 'opt';
|
|
148
199
|
has: B;
|
|
149
200
|
v: V;
|
|
201
|
+
null?: true;
|
|
150
202
|
} | {
|
|
151
203
|
t: 'undef';
|
|
204
|
+
null?: true;
|
|
205
|
+
} | {
|
|
206
|
+
t: 'outside';
|
|
207
|
+
path: string;
|
|
208
|
+
} | {
|
|
209
|
+
t: 'opaque';
|
|
210
|
+
what: string;
|
|
152
211
|
} | {
|
|
153
212
|
t: 'phi';
|
|
154
213
|
c: B;
|
|
@@ -175,7 +234,14 @@ type MapObj = {
|
|
|
175
234
|
origin: 'fresh' | 'input' | 'this' | 'shared';
|
|
176
235
|
gen: number;
|
|
177
236
|
};
|
|
178
|
-
type
|
|
237
|
+
type ListObj = {
|
|
238
|
+
k: 'list';
|
|
239
|
+
base: string;
|
|
240
|
+
decl: MapDecl;
|
|
241
|
+
ops: ListOp[];
|
|
242
|
+
origin: 'fresh' | 'input' | 'this' | 'shared';
|
|
243
|
+
};
|
|
244
|
+
type Obj = Rec | MapObj | ListObj | {
|
|
179
245
|
k: 'alias';
|
|
180
246
|
to: V;
|
|
181
247
|
};
|
|
@@ -210,8 +276,11 @@ export type Setup = {
|
|
|
210
276
|
names: Set<string>;
|
|
211
277
|
vars: Map<string, Var>;
|
|
212
278
|
maps: Map<string, MapDecl>;
|
|
279
|
+
lists?: Map<string, MapDecl>;
|
|
213
280
|
lazySorts: Map<string, Sort>;
|
|
214
281
|
cls?: ts.ClassLikeDeclaration;
|
|
282
|
+
chain?: ts.ClassLikeDeclaration[];
|
|
283
|
+
closure?: Set<ts.Node>;
|
|
215
284
|
now?: string;
|
|
216
285
|
nowRole: 'input' | 'param';
|
|
217
286
|
hints: WeakMap<object, string>;
|
|
@@ -223,6 +292,12 @@ export type Setup = {
|
|
|
223
292
|
ctor?: boolean;
|
|
224
293
|
ours: (sf: ts.SourceFile) => boolean;
|
|
225
294
|
spans?: [number, number][];
|
|
295
|
+
xstate?: {
|
|
296
|
+
outside: Map<string, {
|
|
297
|
+
path: string;
|
|
298
|
+
sort: Sort;
|
|
299
|
+
}>;
|
|
300
|
+
};
|
|
226
301
|
};
|
|
227
302
|
export declare class Exec {
|
|
228
303
|
readonly s: Setup;
|
|
@@ -262,7 +337,7 @@ export declare class Exec {
|
|
|
262
337
|
truthy(v: V, at: ts.Node): B;
|
|
263
338
|
num(v: V, at: ts.Node, p: Path): N;
|
|
264
339
|
private bool;
|
|
265
|
-
equal(a: V, b: V, at: ts.Node): B;
|
|
340
|
+
equal(a: V, b: V, at: ts.Node, loose?: boolean): B;
|
|
266
341
|
ev(e: ts.Expression, p: Path): [V, Path];
|
|
267
342
|
private joinValues;
|
|
268
343
|
private name;
|
|
@@ -283,16 +358,22 @@ export declare class Exec {
|
|
|
283
358
|
private mapId;
|
|
284
359
|
mapSet(id: string, key: K, v: V | undefined, at: ts.Node, p: Path, track?: boolean): Path;
|
|
285
360
|
private cellValue;
|
|
286
|
-
assign(target: ts.Expression, v: V, p: Path): Path;
|
|
361
|
+
assign(target: ts.Expression, v: V, p: Path, setTime?: boolean): Path;
|
|
287
362
|
private writeField;
|
|
288
363
|
resolved(e: ts.Node): ts.Symbol | undefined;
|
|
289
364
|
private args;
|
|
290
365
|
private call;
|
|
366
|
+
private outside;
|
|
367
|
+
private listLen;
|
|
368
|
+
private listOp;
|
|
369
|
+
private array;
|
|
370
|
+
member(name: string, from?: number): ts.ClassElement | undefined;
|
|
291
371
|
private math;
|
|
292
372
|
private now;
|
|
293
373
|
private newExpr;
|
|
294
374
|
inline(f: Callable, args: V[], at: ts.Node, p: Path): [V, Path];
|
|
295
375
|
}
|
|
376
|
+
export declare const isDate: (t: ts.Type) => boolean;
|
|
296
377
|
export declare const memberName: (n: ts.PropertyName | ts.MemberName) => string;
|
|
297
378
|
export declare function impure(e: ts.Node): boolean;
|
|
298
|
-
export type { V, Path, Rec, MapObj, Heap, Flow };
|
|
379
|
+
export type { V, Path, Rec, MapObj, ListObj, Heap, Flow };
|