@cavelang/solver 0.27.14 → 0.29.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/Authors.md +5 -0
- package/License.md +2 -4
- package/README.md +95 -1
- package/dist/src/explain.d.ts +106 -0
- package/dist/src/explain.d.ts.map +1 -0
- package/dist/src/explain.js +256 -0
- package/dist/src/explain.js.map +1 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/model.d.ts +20 -15
- package/dist/src/model.d.ts.map +1 -1
- package/dist/src/solve.d.ts +3 -0
- package/dist/src/solve.d.ts.map +1 -1
- package/dist/src/solve.js +14 -4
- package/dist/src/solve.js.map +1 -1
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/src/validate.js +30 -0
- package/dist/src/validate.js.map +1 -1
- package/dist/src/workflow.d.ts +112 -0
- package/dist/src/workflow.d.ts.map +1 -0
- package/dist/src/workflow.js +420 -0
- package/dist/src/workflow.js.map +1 -0
- package/package.json +15 -4
- package/src/explain.ts +401 -0
- package/src/index.ts +3 -1
- package/src/model.ts +25 -11
- package/src/solve.ts +24 -4
- package/src/validate.ts +31 -0
- package/src/workflow.ts +578 -0
package/Authors.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Authors
|
|
2
|
+
|
|
3
|
+
By adding their name to this file, all listed authors confirm they have copyright over their contributions to this project and are waiving these rights, placing their work in the public domain in accordance with the CC0 1.0 Universal Public Domain Dedication.
|
|
4
|
+
|
|
5
|
+
- Mirek Rusin (Switzerland)
|
package/License.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
2
2
|
|
|
3
|
-
To the extent possible under law, the authors listed in the
|
|
4
|
-
`Authors.md` have waived all copyright and related or neighboring rights to
|
|
5
|
-
this software and associated documentation files (the "Software").
|
|
3
|
+
To the extent possible under law, the authors listed in [Authors.md](./Authors.md) have waived all copyright and related or neighboring rights to this software and associated documentation files (the "Software").
|
|
6
4
|
|
|
7
|
-
For more information, see:
|
|
5
|
+
For more information, please see:
|
|
8
6
|
https://creativecommons.org/publicdomain/zero/1.0/
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ resource limits; canonical model digests; result states; and linear-subset
|
|
|
6
6
|
recognition. It does not depend on Z3, HiGHS, SQLite, or another CAVE package.
|
|
7
7
|
|
|
8
8
|
```ts
|
|
9
|
-
import { Adapter, Model, Solve } from '@cavelang/solver'
|
|
9
|
+
import { Adapter, Explain, Model, Solve } from '@cavelang/solver'
|
|
10
10
|
|
|
11
11
|
const model: Model.t = {
|
|
12
12
|
schema: Model.schema,
|
|
@@ -93,3 +93,97 @@ only then invokes it. Results are disjoint:
|
|
|
93
93
|
A feasible assignment returned after an optimization timeout is `unknown`,
|
|
94
94
|
not `optimal`. A timeout or unsupported capability is never rendered as proof
|
|
95
95
|
that the model is infeasible.
|
|
96
|
+
|
|
97
|
+
## Provenance and explanations
|
|
98
|
+
|
|
99
|
+
Variables, constraints, soft constraints, and objectives may carry a stable
|
|
100
|
+
declaration URI/line/column, exact CAVE evidence row IDs, and scenario input
|
|
101
|
+
IDs. These fields and human descriptions never affect the canonical model
|
|
102
|
+
digest.
|
|
103
|
+
|
|
104
|
+
`Solve.runWithExplanation` wraps any adapter result in versioned, plain JSON.
|
|
105
|
+
The report records the canonical digest, backend/version, resolved limits,
|
|
106
|
+
diagnostics, optional frozen snapshot and authored inputs, assignments,
|
|
107
|
+
evaluated hard and soft constraints, objective contributions, or a mapped
|
|
108
|
+
unsatisfiable core. Cores are explicitly not promised minimal and `unknown`
|
|
109
|
+
keeps its structured reason.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const report = await Solve.runWithExplanation(adapter, model, {
|
|
113
|
+
unsatCore: true,
|
|
114
|
+
limits: { timeoutMs: 2_000 }
|
|
115
|
+
}, {
|
|
116
|
+
snapshot: { transactionTime: '019c…', validTime: '2026-08-01' },
|
|
117
|
+
inputs: [{
|
|
118
|
+
id: 'team-size',
|
|
119
|
+
query: 'system HAS team-size: ?n',
|
|
120
|
+
value: { kind: 'integer', value: '12', unit: 'people' },
|
|
121
|
+
authoredValue: '0.012K people',
|
|
122
|
+
evidenceRowIds: ['019c…'],
|
|
123
|
+
scenarioClaimIds: []
|
|
124
|
+
}]
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
process.stdout.write(Explain.render(report))
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The renderer is a deterministic human view over the same JSON report. Neither
|
|
131
|
+
building nor rendering an explanation writes to the CAVE store.
|
|
132
|
+
|
|
133
|
+
## Backend evaluations
|
|
134
|
+
|
|
135
|
+
Z3 is the only shipped adapter. The [MiniZinc](MINIZINC-EVALUATION.md) and
|
|
136
|
+
[direct HiGHS](HIGHS-EVALUATION.md) evaluations record why neither candidate
|
|
137
|
+
currently crosses the portable boundary. MiniZinc lacks a motivating
|
|
138
|
+
solver-neutral finite-domain schema. HiGHS materially outperforms Z3 on
|
|
139
|
+
representative LP/MIP workloads and is much smaller, but its synchronous
|
|
140
|
+
binary64 wrapper cannot yet honor CAVE's exact-result, cancellation, and
|
|
141
|
+
working-memory contracts.
|
|
142
|
+
|
|
143
|
+
## Verification workflows
|
|
144
|
+
|
|
145
|
+
`Workflow` gives feasibility, optimization, counterexample, and bounded
|
|
146
|
+
sensitivity distinct public semantics while keeping one validated model,
|
|
147
|
+
snapshot context, adapter limits, and result vocabulary.
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { Workflow } from '@cavelang/solver'
|
|
151
|
+
|
|
152
|
+
const feasible = await Workflow.feasibility(adapter, model, {
|
|
153
|
+
limits: { timeoutMs: 2_000 }
|
|
154
|
+
}, context)
|
|
155
|
+
|
|
156
|
+
const best = await Workflow.optimization(adapter, model, {}, context)
|
|
157
|
+
const witness = await Workflow.counterexample(
|
|
158
|
+
adapter, model, 'declared-invariant-id', {}, context
|
|
159
|
+
)
|
|
160
|
+
const boundary = await Workflow.sensitivity(adapter, model, {
|
|
161
|
+
variableId: 'team-size',
|
|
162
|
+
samples: [
|
|
163
|
+
{ sort: 'int', value: '4' },
|
|
164
|
+
{ sort: 'int', value: '8' },
|
|
165
|
+
{ sort: 'int', value: '12' }
|
|
166
|
+
],
|
|
167
|
+
observe: ['architecture'],
|
|
168
|
+
operation: 'optimization',
|
|
169
|
+
maxRuns: 3
|
|
170
|
+
}, {}, context)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Workflows require every real variable to have explicit lower and upper bounds.
|
|
174
|
+
Sensitivity accepts an explicit, typed sample list and refuses more than
|
|
175
|
+
`maxRuns` checks. Its report includes adjacent result transitions and
|
|
176
|
+
contiguous `unknown` regions rather than interpolating across timeouts.
|
|
177
|
+
|
|
178
|
+
Backend model choices are made deterministic with lexicographic objectives in
|
|
179
|
+
stable variable-ID order: false before true, smaller exact numbers first, and
|
|
180
|
+
enum values in lexical order. In optimization, authored objectives retain
|
|
181
|
+
their declared order, explicitly weighted soft constraints follow, and the
|
|
182
|
+
tie-break objectives come last. These generated objectives count against
|
|
183
|
+
`maxObjectives`; the workflow fails preflight rather than silently dropping
|
|
184
|
+
determinism. A merely feasible backend result is never promoted to `optimal`.
|
|
185
|
+
|
|
186
|
+
Counterexample checks replace one declared invariant with its negation. A
|
|
187
|
+
model is a concrete witness; an unsatisfied result means only that the
|
|
188
|
+
invariant holds within the report's named assumptions, bounded domains, and
|
|
189
|
+
declared Boolean/integer/rational/enum theories. `unknown` remains unknown.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Backend, Diagnostic, Limits, Result, UnknownReason } from './adapter.ts';
|
|
2
|
+
import * as Exact from './exact.ts';
|
|
3
|
+
import type { Declaration, Model, Value } from './model.ts';
|
|
4
|
+
export declare const schema: "cave.solver/explanation@1";
|
|
5
|
+
export type Json = null | boolean | number | string | readonly Json[] | {
|
|
6
|
+
readonly [key: string]: Json | undefined;
|
|
7
|
+
};
|
|
8
|
+
export type Snapshot = {
|
|
9
|
+
readonly transactionTime: string | null;
|
|
10
|
+
readonly validTime?: string;
|
|
11
|
+
readonly aliases?: 'exact' | 'closure';
|
|
12
|
+
readonly resolution?: 'coexisting' | 'winner';
|
|
13
|
+
readonly minimumConfidence?: number;
|
|
14
|
+
};
|
|
15
|
+
export type Input = {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly query?: string;
|
|
18
|
+
readonly value?: Json;
|
|
19
|
+
readonly authoredValue?: Json;
|
|
20
|
+
readonly evidenceRowIds: readonly string[];
|
|
21
|
+
readonly scenarioClaimIds: readonly string[];
|
|
22
|
+
};
|
|
23
|
+
export type Scenario = {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly inputDigest: string;
|
|
26
|
+
readonly overlayDigest: string;
|
|
27
|
+
};
|
|
28
|
+
export type Context = {
|
|
29
|
+
/** Reject accidentally replaying bindings against a different model. */
|
|
30
|
+
readonly modelDigest?: string;
|
|
31
|
+
readonly scenario?: Scenario;
|
|
32
|
+
readonly snapshot?: Snapshot;
|
|
33
|
+
readonly inputs?: readonly Input[];
|
|
34
|
+
};
|
|
35
|
+
export type Run = {
|
|
36
|
+
readonly modelDigest: string;
|
|
37
|
+
readonly backend: Backend;
|
|
38
|
+
readonly elapsedMs: number;
|
|
39
|
+
readonly limits: Limits;
|
|
40
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
41
|
+
readonly scenario?: Scenario;
|
|
42
|
+
readonly snapshot?: Snapshot;
|
|
43
|
+
readonly inputs: readonly Input[];
|
|
44
|
+
};
|
|
45
|
+
export type Element = {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly description?: string;
|
|
48
|
+
readonly declaration?: Declaration;
|
|
49
|
+
readonly evidenceRowIds: readonly string[];
|
|
50
|
+
readonly scenarioInputIds: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
export type AssignmentValue = Element & {
|
|
53
|
+
/** False exposes an adapter value that has no matching model declaration. */
|
|
54
|
+
readonly declared: boolean;
|
|
55
|
+
readonly value: Value;
|
|
56
|
+
};
|
|
57
|
+
export type Constraint = Element & {
|
|
58
|
+
readonly evaluation: 'satisfied' | 'violated' | 'indeterminate';
|
|
59
|
+
};
|
|
60
|
+
export type SoftConstraintResult = Element & {
|
|
61
|
+
readonly evaluation: 'accepted' | 'violated' | 'indeterminate';
|
|
62
|
+
readonly weight: ReturnType<typeof Exact.rational>;
|
|
63
|
+
};
|
|
64
|
+
export type ObjectiveResult = Element & {
|
|
65
|
+
/** False exposes an adapter value that has no matching model declaration. */
|
|
66
|
+
readonly declared: boolean;
|
|
67
|
+
readonly direction: 'minimize' | 'maximize' | 'unknown';
|
|
68
|
+
readonly value: Value;
|
|
69
|
+
readonly bound?: Value;
|
|
70
|
+
};
|
|
71
|
+
export type CoreConstraint = Element & {
|
|
72
|
+
/** False means the backend returned an ID absent from the submitted model. */
|
|
73
|
+
readonly declared: boolean;
|
|
74
|
+
};
|
|
75
|
+
type Feasible = {
|
|
76
|
+
readonly assignments: readonly AssignmentValue[];
|
|
77
|
+
readonly hardConstraints: readonly Constraint[];
|
|
78
|
+
readonly softConstraints: readonly SoftConstraintResult[];
|
|
79
|
+
};
|
|
80
|
+
export type Outcome = ({
|
|
81
|
+
readonly status: 'satisfied';
|
|
82
|
+
} & Feasible) | ({
|
|
83
|
+
readonly status: 'optimal';
|
|
84
|
+
readonly objectives: readonly ObjectiveResult[];
|
|
85
|
+
readonly optimalityProved: true;
|
|
86
|
+
} & Feasible) | {
|
|
87
|
+
readonly status: 'unsatisfied';
|
|
88
|
+
readonly core?: readonly CoreConstraint[];
|
|
89
|
+
/** Solver cores explain one contradiction, but are not promised minimal. */
|
|
90
|
+
readonly coreMinimal: false;
|
|
91
|
+
readonly infeasibilityProved: true;
|
|
92
|
+
} | {
|
|
93
|
+
readonly status: 'unknown';
|
|
94
|
+
readonly reason: UnknownReason;
|
|
95
|
+
};
|
|
96
|
+
export type Report = {
|
|
97
|
+
readonly schema: typeof schema;
|
|
98
|
+
readonly run: Run;
|
|
99
|
+
readonly outcome: Outcome;
|
|
100
|
+
};
|
|
101
|
+
/** Build stable JSON data without mutating the model, scenario, or CAVE store. */
|
|
102
|
+
export declare const report: (model: Model, result: Result, limits: Limits, context?: Context) => Report;
|
|
103
|
+
/** Render the same report as concise, deterministic plain text. */
|
|
104
|
+
export declare const render: (value: Report) => string;
|
|
105
|
+
export {};
|
|
106
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../src/explain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAkB,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEtG,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAEV,WAAW,EAGX,KAAK,EAKL,KAAK,EAEN,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,MAAM,EAAG,2BAAoC,CAAA;AAI1D,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,IAAI,EAAE,GAAG;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,CAAA;AAEpH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAA;IAC7C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CACpC,CAAA;AAED,MAAM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
|
3
|
+
export const schema = 'cave.solver/explanation@1';
|
|
4
|
+
const compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
5
|
+
const normalize = (numerator, denominator) => {
|
|
6
|
+
if (denominator === 0n)
|
|
7
|
+
throw new TypeError('cannot explain division by zero');
|
|
8
|
+
const exact = Exact.rational({ numerator: String(numerator), denominator: String(denominator) });
|
|
9
|
+
return { kind: 'number', numerator: BigInt(exact.numerator), denominator: BigInt(exact.denominator) };
|
|
10
|
+
};
|
|
11
|
+
const number = (value) => {
|
|
12
|
+
const exact = Exact.rational(value);
|
|
13
|
+
return { kind: 'number', numerator: BigInt(exact.numerator), denominator: BigInt(exact.denominator) };
|
|
14
|
+
};
|
|
15
|
+
const numeric = (value) => {
|
|
16
|
+
if (value.kind !== 'number')
|
|
17
|
+
throw new TypeError(`expected a numeric explanation value, received ${value.kind}`);
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
const bool = (value) => {
|
|
21
|
+
if (value.kind !== 'bool')
|
|
22
|
+
throw new TypeError(`expected a Boolean explanation value, received ${value.kind}`);
|
|
23
|
+
return value.value;
|
|
24
|
+
};
|
|
25
|
+
const add = (left, right) => normalize(left.numerator * right.denominator + right.numerator * left.denominator, left.denominator * right.denominator);
|
|
26
|
+
const multiply = (left, right) => normalize(left.numerator * right.numerator, left.denominator * right.denominator);
|
|
27
|
+
const compare = (left, right) => {
|
|
28
|
+
const difference = left.numerator * right.denominator - right.numerator * left.denominator;
|
|
29
|
+
return difference < 0n ? -1 : difference > 0n ? 1 : 0;
|
|
30
|
+
};
|
|
31
|
+
const equal = (left, right) => {
|
|
32
|
+
if (left.kind === 'number' && right.kind === 'number')
|
|
33
|
+
return compare(left, right) === 0;
|
|
34
|
+
if (left.kind !== right.kind)
|
|
35
|
+
return false;
|
|
36
|
+
if (left.kind === 'bool' && right.kind === 'bool')
|
|
37
|
+
return left.value === right.value;
|
|
38
|
+
if (left.kind === 'enum' && right.kind === 'enum')
|
|
39
|
+
return left.domain === right.domain && left.value === right.value;
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
const assigned = (value) => {
|
|
43
|
+
switch (value.sort) {
|
|
44
|
+
case 'bool': return { kind: 'bool', value: value.value };
|
|
45
|
+
case 'int': return number({ numerator: value.value, denominator: '1' });
|
|
46
|
+
case 'real': return number({ numerator: value.numerator, denominator: value.denominator });
|
|
47
|
+
case 'enum': return { kind: 'enum', domain: value.domain, value: value.value };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const evaluate = (expression, assignment) => {
|
|
51
|
+
const run = (value) => evaluate(value, assignment);
|
|
52
|
+
switch (expression.kind) {
|
|
53
|
+
case 'literal':
|
|
54
|
+
switch (expression.sort) {
|
|
55
|
+
case 'bool': return { kind: 'bool', value: expression.value };
|
|
56
|
+
case 'int': return number({ numerator: String(Exact.integer(expression.value)), denominator: '1' });
|
|
57
|
+
case 'real': return number(expression.value);
|
|
58
|
+
case 'enum': return { kind: 'enum', domain: expression.domain, value: expression.value };
|
|
59
|
+
}
|
|
60
|
+
case 'variable': {
|
|
61
|
+
const value = assignment[expression.id];
|
|
62
|
+
if (value === undefined)
|
|
63
|
+
throw new TypeError(`assignment omits ${JSON.stringify(expression.id)}`);
|
|
64
|
+
return assigned(value);
|
|
65
|
+
}
|
|
66
|
+
case 'not': return { kind: 'bool', value: !bool(run(expression.value)) };
|
|
67
|
+
case 'and': return { kind: 'bool', value: expression.operands.every(value => bool(run(value))) };
|
|
68
|
+
case 'or': return { kind: 'bool', value: expression.operands.some(value => bool(run(value))) };
|
|
69
|
+
case 'implies': return { kind: 'bool', value: !bool(run(expression.left)) || bool(run(expression.right)) };
|
|
70
|
+
case 'eq': return { kind: 'bool', value: equal(run(expression.left), run(expression.right)) };
|
|
71
|
+
case 'neq': return { kind: 'bool', value: !equal(run(expression.left), run(expression.right)) };
|
|
72
|
+
case 'lt': return { kind: 'bool', value: compare(numeric(run(expression.left)), numeric(run(expression.right))) < 0 };
|
|
73
|
+
case 'lte': return { kind: 'bool', value: compare(numeric(run(expression.left)), numeric(run(expression.right))) <= 0 };
|
|
74
|
+
case 'gt': return { kind: 'bool', value: compare(numeric(run(expression.left)), numeric(run(expression.right))) > 0 };
|
|
75
|
+
case 'gte': return { kind: 'bool', value: compare(numeric(run(expression.left)), numeric(run(expression.right))) >= 0 };
|
|
76
|
+
case 'add': return expression.operands.map(run).map(numeric).reduce(add);
|
|
77
|
+
case 'multiply': return expression.operands.map(run).map(numeric).reduce(multiply);
|
|
78
|
+
case 'subtract': {
|
|
79
|
+
const left = numeric(run(expression.left));
|
|
80
|
+
const right = numeric(run(expression.right));
|
|
81
|
+
return add(left, normalize(-right.numerator, right.denominator));
|
|
82
|
+
}
|
|
83
|
+
case 'divide': {
|
|
84
|
+
const left = numeric(run(expression.left));
|
|
85
|
+
const right = numeric(run(expression.right));
|
|
86
|
+
return normalize(left.numerator * right.denominator, left.denominator * right.numerator);
|
|
87
|
+
}
|
|
88
|
+
case 'negate': {
|
|
89
|
+
const value = numeric(run(expression.value));
|
|
90
|
+
return normalize(-value.numerator, value.denominator);
|
|
91
|
+
}
|
|
92
|
+
case 'if': return bool(run(expression.condition)) ? run(expression.then) : run(expression.else);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const sorted = (values) => [...new Set(values ?? [])].sort();
|
|
96
|
+
const element = (value) => ({
|
|
97
|
+
id: value.id,
|
|
98
|
+
...(value.description === undefined ? {} : { description: value.description }),
|
|
99
|
+
...(value.declaration === undefined ? {} : { declaration: value.declaration }),
|
|
100
|
+
evidenceRowIds: sorted(value.evidenceRowIds),
|
|
101
|
+
scenarioInputIds: sorted(value.scenarioInputIds)
|
|
102
|
+
});
|
|
103
|
+
const constraint = (value, assignment) => {
|
|
104
|
+
let evaluation = 'indeterminate';
|
|
105
|
+
try {
|
|
106
|
+
evaluation = bool(evaluate(value.expression, assignment)) ? 'satisfied' : 'violated';
|
|
107
|
+
}
|
|
108
|
+
catch { /* Keep the solver result usable when a backend uses totalized arithmetic. */ }
|
|
109
|
+
return { ...element(value), evaluation };
|
|
110
|
+
};
|
|
111
|
+
const softConstraint = (value, assignment) => ({
|
|
112
|
+
...element(value),
|
|
113
|
+
evaluation: (() => {
|
|
114
|
+
try {
|
|
115
|
+
return bool(evaluate(value.expression, assignment)) ? 'accepted' : 'violated';
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return 'indeterminate';
|
|
119
|
+
}
|
|
120
|
+
})(),
|
|
121
|
+
weight: Exact.rational(value.weight)
|
|
122
|
+
});
|
|
123
|
+
const assignments = (model, assignment) => {
|
|
124
|
+
const variables = new Map(model.variables.map(variable => [variable.id, variable]));
|
|
125
|
+
return Object.entries(assignment)
|
|
126
|
+
.sort(([left], [right]) => compareText(left, right))
|
|
127
|
+
.map(([id, value]) => {
|
|
128
|
+
const variable = variables.get(id);
|
|
129
|
+
return { ...element(variable ?? { id }), declared: variable !== undefined, value };
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const feasible = (model, assignment) => ({
|
|
133
|
+
assignments: assignments(model, assignment),
|
|
134
|
+
hardConstraints: model.constraints.map(value => constraint(value, assignment)),
|
|
135
|
+
softConstraints: (model.softConstraints ?? []).map(value => softConstraint(value, assignment))
|
|
136
|
+
});
|
|
137
|
+
const objective = (declaration, result) => ({
|
|
138
|
+
...element(declaration ?? { id: result.objectiveId }),
|
|
139
|
+
declared: declaration !== undefined,
|
|
140
|
+
direction: declaration?.direction ?? 'unknown',
|
|
141
|
+
value: result.value,
|
|
142
|
+
...(result.bound === undefined ? {} : { bound: result.bound })
|
|
143
|
+
});
|
|
144
|
+
const outcome = (model, result) => {
|
|
145
|
+
switch (result.status) {
|
|
146
|
+
case 'satisfied': return { status: result.status, ...feasible(model, result.assignment) };
|
|
147
|
+
case 'optimal': {
|
|
148
|
+
const declarations = new Map((model.objectives ?? []).map(value => [value.id, value]));
|
|
149
|
+
return {
|
|
150
|
+
status: result.status,
|
|
151
|
+
...feasible(model, result.assignment),
|
|
152
|
+
objectives: result.objectives.map(value => objective(declarations.get(value.objectiveId), value)),
|
|
153
|
+
optimalityProved: result.optimalityProved
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
case 'unsatisfied': {
|
|
157
|
+
const declarations = new Map(model.constraints.map(value => [value.id, value]));
|
|
158
|
+
return {
|
|
159
|
+
status: result.status,
|
|
160
|
+
...(result.core === undefined ? {} : {
|
|
161
|
+
core: result.core.map(id => {
|
|
162
|
+
const declaration = declarations.get(id);
|
|
163
|
+
return { ...element(declaration ?? { id }), declared: declaration !== undefined };
|
|
164
|
+
})
|
|
165
|
+
}),
|
|
166
|
+
coreMinimal: false,
|
|
167
|
+
infeasibilityProved: result.infeasibilityProved
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
case 'unknown': return { status: result.status, reason: result.reason };
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
/** Build stable JSON data without mutating the model, scenario, or CAVE store. */
|
|
174
|
+
export const report = (model, result, limits, context = {}) => {
|
|
175
|
+
const modelDigest = Canonical.digest(model);
|
|
176
|
+
if (context.modelDigest !== undefined && context.modelDigest !== modelDigest) {
|
|
177
|
+
throw new TypeError(`scenario model digest ${context.modelDigest} does not match ${modelDigest}`);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
schema,
|
|
181
|
+
run: {
|
|
182
|
+
modelDigest,
|
|
183
|
+
backend: result.backend,
|
|
184
|
+
elapsedMs: result.elapsedMs,
|
|
185
|
+
limits,
|
|
186
|
+
diagnostics: result.diagnostics,
|
|
187
|
+
...(context.scenario === undefined ? {} : { scenario: context.scenario }),
|
|
188
|
+
...(context.snapshot === undefined ? {} : { snapshot: context.snapshot }),
|
|
189
|
+
inputs: [...(context.inputs ?? [])].sort((left, right) => compareText(left.id, right.id))
|
|
190
|
+
},
|
|
191
|
+
outcome: outcome(model, result)
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
const evidence = (value) => {
|
|
195
|
+
const parts = [
|
|
196
|
+
value.declaration === undefined ? undefined : `${value.declaration.uri}${value.declaration.line === undefined ? '' : `:${value.declaration.line}${value.declaration.column === undefined ? '' : `:${value.declaration.column}`}`}`,
|
|
197
|
+
value.evidenceRowIds.length === 0 ? undefined : `rows ${value.evidenceRowIds.join(', ')}`,
|
|
198
|
+
value.scenarioInputIds.length === 0 ? undefined : `inputs ${value.scenarioInputIds.join(', ')}`
|
|
199
|
+
].filter((part) => part !== undefined);
|
|
200
|
+
return parts.length === 0 ? '' : ` — ${parts.join('; ')}`;
|
|
201
|
+
};
|
|
202
|
+
const valueText = (value) => {
|
|
203
|
+
switch (value.sort) {
|
|
204
|
+
case 'bool': return String(value.value);
|
|
205
|
+
case 'int': return value.value;
|
|
206
|
+
case 'real': return `${value.numerator}/${value.denominator}`;
|
|
207
|
+
case 'enum': return value.value;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
/** Render the same report as concise, deterministic plain text. */
|
|
211
|
+
export const render = (value) => {
|
|
212
|
+
const lines = [
|
|
213
|
+
`Solver result: ${value.outcome.status}`,
|
|
214
|
+
`Model: ${value.run.modelDigest}`,
|
|
215
|
+
`Backend: ${value.run.backend.name} ${value.run.backend.version}`,
|
|
216
|
+
`Elapsed: ${value.run.elapsedMs} ms`
|
|
217
|
+
];
|
|
218
|
+
if (value.run.snapshot !== undefined) {
|
|
219
|
+
lines.push(`Snapshot: transaction ${value.run.snapshot.transactionTime ?? 'empty'}${value.run.snapshot.validTime === undefined ? '' : `, valid ${value.run.snapshot.validTime}`}`);
|
|
220
|
+
}
|
|
221
|
+
if (value.run.scenario !== undefined)
|
|
222
|
+
lines.push(`Scenario: ${value.run.scenario.id} (${value.run.scenario.inputDigest})`);
|
|
223
|
+
for (const input of value.run.inputs) {
|
|
224
|
+
lines.push(`Input ${input.id}: ${JSON.stringify(input.value)}${input.query === undefined ? '' : ` via ${input.query}`}`);
|
|
225
|
+
}
|
|
226
|
+
switch (value.outcome.status) {
|
|
227
|
+
case 'satisfied':
|
|
228
|
+
case 'optimal':
|
|
229
|
+
for (const assignment of value.outcome.assignments) {
|
|
230
|
+
lines.push(`Assignment ${assignment.id} = ${valueText(assignment.value)}${assignment.declared ? '' : ' (undeclared backend ID)'}${evidence(assignment)}`);
|
|
231
|
+
}
|
|
232
|
+
for (const constraint of value.outcome.hardConstraints) {
|
|
233
|
+
lines.push(`Hard constraint ${constraint.id}: ${constraint.evaluation}${evidence(constraint)}`);
|
|
234
|
+
}
|
|
235
|
+
for (const constraint of value.outcome.softConstraints) {
|
|
236
|
+
lines.push(`Soft constraint ${constraint.id}: ${constraint.evaluation}, weight ${constraint.weight.numerator}/${constraint.weight.denominator}${evidence(constraint)}`);
|
|
237
|
+
}
|
|
238
|
+
if (value.outcome.status === 'optimal') {
|
|
239
|
+
for (const objective of value.outcome.objectives) {
|
|
240
|
+
lines.push(`Objective ${objective.id} (${objective.direction}) = ${valueText(objective.value)}${objective.declared ? '' : ' (undeclared backend ID)'}${evidence(objective)}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
case 'unsatisfied':
|
|
245
|
+
lines.push('Infeasibility proved. Unsatisfiable cores are not necessarily minimal.');
|
|
246
|
+
for (const constraint of value.outcome.core ?? []) {
|
|
247
|
+
lines.push(`Core constraint ${constraint.id}${constraint.declared ? '' : ' (undeclared backend ID)'}${evidence(constraint)}`);
|
|
248
|
+
}
|
|
249
|
+
break;
|
|
250
|
+
case 'unknown':
|
|
251
|
+
lines.push(`Unknown: ${value.outcome.reason.kind} — ${value.outcome.reason.message}`);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return `${lines.join('\n')}\n`;
|
|
255
|
+
};
|
|
256
|
+
//# sourceMappingURL=explain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../../src/explain.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;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,MAAM,CAAC,IAAI,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;YACrF,MAAK;IACT,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;AAChC,CAAC,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Solver-neutral formal reasoning contracts for CAVE.
|
|
2
|
+
* Solver-neutral formal reasoning contracts and bounded workflows for CAVE.
|
|
3
3
|
*
|
|
4
4
|
* This package contains no solver implementation and never imports Z3 or
|
|
5
5
|
* another backend. Adapters receive only validated portable model data.
|
|
@@ -8,8 +8,10 @@ export * as Adapter from './adapter.ts';
|
|
|
8
8
|
export * as Canonical from './canonical.ts';
|
|
9
9
|
export * as Capability from './capability.ts';
|
|
10
10
|
export * as Exact from './exact.ts';
|
|
11
|
+
export * as Explain from './explain.ts';
|
|
11
12
|
export * as Linear from './linear.ts';
|
|
12
13
|
export * as Model from './model.ts';
|
|
13
14
|
export * as Solve from './solve.ts';
|
|
14
15
|
export * as Validate from './validate.ts';
|
|
16
|
+
export * as Workflow from './workflow.ts';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Solver-neutral formal reasoning contracts for CAVE.
|
|
2
|
+
* Solver-neutral formal reasoning contracts and bounded workflows for CAVE.
|
|
3
3
|
*
|
|
4
4
|
* This package contains no solver implementation and never imports Z3 or
|
|
5
5
|
* another backend. Adapters receive only validated portable model data.
|
|
@@ -8,8 +8,10 @@ export * as Adapter from "./adapter.js";
|
|
|
8
8
|
export * as Canonical from "./canonical.js";
|
|
9
9
|
export * as Capability from "./capability.js";
|
|
10
10
|
export * as Exact from "./exact.js";
|
|
11
|
+
export * as Explain from "./explain.js";
|
|
11
12
|
export * as Linear from "./linear.js";
|
|
12
13
|
export * as Model from "./model.js";
|
|
13
14
|
export * as Solve from "./solve.js";
|
|
14
15
|
export * as Validate from "./validate.js";
|
|
16
|
+
export * as Workflow from "./workflow.js";
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
|
package/dist/src/model.d.ts
CHANGED
|
@@ -10,29 +10,37 @@ export type EnumDomain = {
|
|
|
10
10
|
readonly id: string;
|
|
11
11
|
readonly values: readonly string[];
|
|
12
12
|
readonly description?: string;
|
|
13
|
+
readonly declaration?: Declaration;
|
|
13
14
|
};
|
|
14
|
-
export type
|
|
15
|
+
export type Declaration = {
|
|
16
|
+
/** Stable model source. Prefer a repository-relative URI over a machine-local path. */
|
|
17
|
+
readonly uri: string;
|
|
18
|
+
readonly line?: number;
|
|
19
|
+
readonly column?: number;
|
|
20
|
+
};
|
|
21
|
+
export type Provenance = {
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
readonly declaration?: Declaration;
|
|
24
|
+
readonly evidenceRowIds?: readonly string[];
|
|
25
|
+
readonly scenarioInputIds?: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
type VariableDeclaration = {
|
|
15
28
|
readonly id: string;
|
|
29
|
+
} & Provenance;
|
|
30
|
+
export type Variable = VariableDeclaration & ({
|
|
16
31
|
readonly sort: 'bool';
|
|
17
|
-
readonly description?: string;
|
|
18
32
|
} | {
|
|
19
|
-
readonly id: string;
|
|
20
33
|
readonly sort: 'int';
|
|
21
34
|
readonly min: Integer;
|
|
22
35
|
readonly max: Integer;
|
|
23
|
-
readonly description?: string;
|
|
24
36
|
} | {
|
|
25
|
-
readonly id: string;
|
|
26
37
|
readonly sort: 'real';
|
|
27
38
|
readonly min?: Rational;
|
|
28
39
|
readonly max?: Rational;
|
|
29
|
-
readonly description?: string;
|
|
30
40
|
} | {
|
|
31
|
-
readonly id: string;
|
|
32
41
|
readonly sort: 'enum';
|
|
33
42
|
readonly domain: string;
|
|
34
|
-
|
|
35
|
-
};
|
|
43
|
+
});
|
|
36
44
|
export type Literal = {
|
|
37
45
|
readonly kind: 'literal';
|
|
38
46
|
readonly sort: 'bool';
|
|
@@ -84,22 +92,18 @@ export type Expression = Literal | {
|
|
|
84
92
|
readonly then: Expression;
|
|
85
93
|
readonly else: Expression;
|
|
86
94
|
};
|
|
87
|
-
export type HardConstraint = {
|
|
95
|
+
export type HardConstraint = Provenance & {
|
|
88
96
|
readonly id: string;
|
|
89
97
|
readonly expression: Expression;
|
|
90
|
-
readonly description?: string;
|
|
91
|
-
readonly evidenceRowIds?: readonly string[];
|
|
92
98
|
};
|
|
93
99
|
export type SoftConstraint = HardConstraint & {
|
|
94
100
|
/** Deliberate preference weight; never inferred from CAVE confidence. */
|
|
95
101
|
readonly weight: Rational;
|
|
96
102
|
};
|
|
97
|
-
export type Objective = {
|
|
103
|
+
export type Objective = Provenance & {
|
|
98
104
|
readonly id: string;
|
|
99
105
|
readonly direction: 'minimize' | 'maximize';
|
|
100
106
|
readonly expression: Expression;
|
|
101
|
-
readonly description?: string;
|
|
102
|
-
readonly evidenceRowIds?: readonly string[];
|
|
103
107
|
};
|
|
104
108
|
export type Model = {
|
|
105
109
|
readonly schema: typeof schema;
|
|
@@ -127,4 +131,5 @@ export type Value = {
|
|
|
127
131
|
readonly value: string;
|
|
128
132
|
};
|
|
129
133
|
export type Assignment = Readonly<Record<string, Value>>;
|
|
134
|
+
export {};
|
|
130
135
|
//# sourceMappingURL=model.d.ts.map
|