eutaxy 0.5.0 → 0.5.1
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 +1 -1
- package/dist/aws.d.mts +7 -5
- package/dist/aws.d.mts.map +1 -1
- package/dist/aws.mjs +41 -135
- package/dist/aws.mjs.map +1 -1
- package/dist/bin.mjs +2 -2
- package/dist/checked-CGpA2-F0.d.mts +285 -0
- package/dist/checked-CGpA2-F0.d.mts.map +1 -0
- package/dist/cli-IJrKkeYS.mjs +2 -0
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cloudflare.d.mts +158 -54
- package/dist/cloudflare.d.mts.map +1 -1
- package/dist/cloudflare.mjs +3 -1815
- package/dist/delivery-invariants-BraYqcYN.d.mts +5 -0
- package/dist/delivery-invariants-BraYqcYN.d.mts.map +1 -0
- package/dist/delivery-invariants-Cuxdna28.mjs +39 -0
- package/dist/delivery-invariants-Cuxdna28.mjs.map +1 -0
- package/dist/index.d.mts +22 -189
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +17 -197
- package/dist/index.mjs.map +1 -1
- package/dist/{platform-eVgCMbX0.d.mts → platform-DfMwknw1.d.mts} +94 -73
- package/dist/platform-DfMwknw1.d.mts.map +1 -0
- package/dist/{src-C19_yfMM.mjs → src-Bqc9Eyb1.mjs} +961 -543
- package/dist/src-Bqc9Eyb1.mjs.map +1 -0
- package/dist/src-DKb-fkdb.mjs +3399 -0
- package/dist/src-DKb-fkdb.mjs.map +1 -0
- package/dist/{src-CgfGiH25.mjs → src-Dxl9ZlKn.mjs} +223 -17
- package/dist/src-Dxl9ZlKn.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/cli-NqY61bpo.mjs +0 -2
- package/dist/cloudflare.mjs.map +0 -1
- package/dist/explore-BHYvAZKN.d.mts +0 -84
- package/dist/explore-BHYvAZKN.d.mts.map +0 -1
- package/dist/platform-eVgCMbX0.d.mts.map +0 -1
- package/dist/src-BD3jkjgG.mjs +0 -477
- package/dist/src-BD3jkjgG.mjs.map +0 -1
- package/dist/src-C19_yfMM.mjs.map +0 -1
- package/dist/src-CgfGiH25.mjs.map +0 -1
- package/dist/src-s6uYyC0B.mjs +0 -89
- package/dist/src-s6uYyC0B.mjs.map +0 -1
- package/dist/verdict-evEM5Gxx.mjs +0 -12
- package/dist/verdict-evEM5Gxx.mjs.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { E as EffectSelector, k as JsonValue, m as AtMostOncePerKey, p as AtLeastOnce } from "./platform-DfMwknw1.mjs";
|
|
2
|
+
declare function atMostOncePerKey(name: string, effect: EffectSelector, key: string): AtMostOncePerKey;
|
|
3
|
+
declare function atLeastOnce(name: string, effect: EffectSelector, key: string, expected: readonly JsonValue[]): AtLeastOnce;
|
|
4
|
+
export { atMostOncePerKey as n, atLeastOnce as t };
|
|
5
|
+
//# sourceMappingURL=delivery-invariants-BraYqcYN.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-invariants-BraYqcYN.d.mts","names":[],"sources":["../../core/src/delivery-invariants.ts"],"mappings":";iBAUgB,iBACd,cACA,QAAQ,gBACR,cACC;iBAIa,YACd,cACA,QAAQ,gBACR,aACA,mBAAmB,cAClB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { x as getPath } from "./src-Bqc9Eyb1.mjs";
|
|
2
|
+
// packages/core/src/delivery-invariants.ts
|
|
3
|
+
function atMostOncePerKey(name, effect, key) {
|
|
4
|
+
return {
|
|
5
|
+
kind: "atMostOncePerKey",
|
|
6
|
+
name,
|
|
7
|
+
effect,
|
|
8
|
+
key
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function atLeastOnce(name, effect, key, expected) {
|
|
12
|
+
return {
|
|
13
|
+
kind: "atLeastOnce",
|
|
14
|
+
name,
|
|
15
|
+
effect,
|
|
16
|
+
key,
|
|
17
|
+
expected
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Every event's `bodyKey` value must appear at least once as `key` in a
|
|
22
|
+
* selected effect. The expected keys are re-derived from the bodies that
|
|
23
|
+
* remain when shrinking removes events.
|
|
24
|
+
*/
|
|
25
|
+
function atLeastOncePerMessage(name, events, effect, key, bodyKey) {
|
|
26
|
+
const expected = [];
|
|
27
|
+
for (const e of events) {
|
|
28
|
+
const v = getPath(e.body, bodyKey);
|
|
29
|
+
if (v === void 0) throw new Error(`event ${e.id} has no ${JSON.stringify(bodyKey)} in its body`);
|
|
30
|
+
expected.push(v);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...atLeastOnce(name, effect, key, expected),
|
|
34
|
+
perMessage: { bodyKey }
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export { atLeastOncePerMessage as n, atMostOncePerKey as r, atLeastOnce as t };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=delivery-invariants-Cuxdna28.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-invariants-Cuxdna28.mjs","names":[],"sources":["../../core/src/delivery-invariants.ts"],"sourcesContent":["/**\n * Constructors for the delivery invariants every platform's scenarios use:\n * nothing delivered twice, nothing lost. Platforms wrap them to take their\n * own drive shapes.\n */\n\nimport type { JsonValue } from \"./canonical-json.ts\";\nimport type { AtLeastOnce, AtMostOncePerKey } from \"./invariants.ts\";\nimport { type EffectSelector, getPath } from \"./selectors.ts\";\n\nexport function atMostOncePerKey(\n name: string,\n effect: EffectSelector,\n key: string,\n): AtMostOncePerKey {\n return { kind: \"atMostOncePerKey\", name, effect, key };\n}\n\nexport function atLeastOnce(\n name: string,\n effect: EffectSelector,\n key: string,\n expected: readonly JsonValue[],\n): AtLeastOnce {\n return { kind: \"atLeastOnce\", name, effect, key, expected };\n}\n\n/**\n * Every event's `bodyKey` value must appear at least once as `key` in a\n * selected effect. The expected keys are re-derived from the bodies that\n * remain when shrinking removes events.\n */\nexport function atLeastOncePerMessage(\n name: string,\n events: readonly { readonly id: string; readonly body: JsonValue }[],\n effect: EffectSelector,\n key: string,\n bodyKey: string,\n): AtLeastOnce {\n const expected: JsonValue[] = [];\n for (const e of events) {\n const v = getPath(e.body, bodyKey);\n if (v === undefined)\n throw new Error(`event ${e.id} has no ${JSON.stringify(bodyKey)} in its body`);\n expected.push(v);\n }\n return { ...atLeastOnce(name, effect, key, expected), perMessage: { bodyKey } };\n}\n"],"mappings":";;AAUA,SAAgB,iBACd,MACA,QACA,KACkB;CAClB,OAAO;EAAE,MAAM;EAAoB;EAAM;EAAQ;CAAI;AACvD;AAEA,SAAgB,YACd,MACA,QACA,KACA,UACa;CACb,OAAO;EAAE,MAAM;EAAe;EAAM;EAAQ;EAAK;CAAS;AAC5D;;;;;;AAOA,SAAgB,sBACd,MACA,QACA,QACA,KACA,SACa;CACb,MAAM,WAAwB,CAAC;CAC/B,KAAK,MAAM,KAAK,QAAQ;EACtB,MAAM,IAAI,QAAQ,EAAE,MAAM,OAAO;EACjC,IAAI,MAAM,KAAA,GACR,MAAM,IAAI,MAAM,SAAS,EAAE,GAAG,UAAU,KAAK,UAAU,OAAO,EAAE,aAAa;EAC/E,SAAS,KAAK,CAAC;CACjB;CACA,OAAO;EAAE,GAAG,YAAY,MAAM,QAAQ,KAAK,QAAQ;EAAG,YAAY,EAAE,QAAQ;CAAE;AAChF"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,53 +1,18 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { a as
|
|
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";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
4
|
+
* Observe a module's pure core functions while runs are installed: each call
|
|
5
|
+
* from outside the module is recorded with its arguments, for spec checks
|
|
6
|
+
* on the inputs the simulator passed, and logged as a decision of the
|
|
7
|
+
* invocation that made it (`Core:<function>`, payload `{ args, result }` or
|
|
8
|
+
* `{ args, error }`), for `refines`. Calls the module makes to itself do not
|
|
9
|
+
* go through its exports and are not seen.
|
|
10
|
+
*
|
|
11
|
+
* Observing replaces the export on the module's namespace object, which
|
|
12
|
+
* works where a bundler or test runner gives modules a namespace with
|
|
13
|
+
* configurable properties (Vite, so Vitest and the Cloudflare plugin); a
|
|
14
|
+
* native ESM namespace is frozen, and the function is reported unobservable.
|
|
8
15
|
*/
|
|
9
|
-
interface SpecVerdictBase {
|
|
10
|
-
/** The module, as the scenario names it. */
|
|
11
|
-
readonly module: string;
|
|
12
|
-
readonly function: string;
|
|
13
|
-
/** The `@ensures` name, or `@total` / `@throws` for those markers. */
|
|
14
|
-
readonly property: string;
|
|
15
|
-
/** The property as written. */
|
|
16
|
-
readonly text: string;
|
|
17
|
-
readonly assumptions: readonly string[];
|
|
18
|
-
}
|
|
19
|
-
interface Checked extends SpecVerdictBase {
|
|
20
|
-
readonly kind: "CHECKED";
|
|
21
|
-
/** Distinct inputs the property was evaluated on. */
|
|
22
|
-
readonly inputs: number;
|
|
23
|
-
/** Distinct inputs outside the claim: a precondition failed, or a value fell outside its binder's domain. */
|
|
24
|
-
readonly discarded: number;
|
|
25
|
-
}
|
|
26
|
-
/** One assignment that breaks the property, as JavaScript literals, and the call it came from. */
|
|
27
|
-
interface Counterexample {
|
|
28
|
-
/** In the property's binder order. */
|
|
29
|
-
readonly binders: readonly {
|
|
30
|
-
readonly name: string;
|
|
31
|
-
readonly value: string;
|
|
32
|
-
}[];
|
|
33
|
-
readonly call: string;
|
|
34
|
-
/** Set when evaluating the property threw instead of returning false. */
|
|
35
|
-
readonly error?: string;
|
|
36
|
-
}
|
|
37
|
-
interface Refuted extends SpecVerdictBase {
|
|
38
|
-
readonly kind: "REFUTED";
|
|
39
|
-
readonly rung: "CHECKED";
|
|
40
|
-
readonly counterexample: Counterexample;
|
|
41
|
-
}
|
|
42
|
-
type SpecUnknownCause = "gave_up" | "unsupported" | "unavailable";
|
|
43
|
-
interface SpecUnknown extends SpecVerdictBase {
|
|
44
|
-
readonly kind: "UNKNOWN";
|
|
45
|
-
readonly cause: SpecUnknownCause;
|
|
46
|
-
readonly reason: string;
|
|
47
|
-
}
|
|
48
|
-
type SpecVerdict = Checked | Refuted | SpecUnknown;
|
|
49
|
-
/** One line per spec verdict, for error messages; full rendering lives in `report`. */
|
|
50
|
-
export declare function describeSpecVerdict(v: SpecVerdict): string;
|
|
51
16
|
interface ObservedCall {
|
|
52
17
|
readonly function: string;
|
|
53
18
|
/** The arguments as passed; primitives exactly, objects by reference. */
|
|
@@ -66,110 +31,6 @@ interface CoreObserver {
|
|
|
66
31
|
export declare function observeCore(namespace: object, functions: readonly string[]): CoreObserver;
|
|
67
32
|
/** The scenario restricted to the kept events, with per-message invariants re-derived. */
|
|
68
33
|
export declare function restrictSpec(platform: Platform, spec: ScenarioSpec, keepIds: readonly string[]): ScenarioSpec;
|
|
69
|
-
/**
|
|
70
|
-
* SpecIR: function specs as plain data. The surface syntax is Lemma
|
|
71
|
-
* (https://github.com/jessealama/lemma-lang, grammar.ebnf and
|
|
72
|
-
* semantics.md); the IR is Eutaxy's own, so engines and the simulator read
|
|
73
|
-
* one shape whatever the annotation looked like. Leaves are opaque
|
|
74
|
-
* TypeScript expressions, kept as written.
|
|
75
|
-
*/
|
|
76
|
-
/** Lemma's binder domains. */
|
|
77
|
-
type Domain = "int" | "nat" | "number" | "boolean" | "string" | "bigint";
|
|
78
|
-
/**
|
|
79
|
-
* One end of an interval: a numeric literal as written (sign included), or
|
|
80
|
-
* `∞` / `-∞` for either infinity. `[` and `]` include the endpoint.
|
|
81
|
-
*/
|
|
82
|
-
interface Endpoint {
|
|
83
|
-
readonly value: string;
|
|
84
|
-
readonly inclusive: boolean;
|
|
85
|
-
}
|
|
86
|
-
/** A binder's constraint: an interval for numeric domains, a whole-string regex for `string`. */
|
|
87
|
-
type Guard = {
|
|
88
|
-
readonly kind: "interval";
|
|
89
|
-
readonly lower: Endpoint;
|
|
90
|
-
readonly upper: Endpoint;
|
|
91
|
-
} | {
|
|
92
|
-
readonly kind: "regex";
|
|
93
|
-
readonly pattern: string;
|
|
94
|
-
readonly flags: string;
|
|
95
|
-
};
|
|
96
|
-
interface Binder {
|
|
97
|
-
readonly name: string;
|
|
98
|
-
readonly domain: Domain;
|
|
99
|
-
readonly guard?: Guard;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* A formula over boolean atoms. Atoms and equation sides are TypeScript
|
|
103
|
-
* expressions, verbatim. `and` and `or` are n-ary (both are associative);
|
|
104
|
-
* `implies` keeps Lemma's chain: every segment but the last is an
|
|
105
|
-
* antecedent. An implication at a property's root is not a formula node but
|
|
106
|
-
* the property's preconditions (`Property.requires`).
|
|
107
|
-
*/
|
|
108
|
-
type Formula = {
|
|
109
|
-
readonly kind: "atom";
|
|
110
|
-
readonly text: string;
|
|
111
|
-
} | {
|
|
112
|
-
readonly kind: "equation";
|
|
113
|
-
readonly left: string;
|
|
114
|
-
readonly right: string;
|
|
115
|
-
/** `≢` rather than `≡`. */
|
|
116
|
-
readonly negated: boolean;
|
|
117
|
-
} | {
|
|
118
|
-
readonly kind: "not";
|
|
119
|
-
readonly operand: Formula;
|
|
120
|
-
} | {
|
|
121
|
-
readonly kind: "and" | "or";
|
|
122
|
-
readonly operands: readonly Formula[];
|
|
123
|
-
} | {
|
|
124
|
-
readonly kind: "implies";
|
|
125
|
-
readonly antecedents: readonly Formula[];
|
|
126
|
-
readonly consequent: Formula;
|
|
127
|
-
} | {
|
|
128
|
-
readonly kind: "iff";
|
|
129
|
-
readonly left: Formula;
|
|
130
|
-
readonly right: Formula;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* A universally quantified claim: for every assignment of the binders from
|
|
134
|
-
* their (guarded) domains where every precondition holds, `claim` holds.
|
|
135
|
-
* Assignments failing a precondition are outside the claim.
|
|
136
|
-
*/
|
|
137
|
-
interface Property {
|
|
138
|
-
readonly binders: readonly Binder[];
|
|
139
|
-
readonly requires: readonly Formula[];
|
|
140
|
-
readonly claim: Formula;
|
|
141
|
-
}
|
|
142
|
-
/** An `@ensures{name}` annotation. */
|
|
143
|
-
interface NamedProperty {
|
|
144
|
-
readonly name: string;
|
|
145
|
-
readonly property: Property;
|
|
146
|
-
/** The annotation's property text, as written. */
|
|
147
|
-
readonly text: string;
|
|
148
|
-
}
|
|
149
|
-
/** The specs on one exported function. */
|
|
150
|
-
interface FunctionSpec {
|
|
151
|
-
readonly name: string;
|
|
152
|
-
/** Parameter names in order; null for a destructured or rest parameter. */
|
|
153
|
-
readonly params: readonly (string | null)[];
|
|
154
|
-
readonly ensures: readonly NamedProperty[];
|
|
155
|
-
/** `@total`: the function terminates on every input. */
|
|
156
|
-
readonly total: boolean;
|
|
157
|
-
/** `@throws`: the function throws (Lemma has not fixed its semantics yet). */
|
|
158
|
-
readonly throws: boolean;
|
|
159
|
-
/** 1-based line of the declaration. */
|
|
160
|
-
readonly line: number;
|
|
161
|
-
}
|
|
162
|
-
/** A problem with an annotation, located in the module. */
|
|
163
|
-
interface SpecError {
|
|
164
|
-
readonly line: number;
|
|
165
|
-
readonly message: string;
|
|
166
|
-
}
|
|
167
|
-
/** Every spec in one module, the names it exports, and the annotations that did not parse. */
|
|
168
|
-
interface ModuleSpecs {
|
|
169
|
-
readonly functions: readonly FunctionSpec[];
|
|
170
|
-
readonly exports: readonly string[];
|
|
171
|
-
readonly errors: readonly SpecError[];
|
|
172
|
-
}
|
|
173
34
|
export declare function extractSpecs(source: string): ModuleSpecs;
|
|
174
35
|
/** A property that is not Lemma. `stage` says which part rejected it. */
|
|
175
36
|
export declare class LemmaSyntaxError extends Error {
|
|
@@ -178,44 +39,8 @@ export declare class LemmaSyntaxError extends Error {
|
|
|
178
39
|
}
|
|
179
40
|
/** Parse the text after `@ensures{name}`. Throws LemmaSyntaxError. */
|
|
180
41
|
export declare function parseProperty(text: string): Property;
|
|
181
|
-
/** The outcome a predicate returns for one assignment. */
|
|
182
|
-
type PredicateOutcome = "held" | "discarded" | "refuted";
|
|
183
42
|
/** The property as Lemma text (what follows `@ensures{name}`). */
|
|
184
43
|
export declare function printProperty(p: Property): string;
|
|
185
|
-
/** What generated predicates call when free names did not resolve. */
|
|
186
|
-
export declare function lemmaUnresolved(names: readonly string[]): never;
|
|
187
|
-
/** The atom check generated predicates call: its argument when it is a boolean. */
|
|
188
|
-
export declare function lemmaBool(value: unknown): boolean;
|
|
189
|
-
interface CheckedInput {
|
|
190
|
-
readonly module: string;
|
|
191
|
-
readonly fn: FunctionSpec;
|
|
192
|
-
readonly property: NamedProperty;
|
|
193
|
-
/** The calls the simulator made, with their arguments. */
|
|
194
|
-
readonly calls: readonly {
|
|
195
|
-
readonly args: readonly unknown[];
|
|
196
|
-
}[];
|
|
197
|
-
/** The compiled predicate over the binders, or undefined when it could not be built. */
|
|
198
|
-
readonly predicate: ((...binders: never[]) => PredicateOutcome) | undefined;
|
|
199
|
-
/** Why the function's calls could not be observed, when they could not. */
|
|
200
|
-
readonly unobservable?: string;
|
|
201
|
-
}
|
|
202
|
-
export declare function checkedRung(input: CheckedInput): SpecVerdict;
|
|
203
|
-
/** Compiled predicates of a module, by function and property name. */
|
|
204
|
-
interface ModulePredicates {
|
|
205
|
-
readonly [fn: string]: {
|
|
206
|
-
readonly [property: string]: (...binders: never[]) => PredicateOutcome;
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
/** Every spec verdict for one module, from what was observed of its calls. */
|
|
210
|
-
export declare function checkSpecModule(module: string, specs: ModuleSpecs, predicates: ModulePredicates, observed: {
|
|
211
|
-
readonly calls: readonly {
|
|
212
|
-
readonly function: string;
|
|
213
|
-
readonly args: readonly unknown[];
|
|
214
|
-
}[];
|
|
215
|
-
readonly unobservable: {
|
|
216
|
-
readonly [fn: string]: string;
|
|
217
|
-
};
|
|
218
|
-
}): SpecVerdict[];
|
|
219
44
|
interface RegressionTestOptions {
|
|
220
45
|
/** Import lines for the scenario, the platform's dependencies, and anything the platform expression needs. */
|
|
221
46
|
readonly imports: readonly string[];
|
|
@@ -248,5 +73,13 @@ export declare function renderSpecs(specs: readonly SpecVerdict[]): string;
|
|
|
248
73
|
export declare function renderTrace(log: EffectLog, evidence?: readonly number[]): string;
|
|
249
74
|
/** A readable report: verdict, what it rests on, and for a violation the schedule and trace. */
|
|
250
75
|
export declare function renderText(verdict: ScenarioVerdict): string;
|
|
251
|
-
|
|
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 };
|
|
252
85
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[
|
|
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"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import "./src-
|
|
2
|
-
import {
|
|
3
|
-
import { t as describeVerdict } from "./verdict-evEM5Gxx.mjs";
|
|
4
|
-
import { a as emitRegressionTest, c as LemmaSyntaxError, i as renderTrace, l as endpointNumber, n as renderSpecs, r as renderText, s as extractSpecs, t as renderJson, u as parseProperty } from "./src-CgfGiH25.mjs";
|
|
5
|
-
// packages/core/src/spec-verdict.ts
|
|
6
|
-
/** One line per spec verdict, for error messages; full rendering lives in `report`. */
|
|
7
|
-
function describeSpecVerdict(v) {
|
|
8
|
-
const what = `${v.function} ${v.property}`;
|
|
9
|
-
switch (v.kind) {
|
|
10
|
-
case "CHECKED": return `CHECKED ${what}: held on ${v.inputs} input(s) the simulator passed`;
|
|
11
|
-
case "REFUTED": return `REFUTED ${what}: ${v.counterexample.call}${v.counterexample.error ? ` threw ${v.counterexample.error}` : ""}`;
|
|
12
|
-
case "UNKNOWN": return `UNKNOWN ${what}: ${v.cause}: ${v.reason}`;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
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";
|
|
15
3
|
// packages/spec/src/print.ts
|
|
16
4
|
const precedence = {
|
|
17
5
|
iff: 1,
|
|
@@ -71,191 +59,23 @@ function printProperty(p) {
|
|
|
71
59
|
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);
|
|
72
60
|
return `${prefixText(p.binders)} { ${body} }`;
|
|
73
61
|
}
|
|
74
|
-
// packages/
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
/** The atom check generated predicates call: its argument when it is a boolean. */
|
|
84
|
-
function lemmaBool(value) {
|
|
85
|
-
if (typeof value !== "boolean") throw new AtomNotBoolean(`a Lemma atom evaluated to ${render(value)}, not a boolean`);
|
|
86
|
-
return value;
|
|
87
|
-
}
|
|
88
|
-
/** A value as a JavaScript literal, exact for the binder domains. */
|
|
89
|
-
function render(value) {
|
|
90
|
-
switch (typeof value) {
|
|
91
|
-
case "bigint": return `${value}n`;
|
|
92
|
-
case "number": return Object.is(value, -0) ? "-0" : String(value);
|
|
93
|
-
case "string": return JSON.stringify(value);
|
|
94
|
-
case "undefined": return "undefined";
|
|
95
|
-
case "boolean": return String(value);
|
|
96
|
-
case "function": return "[function]";
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
const text = JSON.stringify(value, (_, v) => typeof v === "bigint" ? `${v}n` : v);
|
|
100
|
-
return text === void 0 ? String(value) : text.length > 200 ? `${text.slice(0, 200)}…` : text;
|
|
101
|
-
} catch {
|
|
102
|
-
return String(value);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function bound(value, integral) {
|
|
106
|
-
if (integral && !value.endsWith("∞")) return BigInt(value.replace(/_/g, "").replace(/n$/, ""));
|
|
107
|
-
return endpointNumber(value);
|
|
108
|
-
}
|
|
109
|
-
/** Whether a value lies in a binder's domain and guard. */
|
|
110
|
-
function inDomain(b, v) {
|
|
111
|
-
switch (b.domain) {
|
|
112
|
-
case "int":
|
|
113
|
-
if (!(typeof v === "number" && Number.isInteger(v))) return false;
|
|
114
|
-
break;
|
|
115
|
-
case "nat":
|
|
116
|
-
if (!(typeof v === "number" && Number.isInteger(v) && v >= 0)) return false;
|
|
117
|
-
break;
|
|
118
|
-
case "number":
|
|
119
|
-
if (typeof v !== "number") return false;
|
|
120
|
-
break;
|
|
121
|
-
case "bigint":
|
|
122
|
-
if (typeof v !== "bigint") return false;
|
|
123
|
-
break;
|
|
124
|
-
case "string":
|
|
125
|
-
if (typeof v !== "string") return false;
|
|
126
|
-
break;
|
|
127
|
-
case "boolean": return typeof v === "boolean";
|
|
128
|
-
}
|
|
129
|
-
const g = b.guard;
|
|
130
|
-
if (!g) return true;
|
|
131
|
-
if (g.kind === "regex") return new RegExp(`^(?:${g.pattern})$`, g.flags).test(v);
|
|
132
|
-
const integral = b.domain !== "number";
|
|
133
|
-
const x = integral ? BigInt(v) : v;
|
|
134
|
-
const lo = bound(g.lower.value, integral);
|
|
135
|
-
const hi = bound(g.upper.value, integral);
|
|
136
|
-
const aboveLower = g.lower.inclusive ? x >= lo : x > lo;
|
|
137
|
-
const belowUpper = g.upper.inclusive ? x <= hi : x < hi;
|
|
138
|
-
return aboveLower && belowUpper;
|
|
139
|
-
}
|
|
140
|
-
function checkedRung(input) {
|
|
141
|
-
const { module, fn, property } = input;
|
|
142
|
-
const base = {
|
|
143
|
-
module,
|
|
144
|
-
function: fn.name,
|
|
145
|
-
property: property.name,
|
|
146
|
-
text: property.text
|
|
147
|
-
};
|
|
148
|
-
const unknown = (cause, reason) => ({
|
|
149
|
-
...base,
|
|
150
|
-
kind: "UNKNOWN",
|
|
151
|
-
cause,
|
|
152
|
-
reason,
|
|
153
|
-
assumptions: []
|
|
154
|
-
});
|
|
155
|
-
if (input.unobservable) return unknown("unavailable", `calls to ${fn.name} could not be observed: ${input.unobservable}`);
|
|
156
|
-
const predicate = input.predicate;
|
|
157
|
-
if (!predicate) return unknown("unavailable", "the property's predicate was not compiled");
|
|
158
|
-
const binders = property.property.binders;
|
|
159
|
-
const positions = [];
|
|
160
|
-
for (const b of binders) {
|
|
161
|
-
const at = fn.params.indexOf(b.name);
|
|
162
|
-
if (at < 0) return unknown("unsupported", `binder ${b.name} is not a parameter of ${fn.name}, so the inputs the simulator passed do not determine it`);
|
|
163
|
-
positions.push(at);
|
|
164
|
-
}
|
|
165
|
-
const seen = /* @__PURE__ */ new Set();
|
|
166
|
-
let held = 0;
|
|
167
|
-
let discarded = 0;
|
|
168
|
-
for (const call of input.calls) {
|
|
169
|
-
const values = positions.map((p) => call.args[p]);
|
|
170
|
-
const key = values.map(render).join(", ");
|
|
171
|
-
if (seen.has(key)) continue;
|
|
172
|
-
seen.add(key);
|
|
173
|
-
if (!binders.every((b, i) => inDomain(b, values[i]))) {
|
|
174
|
-
discarded++;
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
const counterexample = (error) => ({
|
|
178
|
-
binders: binders.map((b, i) => ({
|
|
179
|
-
name: b.name,
|
|
180
|
-
value: render(values[i])
|
|
181
|
-
})),
|
|
182
|
-
call: `${fn.name}(${call.args.map(render).join(", ")})`,
|
|
183
|
-
...error === void 0 ? {} : { error }
|
|
184
|
-
});
|
|
185
|
-
let outcome;
|
|
186
|
-
try {
|
|
187
|
-
outcome = predicate(...values);
|
|
188
|
-
} catch (err) {
|
|
189
|
-
if (err instanceof AtomNotBoolean || err instanceof ReferenceError) return unknown("unsupported", `the property could not be evaluated: ${String(err)}`);
|
|
190
|
-
return {
|
|
191
|
-
...base,
|
|
192
|
-
kind: "REFUTED",
|
|
193
|
-
rung: "CHECKED",
|
|
194
|
-
counterexample: counterexample(String(err)),
|
|
195
|
-
assumptions: []
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
if (outcome === "refuted") return {
|
|
199
|
-
...base,
|
|
200
|
-
kind: "REFUTED",
|
|
201
|
-
rung: "CHECKED",
|
|
202
|
-
counterexample: counterexample(),
|
|
203
|
-
assumptions: []
|
|
204
|
-
};
|
|
205
|
-
if (outcome === "discarded") discarded++;
|
|
206
|
-
else held++;
|
|
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}`;
|
|
207
70
|
}
|
|
208
|
-
if (held === 0) return unknown("gave_up", input.calls.length === 0 ? `the simulator never called ${fn.name}` : `none of the ${seen.size} distinct input(s) the simulator passed is inside the claim (domains, guards, preconditions)`);
|
|
209
|
-
return {
|
|
210
|
-
...base,
|
|
211
|
-
kind: "CHECKED",
|
|
212
|
-
inputs: held,
|
|
213
|
-
discarded,
|
|
214
|
-
assumptions: [`held on the ${held} distinct input(s) the simulator passed to ${fn.name}; inputs it never passed are not covered`]
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
/** Verdicts for the markers the CHECKED rung cannot decide. */
|
|
218
|
-
function markerVerdicts(module, fn) {
|
|
219
|
-
const out = [];
|
|
220
|
-
const base = {
|
|
221
|
-
module,
|
|
222
|
-
function: fn.name,
|
|
223
|
-
assumptions: []
|
|
224
|
-
};
|
|
225
|
-
if (fn.total) out.push({
|
|
226
|
-
...base,
|
|
227
|
-
property: "@total",
|
|
228
|
-
text: "@total",
|
|
229
|
-
kind: "UNKNOWN",
|
|
230
|
-
cause: "unsupported",
|
|
231
|
-
reason: "termination is not observable on the inputs the simulator passed; @total needs a prover"
|
|
232
|
-
});
|
|
233
|
-
if (fn.throws) out.push({
|
|
234
|
-
...base,
|
|
235
|
-
property: "@throws",
|
|
236
|
-
text: "@throws",
|
|
237
|
-
kind: "UNKNOWN",
|
|
238
|
-
cause: "unsupported",
|
|
239
|
-
reason: "Lemma has not fixed what @throws claims yet"
|
|
240
|
-
});
|
|
241
|
-
return out;
|
|
242
|
-
}
|
|
243
|
-
/** Every spec verdict for one module, from what was observed of its calls. */
|
|
244
|
-
function checkSpecModule(module, specs, predicates, observed) {
|
|
245
|
-
return specs.functions.flatMap((fn) => {
|
|
246
|
-
const calls = observed.calls.filter((c) => c.function === fn.name);
|
|
247
|
-
const unobservable = Object.hasOwn(observed.unobservable, fn.name) ? observed.unobservable[fn.name] : void 0;
|
|
248
|
-
const own = Object.hasOwn(predicates, fn.name) ? predicates[fn.name] : void 0;
|
|
249
|
-
return [...fn.ensures.map((property) => checkedRung({
|
|
250
|
-
module,
|
|
251
|
-
fn,
|
|
252
|
-
property,
|
|
253
|
-
calls,
|
|
254
|
-
predicate: own && Object.hasOwn(own, property.name) ? own[property.name] : void 0,
|
|
255
|
-
...unobservable === void 0 ? {} : { unobservable }
|
|
256
|
-
})), ...markerVerdicts(module, fn)];
|
|
257
|
-
});
|
|
258
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;
|
|
259
79
|
export { LemmaSyntaxError, checkInvariant, checkInvariants, checkSpecModule, checkedRung, describeSpecVerdict, describeVerdict, emitRegressionTest, explore, extractSpecs, lemmaBool, lemmaUnresolved, observeCore, parseProperty, printProperty, renderJson, renderSpecs, renderText, renderTrace, replay, restrictSpec, validateScenario };
|
|
260
80
|
|
|
261
81
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../core/src/spec-verdict.ts","../../spec/src/print.ts","../../prover/src/checked.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 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","/**\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 * The `CHECKED` rung: a property evaluated on every input the simulator\n * actually passed to its function. Binders are matched to the function's\n * parameters by name, so each recorded call is one assignment; a value\n * outside its binder's domain or guard, or one failing a precondition, is\n * outside the claim and discarded. One assignment where the claim is false\n * refutes the property. Holding on all of them is `CHECKED`, which says\n * nothing about inputs the simulator never passed.\n */\n\nimport type { Counterexample, SpecVerdict } from \"@eutaxy/core\";\nimport {\n type Binder,\n endpointNumber,\n type FunctionSpec,\n type ModuleSpecs,\n type NamedProperty,\n type PredicateOutcome,\n} from \"@eutaxy/spec\";\n\n/** Thrown by `lemmaBool` when an atom is not a genuine boolean: the property is malformed, not false. */\nexport class AtomNotBoolean extends TypeError {}\n\n/** Thrown by `lemmaUnresolved`: the property names something neither its module nor the globals define. */\nexport class UnresolvedName extends ReferenceError {}\n\n/** What generated predicates call when free names did not resolve. */\nexport function lemmaUnresolved(names: readonly string[]): never {\n throw new UnresolvedName(\n `the property refers to ${names.join(\", \")}, which neither its module exports nor the globals define`,\n );\n}\n\n/** The atom check generated predicates call: its argument when it is a boolean. */\nexport function lemmaBool(value: unknown): boolean {\n if (typeof value !== \"boolean\")\n throw new AtomNotBoolean(`a Lemma atom evaluated to ${render(value)}, not a boolean`);\n return value;\n}\n\n/** A value as a JavaScript literal, exact for the binder domains. */\nexport function render(value: unknown): string {\n switch (typeof value) {\n case \"bigint\":\n return `${value}n`;\n case \"number\":\n return Object.is(value, -0) ? \"-0\" : String(value);\n case \"string\":\n return JSON.stringify(value);\n case \"undefined\":\n return \"undefined\";\n case \"boolean\":\n return String(value);\n case \"function\":\n return \"[function]\";\n }\n try {\n const text = JSON.stringify(value, (_, v: unknown) => (typeof v === \"bigint\" ? `${v}n` : v));\n return text === undefined ? String(value) : text.length > 200 ? `${text.slice(0, 200)}…` : text;\n } catch {\n return String(value);\n }\n}\n\nfunction bound(value: string, integral: boolean): number | bigint {\n if (integral && !value.endsWith(\"∞\")) return BigInt(value.replace(/_/g, \"\").replace(/n$/, \"\"));\n return endpointNumber(value);\n}\n\n/** Whether a value lies in a binder's domain and guard. */\nexport function inDomain(b: Binder, v: unknown): boolean {\n switch (b.domain) {\n case \"int\":\n if (!(typeof v === \"number\" && Number.isInteger(v))) return false;\n break;\n case \"nat\":\n if (!(typeof v === \"number\" && Number.isInteger(v) && v >= 0)) return false;\n break;\n case \"number\":\n if (typeof v !== \"number\") return false;\n break;\n case \"bigint\":\n if (typeof v !== \"bigint\") return false;\n break;\n case \"string\":\n if (typeof v !== \"string\") return false;\n break;\n case \"boolean\":\n return typeof v === \"boolean\";\n }\n const g = b.guard;\n if (!g) return true;\n if (g.kind === \"regex\") return new RegExp(`^(?:${g.pattern})$`, g.flags).test(v as string);\n // Integer domains compare exactly: an integer double converts to bigint without loss.\n const integral = b.domain !== \"number\";\n const x = integral ? BigInt(v as number | bigint) : (v as number);\n const lo = bound(g.lower.value, integral);\n const hi = bound(g.upper.value, integral);\n const aboveLower = g.lower.inclusive ? x >= lo : x > lo;\n const belowUpper = g.upper.inclusive ? x <= hi : x < hi;\n return aboveLower && belowUpper;\n}\n\nexport interface CheckedInput {\n readonly module: string;\n readonly fn: FunctionSpec;\n readonly property: NamedProperty;\n /** The calls the simulator made, with their arguments. */\n readonly calls: readonly { readonly args: readonly unknown[] }[];\n /** The compiled predicate over the binders, or undefined when it could not be built. */\n readonly predicate: ((...binders: never[]) => PredicateOutcome) | undefined;\n /** Why the function's calls could not be observed, when they could not. */\n readonly unobservable?: string;\n}\n\nexport function checkedRung(input: CheckedInput): SpecVerdict {\n const { module, fn, property } = input;\n const base = { module, function: fn.name, property: property.name, text: property.text };\n const unknown = (\n cause: \"gave_up\" | \"unsupported\" | \"unavailable\",\n reason: string,\n ): SpecVerdict => ({\n ...base,\n kind: \"UNKNOWN\",\n cause,\n reason,\n assumptions: [],\n });\n if (input.unobservable)\n return unknown(\n \"unavailable\",\n `calls to ${fn.name} could not be observed: ${input.unobservable}`,\n );\n const predicate = input.predicate as ((...binders: unknown[]) => PredicateOutcome) | undefined;\n if (!predicate) return unknown(\"unavailable\", \"the property's predicate was not compiled\");\n const binders = property.property.binders;\n const positions: number[] = [];\n for (const b of binders) {\n const at = fn.params.indexOf(b.name);\n if (at < 0)\n return unknown(\n \"unsupported\",\n `binder ${b.name} is not a parameter of ${fn.name}, so the inputs the simulator passed do not determine it`,\n );\n positions.push(at);\n }\n const seen = new Set<string>();\n let held = 0;\n let discarded = 0;\n for (const call of input.calls) {\n const values = positions.map((p) => call.args[p]);\n const key = values.map(render).join(\", \");\n if (seen.has(key)) continue;\n seen.add(key);\n if (!binders.every((b, i) => inDomain(b, values[i]))) {\n discarded++;\n continue;\n }\n const counterexample = (error?: string): Counterexample => ({\n binders: binders.map((b, i) => ({ name: b.name, value: render(values[i]) })),\n call: `${fn.name}(${call.args.map(render).join(\", \")})`,\n ...(error === undefined ? {} : { error }),\n });\n let outcome: PredicateOutcome;\n try {\n outcome = predicate(...values);\n } catch (err) {\n // An atom that is not a boolean, or a name nothing defines, is a malformed property. Any other throw, the function's own\n // included (JSON.parse's SyntaxError, say), means the claim is not true there.\n // A ReferenceError, likewise: compiled TypeScript under test hardly throws one, a name the\n // property's scope analysis missed does, and that must never pass for a refutation.\n if (err instanceof AtomNotBoolean || err instanceof ReferenceError)\n return unknown(\"unsupported\", `the property could not be evaluated: ${String(err)}`);\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"CHECKED\",\n counterexample: counterexample(String(err)),\n assumptions: [],\n };\n }\n\n if (outcome === \"refuted\")\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"CHECKED\",\n counterexample: counterexample(),\n assumptions: [],\n };\n if (outcome === \"discarded\") discarded++;\n else held++;\n }\n if (held === 0)\n return unknown(\n \"gave_up\",\n input.calls.length === 0\n ? `the simulator never called ${fn.name}`\n : `none of the ${seen.size} distinct input(s) the simulator passed is inside the claim (domains, guards, preconditions)`,\n );\n return {\n ...base,\n kind: \"CHECKED\",\n inputs: held,\n discarded,\n assumptions: [\n `held on the ${held} distinct input(s) the simulator passed to ${fn.name}; inputs it never passed are not covered`,\n ],\n };\n}\n\n/** Verdicts for the markers the CHECKED rung cannot decide. */\nexport function markerVerdicts(module: string, fn: FunctionSpec): SpecVerdict[] {\n const out: SpecVerdict[] = [];\n const base = { module, function: fn.name, assumptions: [] };\n if (fn.total)\n out.push({\n ...base,\n property: \"@total\",\n text: \"@total\",\n kind: \"UNKNOWN\",\n cause: \"unsupported\",\n reason:\n \"termination is not observable on the inputs the simulator passed; @total needs a prover\",\n });\n if (fn.throws)\n out.push({\n ...base,\n property: \"@throws\",\n text: \"@throws\",\n kind: \"UNKNOWN\",\n cause: \"unsupported\",\n reason: \"Lemma has not fixed what @throws claims yet\",\n });\n return out;\n}\n\n/** Compiled predicates of a module, by function and property name. */\nexport interface ModulePredicates {\n readonly [fn: string]: { readonly [property: string]: (...binders: never[]) => PredicateOutcome };\n}\n\n/** Every spec verdict for one module, from what was observed of its calls. */\nexport function checkSpecModule(\n module: string,\n specs: ModuleSpecs,\n predicates: ModulePredicates,\n observed: {\n readonly calls: readonly { readonly function: string; readonly args: readonly unknown[] }[];\n readonly unobservable: { readonly [fn: string]: string };\n },\n): SpecVerdict[] {\n return specs.functions.flatMap((fn) => {\n const calls = observed.calls.filter((c) => c.function === fn.name);\n // Own properties only: a function named toString must not find Object.prototype's.\n const unobservable = Object.hasOwn(observed.unobservable, fn.name)\n ? observed.unobservable[fn.name]\n : undefined;\n const own = Object.hasOwn(predicates, fn.name) ? predicates[fn.name] : undefined;\n return [\n ...fn.ensures.map((property) =>\n checkedRung({\n module,\n fn,\n property,\n calls,\n predicate: own && Object.hasOwn(own, property.name) ? own[property.name] : undefined,\n ...(unobservable === undefined ? {} : { unobservable }),\n }),\n ),\n ...markerVerdicts(module, fn),\n ];\n });\n}\n"],"mappings":";;;;;;AAoDA,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;;ACrDA,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,UAAU,KAAA,KAAc,EAAE,UAAU,KAAA,KAAa,UAAU,EAAE,KAAK,MAAM,UAAU,EAAE,KAAK;AAEhG;AAEA,SAAS,WAAW,SAAoC;CACtD,MAAM,SAAqB,CAAC;CAC5B,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,OAAO,OAAO,OAAO,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C,IAAI,EAAE,aAAa;EACvD,CAAC,CACH,GACA,GAAG,eAAe,QAAQ,EAAE,CAC9B;CACF,CAAC;AACH"}
|
|
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,UAAU,KAAA,KAAc,EAAE,UAAU,KAAA,KAAa,UAAU,EAAE,KAAK,MAAM,UAAU,EAAE,KAAK;AAEhG;AAEA,SAAS,WAAW,SAAoC;CACtD,MAAM,SAAqB,CAAC;CAC5B,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,OAAO,OAAO,OAAO,SAAS;EACpC,IAAI,QAAQ,UAAU,KAAK,IAAc,CAAC,GAAG,KAAK,KAAK,CAAC;OACnD,OAAO,KAAK,CAAC,CAAC,CAAC;CACtB;CAM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