eutaxy 0.5.1 → 0.6.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 (32) hide show
  1. package/README.md +96 -12
  2. package/dist/aws.mjs +5 -5
  3. package/dist/bin.mjs +2 -2
  4. package/dist/{checksum-DhS6ofSm.mjs → checksum-DHr5qb3Y.mjs} +2 -2
  5. package/dist/{checksum-DhS6ofSm.mjs.map → checksum-DHr5qb3Y.mjs.map} +1 -1
  6. package/dist/cli-CsiVEsS-.mjs +2 -0
  7. package/dist/cli.d.mts.map +1 -1
  8. package/dist/cli.mjs +2 -2
  9. package/dist/cloudflare.d.mts +2 -4
  10. package/dist/cloudflare.d.mts.map +1 -1
  11. package/dist/cloudflare.mjs +2 -2
  12. package/dist/{delivery-invariants-Cuxdna28.mjs → delivery-invariants-hmhwh_qD.mjs} +2 -2
  13. package/dist/{delivery-invariants-Cuxdna28.mjs.map → delivery-invariants-hmhwh_qD.mjs.map} +1 -1
  14. package/dist/{event-streams-BANyO9xt.mjs → event-streams-i8OGzuFN.mjs} +2 -2
  15. package/dist/{event-streams-BANyO9xt.mjs.map → event-streams-i8OGzuFN.mjs.map} +1 -1
  16. package/dist/{checked-CGpA2-F0.d.mts → explore-CDpJA9zX.d.mts} +118 -61
  17. package/dist/explore-CDpJA9zX.d.mts.map +1 -0
  18. package/dist/index.d.mts +76 -20
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +19 -20
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/{src-Bqc9Eyb1.mjs → src-BO7I3f-1.mjs} +2 -2
  23. package/dist/{src-Bqc9Eyb1.mjs.map → src-BO7I3f-1.mjs.map} +1 -1
  24. package/dist/{src-DKb-fkdb.mjs → src-C43iUZgr.mjs} +1650 -10
  25. package/dist/src-C43iUZgr.mjs.map +1 -0
  26. package/dist/{src-Dxl9ZlKn.mjs → src-Cs4Mg55e.mjs} +957 -37
  27. package/dist/src-Cs4Mg55e.mjs.map +1 -0
  28. package/package.json +16 -1
  29. package/dist/checked-CGpA2-F0.d.mts.map +0 -1
  30. package/dist/cli-IJrKkeYS.mjs +0 -2
  31. package/dist/src-DKb-fkdb.mjs.map +0 -1
  32. package/dist/src-Dxl9ZlKn.mjs.map +0 -1
@@ -1,9 +1,10 @@
1
1
  import { D as EffectLog, f as Schedule, g as Violation, n as Platform, o as ScenarioSpec, r as Bounds } from "./platform-DfMwknw1.mjs";
2
2
  /**
3
3
  * Spec verdicts: what is known about one property of one pure function.
4
- * Kept apart from scenario verdicts in every report. The ladder starts at
5
- * `CHECKED` (held on every input the simulator passed); `TESTED` and
6
- * `PROVEN` come with the provers.
4
+ * Kept apart from scenario verdicts in every report. The ladder runs
5
+ * `CHECKED` (held on every input the simulator passed), then `TESTED` (held
6
+ * on inputs generated from the binders' domains), then `PROVEN` (an engine
7
+ * proved it for every input); `CONFLICT` when engines disagree.
7
8
  */
8
9
  interface SpecVerdictBase {
9
10
  /** The module, as the scenario names it. */
@@ -22,29 +23,73 @@ interface Checked extends SpecVerdictBase {
22
23
  /** Distinct inputs outside the claim: a precondition failed, or a value fell outside its binder's domain. */
23
24
  readonly discarded: number;
24
25
  }
25
- /** One assignment that breaks the property, as JavaScript literals, and the call it came from. */
26
+ /** The property held on inputs generated from its binders' domains, and on the simulator's where it passed any. */
27
+ interface Tested extends SpecVerdictBase {
28
+ readonly kind: "TESTED";
29
+ /** Generated assignments the property held on. */
30
+ readonly inputs: number;
31
+ /** Generated assignments outside the claim: a precondition failed. */
32
+ readonly discarded: number;
33
+ /** The seed the assignments were drawn from; the same seed draws the same assignments. */
34
+ readonly seed: string;
35
+ /** Distinct inputs the simulator passed that the property also held on, when it passed any. */
36
+ readonly checked?: number;
37
+ }
38
+ /** One assignment that breaks the property, as JavaScript literals, and where it came from. */
26
39
  interface Counterexample {
27
40
  /** In the property's binder order. */
28
41
  readonly binders: readonly {
29
42
  readonly name: string;
30
43
  readonly value: string;
31
44
  }[];
32
- readonly call: string;
45
+ /** The simulator's call the assignment was taken from; absent when it was generated. */
46
+ readonly call?: string;
33
47
  /** Set when evaluating the property threw instead of returning false. */
34
48
  readonly error?: string;
35
49
  }
36
50
  interface Refuted extends SpecVerdictBase {
37
51
  readonly kind: "REFUTED";
38
- readonly rung: "CHECKED";
52
+ /** The rung that found the counterexample: a rung of the simulator, or an engine by name. */
53
+ readonly rung: "CHECKED" | "TESTED" | "PROVEN";
54
+ /** The engine, when the rung is PROVEN. */
55
+ readonly engine?: {
56
+ readonly name: string;
57
+ readonly version: string;
58
+ };
39
59
  readonly counterexample: Counterexample;
40
60
  }
61
+ /** Proved for every input by a named engine; the lower rungs' evidence is kept beside it. */
62
+ interface Proven extends SpecVerdictBase {
63
+ readonly kind: "PROVEN";
64
+ readonly engine: {
65
+ readonly name: string;
66
+ readonly version: string;
67
+ };
68
+ /** Generated inputs the TESTED rung held on, when it ran. */
69
+ readonly tested?: number;
70
+ /** Distinct inputs the simulator passed that the CHECKED rung held on, when it passed any. */
71
+ readonly checked?: number;
72
+ }
73
+ /** Two engines disagree: one proves, one refutes. Never resolved automatically. */
74
+ interface Conflict extends SpecVerdictBase {
75
+ readonly kind: "CONFLICT";
76
+ readonly proven: {
77
+ readonly name: string;
78
+ readonly version: string;
79
+ };
80
+ readonly refuted: {
81
+ readonly name: string;
82
+ readonly version: string;
83
+ readonly counterexample?: Counterexample;
84
+ };
85
+ }
41
86
  type SpecUnknownCause = "gave_up" | "unsupported" | "unavailable";
42
87
  interface SpecUnknown extends SpecVerdictBase {
43
88
  readonly kind: "UNKNOWN";
44
89
  readonly cause: SpecUnknownCause;
45
90
  readonly reason: string;
46
91
  }
47
- type SpecVerdict = Checked | Refuted | SpecUnknown;
92
+ type SpecVerdict = Checked | Tested | Proven | Refuted | Conflict | SpecUnknown;
48
93
  /** One line per spec verdict, for error messages; full rendering lives in `report`. */
49
94
  declare function describeSpecVerdict(v: SpecVerdict): string;
50
95
  interface BoundsReached {
@@ -98,49 +143,6 @@ interface Unsupported extends VerdictBase {
98
143
  type ScenarioVerdict = Violated | Bounded | Unsupported;
99
144
  /** One line per verdict, for error messages; full rendering lives in `report`. */
100
145
  declare function describeVerdict(v: ScenarioVerdict): string;
101
- interface ExploreOptions {
102
- readonly seed: number | string;
103
- /** Hard cap on runs, in addition to the scenario's time budget. */
104
- readonly maxRuns?: number;
105
- /**
106
- * Replaces the scenario's `budgetMs` for this exploration: the real time
107
- * exploring and shrinking may take, and the real time one effect's I/O
108
- * may take before it counts as hung. With a generous budget and
109
- * `maxRuns`, the run cap ends exploration, so a seed decides the verdict
110
- * on any machine.
111
- */
112
- readonly budgetMs?: number;
113
- /**
114
- * The share of seeded runs after the first (which injects none) that
115
- * inject faults (see `planFaults`). Default 0.9: the runs without faults
116
- * also check the scenario as it runs without them, and measure how many
117
- * eligible points a run without faults has, which can vary with the seed.
118
- */
119
- readonly faultProbability?: number;
120
- /** Clock for the time budget; injectable for tests. */
121
- readonly now?: () => number;
122
- /** Hard cap on replay runs spent shrinking a violation. */
123
- readonly maxShrinkRuns?: number;
124
- /**
125
- * How many of the first exploration runs to replay in reverse order
126
- * before reporting BOUNDED, to detect module-level state leaking between
127
- * runs. 0 disables the pass.
128
- */
129
- readonly leakCheckRuns?: number;
130
- /**
131
- * Explore every schedule within the bounds, each once, instead of drawing
132
- * schedules from the seed: every fault (or none) at every effect point
133
- * that may still take one, and every order of turns. With `reduction`
134
- * (the default), turns of different invocations on different targets
135
- * commute and only one order of them is run.
136
- */
137
- readonly exhaustive?: boolean | {
138
- readonly reduction?: boolean;
139
- };
140
- }
141
- /** Re-run a recorded schedule exactly. */
142
- declare function replay(spec: ScenarioSpec, platform: Platform, schedule: Schedule): Promise<EffectLog>;
143
- declare function explore(scenario: ScenarioSpec, platform: Platform, options: ExploreOptions): Promise<ScenarioVerdict>;
144
146
  /**
145
147
  * SpecIR: function specs as plain data. The surface syntax is Lemma
146
148
  * (https://github.com/jessealama/lemma-lang, grammar.ebnf and
@@ -233,6 +235,8 @@ interface FunctionSpec {
233
235
  readonly throws: boolean;
234
236
  /** 1-based line of the declaration. */
235
237
  readonly line: number;
238
+ /** Offset in the source of the `(` opening the parameters: the declaration's identity, for tools that read the module themselves. */
239
+ readonly offset: number;
236
240
  }
237
241
  /** A problem with an annotation, located in the module. */
238
242
  interface SpecError {
@@ -265,21 +269,74 @@ interface CheckedInput {
265
269
  readonly unobservable?: string;
266
270
  }
267
271
  declare function checkedRung(input: CheckedInput): SpecVerdict;
272
+ interface TestedOptions {
273
+ /** The check's seed; each property derives its own stream from it and its name. */
274
+ readonly seed: string;
275
+ /** Distinct assignments the property must hold on; default 100. Drawing stops after 20 times as many draws, whatever they were. */
276
+ readonly inputs?: number;
277
+ }
278
+ interface TestedInput extends TestedOptions {
279
+ readonly module: string;
280
+ readonly fn: FunctionSpec;
281
+ readonly property: NamedProperty;
282
+ /** The compiled predicate over the binders, or undefined when it could not be built. */
283
+ readonly predicate: ((...binders: never[]) => PredicateOutcome) | undefined;
284
+ }
285
+ declare function testedRung(input: TestedInput): SpecVerdict;
286
+ interface LadderOptions {
287
+ /** Run the `TESTED` rung with these options; `false` stops the ladder at `CHECKED`. */
288
+ readonly tested?: TestedOptions | false;
289
+ }
290
+ /** One property through the ladder's rungs. */
291
+ declare function specLadder(input: CheckedInput, options?: LadderOptions): SpecVerdict;
268
292
  /** Compiled predicates of a module, by function and property name. */
269
293
  interface ModulePredicates {
270
294
  readonly [fn: string]: {
271
295
  readonly [property: string]: (...binders: never[]) => PredicateOutcome;
272
296
  };
273
297
  }
274
- /** Every spec verdict for one module, from what was observed of its calls. */
275
- declare function checkSpecModule(module: string, specs: ModuleSpecs, predicates: ModulePredicates, observed: {
276
- readonly calls: readonly {
277
- readonly function: string;
278
- readonly args: readonly unknown[];
279
- }[];
280
- readonly unobservable: {
281
- readonly [fn: string]: string;
298
+ interface ExploreOptions {
299
+ readonly seed: number | string;
300
+ /** Hard cap on runs, in addition to the scenario's time budget. */
301
+ readonly maxRuns?: number;
302
+ /**
303
+ * Replaces the scenario's `budgetMs` for this exploration: the real time
304
+ * exploring and shrinking may take, and the real time one effect's I/O
305
+ * may take before it counts as hung. With a generous budget and
306
+ * `maxRuns`, the run cap ends exploration, so a seed decides the verdict
307
+ * on any machine.
308
+ */
309
+ readonly budgetMs?: number;
310
+ /**
311
+ * The share of seeded runs after the first (which injects none) that
312
+ * inject faults (see `planFaults`). Default 0.9: the runs without faults
313
+ * also check the scenario as it runs without them, and measure how many
314
+ * eligible points a run without faults has, which can vary with the seed.
315
+ */
316
+ readonly faultProbability?: number;
317
+ /** Clock for the time budget; injectable for tests. */
318
+ readonly now?: () => number;
319
+ /** Hard cap on replay runs spent shrinking a violation. */
320
+ readonly maxShrinkRuns?: number;
321
+ /**
322
+ * How many of the first exploration runs to replay in reverse order
323
+ * before reporting BOUNDED, to detect module-level state leaking between
324
+ * runs. 0 disables the pass.
325
+ */
326
+ readonly leakCheckRuns?: number;
327
+ /**
328
+ * Explore every schedule within the bounds, each once, instead of drawing
329
+ * schedules from the seed: every fault (or none) at every effect point
330
+ * that may still take one, and every order of turns. With `reduction`
331
+ * (the default), turns of different invocations on different targets
332
+ * commute and only one order of them is run.
333
+ */
334
+ readonly exhaustive?: boolean | {
335
+ readonly reduction?: boolean;
282
336
  };
283
- }): SpecVerdict[];
284
- export { Checked as C, SpecVerdict as D, SpecUnknown as E, describeSpecVerdict as O, describeVerdict as S, Refuted as T, Bounded as _, lemmaUnresolved as a, Unsupported as b, Formula as c, ModuleSpecs as d, NamedProperty as f, replay as g, explore as h, lemmaBool as i, FunctionSpec as l, ExploreOptions as m, checkSpecModule as n, Binder as o, Property as p, checkedRung as r, Domain as s, ModulePredicates as t, Guard as u, BoundsReached as v, Counterexample as w, Violated as x, ScenarioVerdict as y };
285
- //# sourceMappingURL=checked-CGpA2-F0.d.mts.map
337
+ }
338
+ /** Re-run a recorded schedule exactly. */
339
+ declare function replay(spec: ScenarioSpec, platform: Platform, schedule: Schedule): Promise<EffectLog>;
340
+ declare function explore(scenario: ScenarioSpec, platform: Platform, options: ExploreOptions): Promise<ScenarioVerdict>;
341
+ export { Proven as A, ScenarioVerdict as C, Checked as D, describeVerdict as E, describeSpecVerdict as F, SpecUnknown as M, SpecVerdict as N, Conflict as O, Tested as P, BoundsReached as S, Violated as T, ModuleSpecs as _, ModulePredicates as a, SpecError as b, testedRung as c, lemmaUnresolved as d, Binder as f, Guard as g, FunctionSpec as h, LadderOptions as i, Refuted as j, Counterexample as k, checkedRung as l, Formula as m, explore as n, specLadder as o, Domain as p, replay as r, TestedOptions as s, ExploreOptions as t, lemmaBool as u, NamedProperty as v, Unsupported as w, Bounded as x, Property as y };
342
+ //# sourceMappingURL=explore-CDpJA9zX.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explore-CDpJA9zX.d.mts","names":[],"sources":["../../core/src/spec-verdict.ts","../../core/src/verdict.ts","../../spec/src/ir.ts","../../spec/src/predicate.ts","../../prover/src/checked.ts","../../prover/src/tested.ts","../../prover/src/ladder.ts","../../engine/src/explore.ts"],"mappings":";;;;;;;;UAQU;;WAEC;WACA;;WAEA;;WAEA;WACA;;UAGM,gBAAgB;WACtB;;WAEA;;WAEA;;;UAIM,eAAe;WACrB;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;aAA6B;aAAuB;;;WAEpD;;WAEA;;UAGM,gBAAgB;WACtB;;WAEA;;WAEA;aAAoB;aAAuB;;WAC3C,gBAAgB;;;UAIV,eAAe;WACrB;WACA;aAAmB;aAAuB;;;WAE1C;;WAEA;;;UAIM,iBAAiB;WACvB;WACA;aAAmB;aAAuB;;WAC1C;aACE;aACA;aACA,iBAAiB;;;KAIlB;UAEK,oBAAoB;WAC1B;WACA,OAAO;WACP;;KAGC,cAAc,UAAU,SAAS,SAAS,UAAU,WAAW;;iBAG3D,oBAAoB,GAAG;UCpFtB;WACN;WACA;WACA;WACA;;;;;;;WAOA;aACE;aACA;aACA;;;UAIH;WACC;WACA;WACA,SAAS;WACT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,MAAM,cACN,UAAU,UACV,UAAU,WACT,QAAQ;iBAIW,QACpB,UAAU,cACV,UAAU,UACV,SAAS,iBACR,QAAQ"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,79 @@
1
1
  import { C as StateQuery, D as EffectLog, E as EffectSelector, O as EffectRecord, S as RowCondition, T as Refines, _ as checkInvariant, b as Implies, d as FaultKind, f as Schedule, g as Violation, h as Invariant, l as validateScenario, m as AtMostOncePerKey, n as Platform, o as ScenarioSpec, p as AtLeastOnce, r as Bounds, t as EventRef, u as FaultDecision, v as checkInvariants, w as Unique, y as EveryRow } from "./platform-DfMwknw1.mjs";
2
- import { C as Checked, D as SpecVerdict, E as SpecUnknown, O as describeSpecVerdict, S as describeVerdict, T as Refuted, _ as Bounded, a as lemmaUnresolved$1, b as Unsupported, c as Formula, d as ModuleSpecs, f as NamedProperty, g as replay, h as explore, i as lemmaBool$1, l as FunctionSpec, m as ExploreOptions, n as checkSpecModule$1, o as Binder, p as Property, r as checkedRung, s as Domain, t as ModulePredicates$1, u as Guard, v as BoundsReached, w as Counterexample, x as Violated, y as ScenarioVerdict } from "./checked-CGpA2-F0.mjs";
2
+ import { A as Proven, C as ScenarioVerdict, D as Checked, E as describeVerdict, F as describeSpecVerdict, M as SpecUnknown, N as SpecVerdict, O as Conflict, P as Tested, S as BoundsReached, T as Violated, _ as ModuleSpecs, b as SpecError, c as testedRung, f as Binder, g as Guard, h as FunctionSpec, i as LadderOptions, j as Refuted, k as Counterexample, l as checkedRung, m as Formula, n as explore, o as specLadder, p as Domain, r as replay, s as TestedOptions, t as ExploreOptions, v as NamedProperty, w as Unsupported, x as Bounded, y as Property } from "./explore-CDpJA9zX.mjs";
3
+ export declare function extractSpecs(source: string): ModuleSpecs;
4
+ /** A property that is not Lemma. `stage` says which part rejected it. */
5
+ export declare class LemmaSyntaxError extends Error {
6
+ readonly stage: "prefix" | "formula";
7
+ constructor(stage: "prefix" | "formula", message: string);
8
+ }
9
+ /** Parse the text after `@ensures{name}`. Throws LemmaSyntaxError. */
10
+ export declare function parseProperty(text: string): Property;
11
+ /** The property as Lemma text (what follows `@ensures{name}`). */
12
+ export declare function printProperty(p: Property): string;
13
+ interface EngineId {
14
+ readonly name: string;
15
+ readonly version: string;
16
+ }
17
+ type ProofOutcome = {
18
+ readonly kind: "PROVEN";
19
+ readonly engine: EngineId;
20
+ readonly assumptions: readonly string[];
21
+ } | {
22
+ readonly kind: "REFUTED";
23
+ readonly engine: EngineId;
24
+ readonly counterexample?: Counterexample;
25
+ readonly assumptions: readonly string[];
26
+ } | {
27
+ readonly kind: "UNKNOWN";
28
+ readonly cause: "gave_up" | "unsupported" | "unavailable";
29
+ readonly reason: string;
30
+ };
31
+ interface PropertyProof {
32
+ readonly function: string;
33
+ /** The `@ensures` name, or `@total`. */
34
+ readonly property: string;
35
+ readonly outcome: ProofOutcome;
36
+ }
37
+ interface ModuleProofs {
38
+ readonly results: readonly PropertyProof[];
39
+ /** Annotations that did not parse: properties asked for and never checked. */
40
+ readonly specErrors: readonly SpecError[];
41
+ }
42
+ interface ProveInput {
43
+ /** The module's source text. */
44
+ readonly source: string;
45
+ /** The annotated functions to prove; every annotated one when omitted. */
46
+ readonly functions?: readonly string[];
47
+ /** The module's specs when the caller has them already. */
48
+ readonly specs?: ModuleSpecs;
49
+ readonly timeoutMs?: number;
50
+ }
51
+ interface Prover {
52
+ readonly name: string;
53
+ /** Whether the engine can run here, or why not. */
54
+ available(): Promise<{
55
+ readonly version: string;
56
+ } | {
57
+ readonly unavailable: string;
58
+ }>;
59
+ prove(input: ProveInput): Promise<ModuleProofs>;
60
+ }
61
+ /** What an engine said about one module, by its name. */
62
+ interface EngineReport {
63
+ readonly engine: string;
64
+ readonly proofs: ModuleProofs;
65
+ }
66
+ /**
67
+ * The simulator's verdicts for a module (CHECKED, TESTED, REFUTED, UNKNOWN,
68
+ * markers included) combined with what the engines proved. A simulator
69
+ * counterexample stands. One engine proving is `PROVEN`, the lower rungs'
70
+ * counts kept beside it; an engine refuting where nothing else did is
71
+ * `REFUTED` at the PROVEN rung; one proving and another refuting is
72
+ * `CONFLICT`. An engine that gave up, could not run or does not take the
73
+ * function leaves the verdict as it was, with why among the assumptions.
74
+ * `@total` is proved by acceptance where the engine says so.
75
+ */
76
+ export declare function aggregate(module: string, verdicts: readonly SpecVerdict[], reports: readonly EngineReport[]): SpecVerdict[];
3
77
  /**
4
78
  * Observe a module's pure core functions while runs are installed: each call
5
79
  * from outside the module is recorded with its arguments, for spec checks
@@ -31,16 +105,6 @@ interface CoreObserver {
31
105
  export declare function observeCore(namespace: object, functions: readonly string[]): CoreObserver;
32
106
  /** The scenario restricted to the kept events, with per-message invariants re-derived. */
33
107
  export declare function restrictSpec(platform: Platform, spec: ScenarioSpec, keepIds: readonly string[]): ScenarioSpec;
34
- export declare function extractSpecs(source: string): ModuleSpecs;
35
- /** A property that is not Lemma. `stage` says which part rejected it. */
36
- export declare class LemmaSyntaxError extends Error {
37
- readonly stage: "prefix" | "formula";
38
- constructor(stage: "prefix" | "formula", message: string);
39
- }
40
- /** Parse the text after `@ensures{name}`. Throws LemmaSyntaxError. */
41
- export declare function parseProperty(text: string): Property;
42
- /** The property as Lemma text (what follows `@ensures{name}`). */
43
- export declare function printProperty(p: Property): string;
44
108
  interface RegressionTestOptions {
45
109
  /** Import lines for the scenario, the platform's dependencies, and anything the platform expression needs. */
46
110
  readonly imports: readonly string[];
@@ -73,13 +137,5 @@ export declare function renderSpecs(specs: readonly SpecVerdict[]): string;
73
137
  export declare function renderTrace(log: EffectLog, evidence?: readonly number[]): string;
74
138
  /** A readable report: verdict, what it rests on, and for a violation the schedule and trace. */
75
139
  export declare function renderText(verdict: ScenarioVerdict): string;
76
- /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
77
- export declare const checkSpecModule: typeof checkSpecModule$1;
78
- /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
79
- export declare const lemmaBool: typeof lemmaBool$1;
80
- /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
81
- export declare const lemmaUnresolved: typeof lemmaUnresolved$1;
82
- /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
83
- export type ModulePredicates = ModulePredicates$1;
84
- export { type AtLeastOnce, type AtMostOncePerKey, type Binder, type Bounded, type Bounds, type BoundsReached, type Checked, type CoreObserver, type Counterexample, type Domain, type EffectLog, type EffectRecord, type EffectSelector, type EventRef, type EveryRow, type ExploreOptions, type FaultDecision, type FaultKind, type Formula, type FunctionSpec, type Guard, type Implies, type Invariant, type ModuleSpecs, type NamedProperty, type ObservedCall, type Platform, type Property, type Refines, type Refuted, type RegressionTestOptions, type RowCondition, type ScenarioSpec, type ScenarioVerdict, type Schedule, type SpecUnknown, type SpecVerdict, type StateQuery, type Unique, type Unsupported, type Violated, type Violation, checkInvariant, checkInvariants, checkedRung, describeSpecVerdict, describeVerdict, explore, replay, validateScenario };
140
+ export { type AtLeastOnce, type AtMostOncePerKey, type Binder, type Bounded, type Bounds, type BoundsReached, type Checked, type Conflict, type CoreObserver, type Counterexample, type Domain, type EffectLog, type EffectRecord, type EffectSelector, type EngineId, type EngineReport, type EventRef, type EveryRow, type ExploreOptions, type FaultDecision, type FaultKind, type Formula, type FunctionSpec, type Guard, type Implies, type Invariant, type LadderOptions, type ModuleProofs, type ModuleSpecs, type NamedProperty, type ObservedCall, type Platform, type ProofOutcome, type Property, type PropertyProof, type ProveInput, type Proven, type Prover, type Refines, type Refuted, type RegressionTestOptions, type RowCondition, type ScenarioSpec, type ScenarioVerdict, type Schedule, type SpecUnknown, type SpecVerdict, type StateQuery, type Tested, type TestedOptions, type Unique, type Unsupported, type Violated, type Violation, checkInvariant, checkInvariants, checkedRung, describeSpecVerdict, describeVerdict, explore, replay, specLadder, testedRung, validateScenario };
85
141
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["prover.checkSpecModule","prover.lemmaBool","prover.lemmaUnresolved","prover.ModulePredicates"],"sources":["../../engine/src/observe.ts","../../engine/src/shrink.ts","../../spec/src/extract.ts","../../spec/src/parse.ts","../../spec/src/print.ts","../../report/src/regression.ts","../../report/src/render.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAkBiB;WACN;;WAEA;WACA;;UAGM;WACN,gBAAgB;;WAEhB;cAA0B;;;EAEnC;;wBAGc,YAAY,mBAAmB,+BAA+B;;wBCK9D,aACd,UAAU,UACV,MAAM,cACN,6BACC;wBCkIa,aAAa,iBAAiB;;qBCjJjC,yBAAyB;WAC3B;EACT,YAAY,6BAA6B;;;wBAmC3B,cAAc,eAAe;;wBCa7B,cAAc,GAAG;UChEhB;;WAEN;;WAEA;;WAEA;;WAEA;WACA;;;;;;WAMA;aACE;aACA;;;wBAIG,mBAAmB,SAAS,UAAU,SAAS;;;;;wBCf/C,WAAW,SAAS,iBAAiB,iBAAgB;;wBAUrD,YAAY,gBAAgB;;wBAqC5B,YAAY,KAAK,WAAW;;wBAuB5B,WAAW,SAAS;;qBCrCvB,wBAAeA;;qBAEf,kBAASC;;qBAET,wBAAeC;;YAEhB,mBAAmBC"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../spec/src/extract.ts","../../spec/src/parse.ts","../../spec/src/print.ts","../../prover/src/provers.ts","../../engine/src/observe.ts","../../engine/src/shrink.ts","../../report/src/regression.ts","../../report/src/render.ts"],"mappings":";;wBA4KgB,aAAa,iBAAiB;;qBCjJjC,yBAAyB;WAC3B;EACT,YAAY,6BAA6B;;;wBAmC3B,cAAc,eAAe;;wBCa7B,cAAc,GAAG;UC/DhB;WACN;WACA;;KAGC;WACG;WAAyB,QAAQ;WAAmB;;WAEpD;WACA,QAAQ;WACR,iBAAiB;WACjB;;WAGA;WACA;WACA;;UAGE;WACN;;WAEA;WACA,SAAS;;UAGH;WACN,kBAAkB;;WAElB,qBAAqB;;UAGf;;WAEN;;WAEA;;WAEA,QAAQ;WACR;;UAGM;WACN;;EAET,aAAa;aAAmB;;aAA+B;;EAC/D,MAAM,OAAO,aAAa,QAAQ;;;UAInB;WACN;WACA,QAAQ;;;;;;;;;;;;wBAaH,UACd,gBACA,mBAAmB,eACnB,kBAAkB,iBACjB;;;;;;;;;;;;;;UCjEc;WACN;;WAEA;WACA;;UAGM;WACN,gBAAgB;;WAEhB;cAA0B;;;EAEnC;;wBAGc,YAAY,mBAAmB,+BAA+B;;wBCK9D,aACd,UAAU,UACV,MAAM,cACN,6BACC;UC7Bc;;WAEN;;WAEA;;WAEA;;WAEA;WACA;;;;;;WAMA;aACE;aACA;;;wBAIG,mBAAmB,SAAS,UAAU,SAAS;;;;;wBCf/C,WAAW,SAAS,iBAAiB,iBAAgB;;wBAUrD,YAAY,gBAAgB;;wBAwE5B,YAAY,KAAK,WAAW;;wBAuB5B,WAAW,SAAS"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,21 @@
1
- import { a as emitRegressionTest, c as checkedRung, f as extractSpecs, i as renderTrace, l as lemmaBool$1, m as parseProperty, n as renderSpecs, o as describeVerdict, p as LemmaSyntaxError, r as renderText, s as checkSpecModule$1, t as renderJson, u as lemmaUnresolved$1 } from "./src-Dxl9ZlKn.mjs";
2
- import { a as explore, b as checkInvariants, o as replay, s as restrictSpec, t as observeCore, v as validateScenario, y as checkInvariant } from "./src-Bqc9Eyb1.mjs";
1
+ import { a as explore, b as checkInvariants, o as replay, s as restrictSpec, t as observeCore, v as validateScenario, y as checkInvariant } from "./src-BO7I3f-1.mjs";
2
+ import { a as emitRegressionTest, b as describeVerdict, c as specLadder, g as parseProperty, h as LemmaSyntaxError, i as renderTrace, l as testedRung, m as extractSpecs, n as renderSpecs, o as aggregate, r as renderText, t as renderJson, u as checkedRung } from "./src-Cs4Mg55e.mjs";
3
+ // packages/core/src/spec-verdict.ts
4
+ /** One line per spec verdict, for error messages; full rendering lives in `report`. */
5
+ function describeSpecVerdict(v) {
6
+ const what = `${v.function} ${v.property}`;
7
+ switch (v.kind) {
8
+ case "CHECKED": return `CHECKED ${what}: held on ${v.inputs} input(s) the simulator passed`;
9
+ case "TESTED": return `TESTED ${what}: held on ${v.inputs} generated input(s)`;
10
+ case "PROVEN": return `PROVEN ${what}: by ${v.engine.name} ${v.engine.version}`;
11
+ case "CONFLICT": return `CONFLICT ${what}: ${v.proven.name} proves it, ${v.refuted.name} refutes it`;
12
+ case "REFUTED": {
13
+ const c = v.counterexample;
14
+ return `REFUTED ${what}: ${c.call ?? c.binders.map((b) => `${b.name} = ${b.value}`).join(", ")}${c.error ? ` threw ${c.error}` : ""}`;
15
+ }
16
+ case "UNKNOWN": return `UNKNOWN ${what}: ${v.cause}: ${v.reason}`;
17
+ }
18
+ }
3
19
  // packages/spec/src/print.ts
4
20
  const precedence = {
5
21
  iff: 1,
@@ -59,23 +75,6 @@ function printProperty(p) {
59
75
  const body = p.requires.length > 0 ? [...p.requires, p.claim].map((f) => printFormula(f, precedence.or)).join(" → ") : printFormula(p.claim, p.claim.kind === "implies" ? precedence.or : 0);
60
76
  return `${prefixText(p.binders)} { ${body} }`;
61
77
  }
62
- // packages/core/src/spec-verdict.ts
63
- /** One line per spec verdict, for error messages; full rendering lives in `report`. */
64
- function describeSpecVerdict(v) {
65
- const what = `${v.function} ${v.property}`;
66
- switch (v.kind) {
67
- case "CHECKED": return `CHECKED ${what}: held on ${v.inputs} input(s) the simulator passed`;
68
- case "REFUTED": return `REFUTED ${what}: ${v.counterexample.call}${v.counterexample.error ? ` threw ${v.counterexample.error}` : ""}`;
69
- case "UNKNOWN": return `UNKNOWN ${what}: ${v.cause}: ${v.reason}`;
70
- }
71
- }
72
- // packages/eutaxy/src/index.ts
73
- /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
74
- const checkSpecModule = checkSpecModule$1;
75
- /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
76
- const lemmaBool = lemmaBool$1;
77
- /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
78
- const lemmaUnresolved = lemmaUnresolved$1;
79
- export { LemmaSyntaxError, checkInvariant, checkInvariants, checkSpecModule, checkedRung, describeSpecVerdict, describeVerdict, emitRegressionTest, explore, extractSpecs, lemmaBool, lemmaUnresolved, observeCore, parseProperty, printProperty, renderJson, renderSpecs, renderText, renderTrace, replay, restrictSpec, validateScenario };
78
+ export { LemmaSyntaxError, aggregate, checkInvariant, checkInvariants, checkedRung, describeSpecVerdict, describeVerdict, emitRegressionTest, explore, extractSpecs, observeCore, parseProperty, printProperty, renderJson, renderSpecs, renderText, renderTrace, replay, restrictSpec, specLadder, testedRung, validateScenario };
80
79
 
81
80
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["prover.checkSpecModule","prover.lemmaBool","prover.lemmaUnresolved"],"sources":["../../spec/src/print.ts","../../core/src/spec-verdict.ts","../src/index.ts"],"sourcesContent":["/**\n * Print SpecIR back as Lemma, canonically: glyph connectives, binders with\n * the same domain and guard grouped, and parentheses only where precedence\n * or a root-level material implication needs them. Parsing what it prints\n * gives the same IR.\n */\n\nimport type { Binder, Formula, Guard, Property } from \"./ir.ts\";\n\nconst precedence: { readonly [k in Formula[\"kind\"]]: number } = {\n iff: 1,\n implies: 2,\n or: 3,\n and: 4,\n not: 5,\n atom: 6,\n equation: 6,\n};\n\nfunction guardText(g: Guard): string {\n if (g.kind === \"regex\") return `/${g.pattern}/${g.flags}`;\n return `${g.lower.inclusive ? \"[\" : \"(\"}${g.lower.value}, ${g.upper.value}${g.upper.inclusive ? \"]\" : \")\"}`;\n}\n\nfunction sameGroup(a: Binder, b: Binder): boolean {\n return (\n a.domain === b.domain &&\n (a.guard === undefined) === (b.guard === undefined) &&\n (a.guard === undefined || (b.guard !== undefined && guardText(a.guard) === guardText(b.guard)))\n );\n}\n\nfunction prefixText(binders: readonly Binder[]): string {\n const groups: Binder[][] = [];\n for (const b of binders) {\n const last = groups[groups.length - 1];\n if (last && sameGroup(last[0] as Binder, b)) last.push(b);\n else groups.push([b]);\n }\n const text = groups.map((g) => {\n const head = g[0] as Binder;\n const guard = head.guard ? ` ∈ ${guardText(head.guard)}` : \"\";\n return `(${g.map((b) => b.name).join(\" \")}: ${head.domain}${guard})`;\n });\n return `forall ${text.join(\" \")}`;\n}\n\n/** Print a formula, parenthesized when its precedence is below `min`. */\nexport function printFormula(f: Formula, min = 0): string {\n let s: string;\n switch (f.kind) {\n case \"atom\":\n s = f.text;\n break;\n case \"equation\":\n s = `${f.left} ${f.negated ? \"≢\" : \"≡\"} ${f.right}`;\n break;\n case \"not\":\n s = `¬${printFormula(f.operand, precedence.not)}`;\n break;\n case \"and\":\n case \"or\":\n s = f.operands\n .map((o) => printFormula(o, precedence[f.kind] + 1))\n .join(f.kind === \"and\" ? \" ∧ \" : \" ∨ \");\n break;\n case \"implies\":\n s = [...f.antecedents, f.consequent].map((o) => printFormula(o, precedence.or)).join(\" → \");\n break;\n case \"iff\":\n s = `${printFormula(f.left, precedence.implies)} ↔ ${printFormula(f.right, precedence.implies)}`;\n break;\n }\n return precedence[f.kind] < min ? `(${s})` : s;\n}\n\n/** The property as Lemma text (what follows `@ensures{name}`). */\nexport function printProperty(p: Property): string {\n // A root implication is the preconditions; a material one there needs its parentheses.\n const body =\n p.requires.length > 0\n ? [...p.requires, p.claim].map((f) => printFormula(f, precedence.or)).join(\" → \")\n : printFormula(p.claim, p.claim.kind === \"implies\" ? precedence.or : 0);\n return `${prefixText(p.binders)} { ${body} }`;\n}\n","/**\n * Spec verdicts: what is known about one property of one pure function.\n * Kept apart from scenario verdicts in every report. The ladder starts at\n * `CHECKED` (held on every input the simulator passed); `TESTED` and\n * `PROVEN` come with the provers.\n */\n\ninterface SpecVerdictBase {\n /** The module, as the scenario names it. */\n readonly module: string;\n readonly function: string;\n /** The `@ensures` name, or `@total` / `@throws` for those markers. */\n readonly property: string;\n /** The property as written. */\n readonly text: string;\n readonly assumptions: readonly string[];\n}\n\nexport interface Checked extends SpecVerdictBase {\n readonly kind: \"CHECKED\";\n /** Distinct inputs the property was evaluated on. */\n readonly inputs: number;\n /** Distinct inputs outside the claim: a precondition failed, or a value fell outside its binder's domain. */\n readonly discarded: number;\n}\n\n/** One assignment that breaks the property, as JavaScript literals, and the call it came from. */\nexport interface Counterexample {\n /** In the property's binder order. */\n readonly binders: readonly { readonly name: string; readonly value: string }[];\n readonly call: string;\n /** Set when evaluating the property threw instead of returning false. */\n readonly error?: string;\n}\n\nexport interface Refuted extends SpecVerdictBase {\n readonly kind: \"REFUTED\";\n readonly rung: \"CHECKED\";\n readonly counterexample: Counterexample;\n}\n\nexport type SpecUnknownCause = \"gave_up\" | \"unsupported\" | \"unavailable\";\n\nexport interface SpecUnknown extends SpecVerdictBase {\n readonly kind: \"UNKNOWN\";\n readonly cause: SpecUnknownCause;\n readonly reason: string;\n}\n\nexport type SpecVerdict = Checked | Refuted | SpecUnknown;\n\n/** One line per spec verdict, for error messages; full rendering lives in `report`. */\nexport function describeSpecVerdict(v: SpecVerdict): string {\n const what = `${v.function} ${v.property}`;\n switch (v.kind) {\n case \"CHECKED\":\n return `CHECKED ${what}: held on ${v.inputs} input(s) the simulator passed`;\n case \"REFUTED\":\n return `REFUTED ${what}: ${v.counterexample.call}${v.counterexample.error ? ` threw ${v.counterexample.error}` : \"\"}`;\n case \"UNKNOWN\":\n return `UNKNOWN ${what}: ${v.cause}: ${v.reason}`;\n }\n}\n","// eutaxy: the public API. Platform-specific entry points live under subpaths.\nimport * as prover from \"@eutaxy/prover\";\n\nexport {\n type AtLeastOnce,\n type AtMostOncePerKey,\n type Bounded,\n type Bounds,\n type BoundsReached,\n type Checked,\n type Counterexample,\n checkInvariant,\n checkInvariants,\n describeSpecVerdict,\n describeVerdict,\n type EffectLog,\n type EffectRecord,\n type EffectSelector,\n type EventRef,\n type EveryRow,\n type FaultDecision,\n type FaultKind,\n type Implies,\n type Invariant,\n type Platform,\n type Refines,\n type Refuted,\n type RowCondition,\n type ScenarioSpec,\n type ScenarioVerdict,\n type Schedule,\n type SpecUnknown,\n type SpecVerdict,\n type StateQuery,\n type Unique,\n type Unsupported,\n type Violated,\n type Violation,\n validateScenario,\n} from \"@eutaxy/core\";\nexport {\n type CoreObserver,\n type ExploreOptions,\n explore,\n type ObservedCall,\n observeCore,\n replay,\n restrictSpec,\n} from \"@eutaxy/engine\";\nexport { checkedRung } from \"@eutaxy/prover\";\n\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport const checkSpecModule = prover.checkSpecModule;\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport const lemmaBool = prover.lemmaBool;\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport const lemmaUnresolved = prover.lemmaUnresolved;\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport type ModulePredicates = prover.ModulePredicates;\nexport {\n emitRegressionTest,\n type RegressionTestOptions,\n renderJson,\n renderSpecs,\n renderText,\n renderTrace,\n} from \"@eutaxy/report\";\nexport {\n type Binder,\n type Domain,\n extractSpecs,\n type Formula,\n type FunctionSpec,\n type Guard,\n LemmaSyntaxError,\n type ModuleSpecs,\n type NamedProperty,\n type Property,\n parseProperty,\n printProperty,\n} from \"@eutaxy/spec\";\n"],"mappings":";;;AASA,MAAM,aAA0D;CAC9D,KAAK;CACL,SAAS;CACT,IAAI;CACJ,KAAK;CACL,KAAK;CACL,MAAM;CACN,UAAU;AACZ;AAEA,SAAS,UAAU,GAAkB;CACnC,IAAI,EAAE,SAAS,SAAS,OAAO,IAAI,EAAE,QAAQ,GAAG,EAAE;CAClD,OAAO,GAAG,EAAE,MAAM,YAAY,MAAM,MAAM,EAAE,MAAM,MAAM,IAAI,EAAE,MAAM,QAAQ,EAAE,MAAM,YAAY,MAAM;AACxG;AAEA,SAAS,UAAU,GAAW,GAAoB;CAChD,OACE,EAAE,WAAW,EAAE,UACd,EAAE,UAAU,KAAA,OAAgB,EAAE,UAAU,KAAA,OACxC,EAAE,UA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WAAW,OAAO;CAEjG;CACA,OAAO,WAAW,EAAE,QAAQ,MAAM,IAAI,EAAE,KAAK;AAC/C;;AAGA,SAAgB,cAAc,GAAqB;CAEjD,MAAM,OACJ,EAAE,SAAS,SAAS,IAChB,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,KAAK,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,IAC9E,aAAa,EAAE,OAAO,EAAE,MAAM,SAAS,YAAY,WAAW,KAAK,CAAC;CAC1E,OAAO,GAAG,WAAW,EAAE,OAAO,EAAE,KAAK,KAAK;AAC5C;;;AChCA,SAAgB,oBAAoB,GAAwB;CAC1D,MAAM,OAAO,GAAG,EAAE,SAAS,GAAG,EAAE;CAChC,QAAQ,EAAE,MAAV;EACE,KAAK,WACH,OAAO,WAAW,KAAK,YAAY,EAAE,OAAO;EAC9C,KAAK,WACH,OAAO,WAAW,KAAK,IAAI,EAAE,eAAe,OAAO,EAAE,eAAe,QAAQ,UAAU,EAAE,eAAe,UAAU;EACnH,KAAK,WACH,OAAO,WAAW,KAAK,IAAI,EAAE,MAAM,IAAI,EAAE;CAC7C;AACF;;;ACVA,MAAa,kBAAkBA;;AAE/B,MAAa,YAAYC;;AAEzB,MAAa,kBAAkBC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../core/src/spec-verdict.ts","../../spec/src/print.ts"],"sourcesContent":["/**\n * Spec verdicts: what is known about one property of one pure function.\n * Kept apart from scenario verdicts in every report. The ladder runs\n * `CHECKED` (held on every input the simulator passed), then `TESTED` (held\n * on inputs generated from the binders' domains), then `PROVEN` (an engine\n * proved it for every input); `CONFLICT` when engines disagree.\n */\n\ninterface SpecVerdictBase {\n /** The module, as the scenario names it. */\n readonly module: string;\n readonly function: string;\n /** The `@ensures` name, or `@total` / `@throws` for those markers. */\n readonly property: string;\n /** The property as written. */\n readonly text: string;\n readonly assumptions: readonly string[];\n}\n\nexport interface Checked extends SpecVerdictBase {\n readonly kind: \"CHECKED\";\n /** Distinct inputs the property was evaluated on. */\n readonly inputs: number;\n /** Distinct inputs outside the claim: a precondition failed, or a value fell outside its binder's domain. */\n readonly discarded: number;\n}\n\n/** The property held on inputs generated from its binders' domains, and on the simulator's where it passed any. */\nexport interface Tested extends SpecVerdictBase {\n readonly kind: \"TESTED\";\n /** Generated assignments the property held on. */\n readonly inputs: number;\n /** Generated assignments outside the claim: a precondition failed. */\n readonly discarded: number;\n /** The seed the assignments were drawn from; the same seed draws the same assignments. */\n readonly seed: string;\n /** Distinct inputs the simulator passed that the property also held on, when it passed any. */\n readonly checked?: number;\n}\n\n/** One assignment that breaks the property, as JavaScript literals, and where it came from. */\nexport interface Counterexample {\n /** In the property's binder order. */\n readonly binders: readonly { readonly name: string; readonly value: string }[];\n /** The simulator's call the assignment was taken from; absent when it was generated. */\n readonly call?: string;\n /** Set when evaluating the property threw instead of returning false. */\n readonly error?: string;\n}\n\nexport interface Refuted extends SpecVerdictBase {\n readonly kind: \"REFUTED\";\n /** The rung that found the counterexample: a rung of the simulator, or an engine by name. */\n readonly rung: \"CHECKED\" | \"TESTED\" | \"PROVEN\";\n /** The engine, when the rung is PROVEN. */\n readonly engine?: { readonly name: string; readonly version: string };\n readonly counterexample: Counterexample;\n}\n\n/** Proved for every input by a named engine; the lower rungs' evidence is kept beside it. */\nexport interface Proven extends SpecVerdictBase {\n readonly kind: \"PROVEN\";\n readonly engine: { readonly name: string; readonly version: string };\n /** Generated inputs the TESTED rung held on, when it ran. */\n readonly tested?: number;\n /** Distinct inputs the simulator passed that the CHECKED rung held on, when it passed any. */\n readonly checked?: number;\n}\n\n/** Two engines disagree: one proves, one refutes. Never resolved automatically. */\nexport interface Conflict extends SpecVerdictBase {\n readonly kind: \"CONFLICT\";\n readonly proven: { readonly name: string; readonly version: string };\n readonly refuted: {\n readonly name: string;\n readonly version: string;\n readonly counterexample?: Counterexample;\n };\n}\n\nexport type SpecUnknownCause = \"gave_up\" | \"unsupported\" | \"unavailable\";\n\nexport interface SpecUnknown extends SpecVerdictBase {\n readonly kind: \"UNKNOWN\";\n readonly cause: SpecUnknownCause;\n readonly reason: string;\n}\n\nexport type SpecVerdict = Checked | Tested | Proven | Refuted | Conflict | SpecUnknown;\n\n/** One line per spec verdict, for error messages; full rendering lives in `report`. */\nexport function describeSpecVerdict(v: SpecVerdict): string {\n const what = `${v.function} ${v.property}`;\n switch (v.kind) {\n case \"CHECKED\":\n return `CHECKED ${what}: held on ${v.inputs} input(s) the simulator passed`;\n case \"TESTED\":\n return `TESTED ${what}: held on ${v.inputs} generated input(s)`;\n case \"PROVEN\":\n return `PROVEN ${what}: by ${v.engine.name} ${v.engine.version}`;\n case \"CONFLICT\":\n return `CONFLICT ${what}: ${v.proven.name} proves it, ${v.refuted.name} refutes it`;\n case \"REFUTED\": {\n const c = v.counterexample;\n const where = c.call ?? c.binders.map((b) => `${b.name} = ${b.value}`).join(\", \");\n return `REFUTED ${what}: ${where}${c.error ? ` threw ${c.error}` : \"\"}`;\n }\n case \"UNKNOWN\":\n return `UNKNOWN ${what}: ${v.cause}: ${v.reason}`;\n }\n}\n","/**\n * Print SpecIR back as Lemma, canonically: glyph connectives, binders with\n * the same domain and guard grouped, and parentheses only where precedence\n * or a root-level material implication needs them. Parsing what it prints\n * gives the same IR.\n */\n\nimport type { Binder, Formula, Guard, Property } from \"./ir.ts\";\n\nconst precedence: { readonly [k in Formula[\"kind\"]]: number } = {\n iff: 1,\n implies: 2,\n or: 3,\n and: 4,\n not: 5,\n atom: 6,\n equation: 6,\n};\n\nfunction guardText(g: Guard): string {\n if (g.kind === \"regex\") return `/${g.pattern}/${g.flags}`;\n return `${g.lower.inclusive ? \"[\" : \"(\"}${g.lower.value}, ${g.upper.value}${g.upper.inclusive ? \"]\" : \")\"}`;\n}\n\nfunction sameGroup(a: Binder, b: Binder): boolean {\n return (\n a.domain === b.domain &&\n (a.guard === undefined) === (b.guard === undefined) &&\n (a.guard === undefined || (b.guard !== undefined && guardText(a.guard) === guardText(b.guard)))\n );\n}\n\nfunction prefixText(binders: readonly Binder[]): string {\n const groups: Binder[][] = [];\n for (const b of binders) {\n const last = groups[groups.length - 1];\n if (last && sameGroup(last[0] as Binder, b)) last.push(b);\n else groups.push([b]);\n }\n const text = groups.map((g) => {\n const head = g[0] as Binder;\n const guard = head.guard ? ` ∈ ${guardText(head.guard)}` : \"\";\n return `(${g.map((b) => b.name).join(\" \")}: ${head.domain}${guard})`;\n });\n return `forall ${text.join(\" \")}`;\n}\n\n/** Print a formula, parenthesized when its precedence is below `min`. */\nexport function printFormula(f: Formula, min = 0): string {\n let s: string;\n switch (f.kind) {\n case \"atom\":\n s = f.text;\n break;\n case \"equation\":\n s = `${f.left} ${f.negated ? \"≢\" : \"≡\"} ${f.right}`;\n break;\n case \"not\":\n s = `¬${printFormula(f.operand, precedence.not)}`;\n break;\n case \"and\":\n case \"or\":\n s = f.operands\n .map((o) => printFormula(o, precedence[f.kind] + 1))\n .join(f.kind === \"and\" ? \" ∧ \" : \" ∨ \");\n break;\n case \"implies\":\n s = [...f.antecedents, f.consequent].map((o) => printFormula(o, precedence.or)).join(\" → \");\n break;\n case \"iff\":\n s = `${printFormula(f.left, precedence.implies)} ↔ ${printFormula(f.right, precedence.implies)}`;\n break;\n }\n return precedence[f.kind] < min ? `(${s})` : s;\n}\n\n/** The property as Lemma text (what follows `@ensures{name}`). */\nexport function printProperty(p: Property): string {\n // A root implication is the preconditions; a material one there needs its parentheses.\n const body =\n p.requires.length > 0\n ? [...p.requires, p.claim].map((f) => printFormula(f, precedence.or)).join(\" → \")\n : printFormula(p.claim, p.claim.kind === \"implies\" ? precedence.or : 0);\n return `${prefixText(p.binders)} { ${body} }`;\n}\n"],"mappings":";;;;AA2FA,SAAgB,oBAAoB,GAAwB;CAC1D,MAAM,OAAO,GAAG,EAAE,SAAS,GAAG,EAAE;CAChC,QAAQ,EAAE,MAAV;EACE,KAAK,WACH,OAAO,WAAW,KAAK,YAAY,EAAE,OAAO;EA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,OAAO,EAAE,MAAM,SAAS,YAAY,WAAW,KAAK,CAAC;CAC1E,OAAO,GAAG,WAAW,EAAE,OAAO,EAAE,KAAK,KAAK;AAC5C"}
@@ -2650,6 +2650,6 @@ function observeCore(namespace, functions) {
2650
2650
  }
2651
2651
  };
2652
2652
  }
2653
- export { canonicalJson as S, defaultBounds as _, explore as a, checkInvariants as b, CrashSignal as c, withoutNetwork as d, patchGlobals as f, toJson as g, patchProperty as h, proxiedSide as i, InjectedEffectError as l, settleOn as m, DifferentialStuck as n, replay as o, realTick as p, compareSides as r, restrictSpec as s, observeCore as t, installScriptedFetch as u, validateScenario as v, getPath as x, checkInvariant as y };
2653
+ export { nextU32 as C, canonicalJson as E, nextInt as S, getPath as T, defaultBounds as _, explore as a, checkInvariants as b, CrashSignal as c, withoutNetwork as d, patchGlobals as f, toJson as g, patchProperty as h, proxiedSide as i, InjectedEffectError as l, settleOn as m, DifferentialStuck as n, replay as o, realTick as p, compareSides as r, restrictSpec as s, observeCore as t, installScriptedFetch as u, validateScenario as v, seedPrng as w, nextFloat as x, checkInvariant as y };
2654
2654
 
2655
- //# sourceMappingURL=src-Bqc9Eyb1.mjs.map
2655
+ //# sourceMappingURL=src-BO7I3f-1.mjs.map