libpetri 2.5.0 → 2.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.
- package/dist/{chunk-FN773SSE.js → chunk-ATT7U5H5.js} +1 -1
- package/dist/chunk-ATT7U5H5.js.map +1 -0
- package/dist/{chunk-H62Z76FY.js → chunk-ETNHEAS6.js} +130 -18
- package/dist/chunk-ETNHEAS6.js.map +1 -0
- package/dist/{chunk-2GAZLDH3.js → chunk-ULX3OG6H.js} +2 -2
- package/dist/debug/index.d.ts +2 -2
- package/dist/debug/index.js +2 -2
- package/dist/doclet/index.d.ts +1 -1
- package/dist/doclet/index.js +3 -3
- package/dist/dot-exporter-TYC6FUAD.js +8 -0
- package/dist/{event-store-z30VMn0T.d.ts → event-store-E_ahsEc9.d.ts} +1 -1
- package/dist/export/index.d.ts +1 -1
- package/dist/export/index.js +2 -2
- package/dist/index.d.ts +29 -4
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/{petri-net-DXdpd0r5.d.ts → petri-net-C3asscb4.d.ts} +8 -1
- package/dist/verification/index.d.ts +39 -34
- package/dist/verification/index.js +7 -17
- package/dist/verification/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-FN773SSE.js.map +0 -1
- package/dist/chunk-H62Z76FY.js.map +0 -1
- package/dist/dot-exporter-7YDFCBKC.js +0 -8
- /package/dist/{chunk-2GAZLDH3.js.map → chunk-ULX3OG6H.js.map} +0 -0
- /package/dist/{dot-exporter-7YDFCBKC.js.map → dot-exporter-TYC6FUAD.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/timing.ts"],"sourcesContent":["/**\n * Firing timing specification for transitions.\n *\n * Based on classical Time Petri Net (TPN) semantics:\n * - Transition CANNOT fire before earliest time (lower bound)\n * - Transition MUST fire by deadline OR become disabled (upper bound)\n *\n * All durations are in milliseconds.\n */\nexport type Timing = TimingImmediate | TimingDeadline | TimingDelayed | TimingWindow | TimingExact;\n\nexport interface TimingImmediate {\n readonly type: 'immediate';\n}\n\nexport interface TimingDeadline {\n readonly type: 'deadline';\n /** Deadline in milliseconds. Must be positive. */\n readonly byMs: number;\n}\n\nexport interface TimingDelayed {\n readonly type: 'delayed';\n /** Minimum delay in milliseconds. Must be non-negative. */\n readonly afterMs: number;\n}\n\nexport interface TimingWindow {\n readonly type: 'window';\n /** Earliest firing time in milliseconds. Must be non-negative. */\n readonly earliestMs: number;\n /** Latest firing time in milliseconds. Must be >= earliestMs. */\n readonly latestMs: number;\n}\n\nexport interface TimingExact {\n readonly type: 'exact';\n /** Exact firing time in milliseconds. Must be non-negative. */\n readonly atMs: number;\n}\n\n/** ~100 years in milliseconds, used for \"unconstrained\" intervals. */\nexport const MAX_DURATION_MS = 365 * 100 * 24 * 60 * 60 * 1000;\n\n// ==================== Factory Functions ====================\n\n/** Immediate firing: can fire as soon as enabled, no deadline. [0, inf) */\nexport function immediate(): TimingImmediate {\n return { type: 'immediate' };\n}\n\n/** Immediate with deadline: can fire immediately, must fire by deadline. [0, by] */\nexport function deadline(byMs: number): TimingDeadline {\n if (byMs <= 0) {\n throw new Error(`Deadline must be positive: ${byMs}`);\n }\n return { type: 'deadline', byMs };\n}\n\n/** Delayed firing: must wait, then can fire anytime. [after, inf) */\nexport function delayed(afterMs: number): TimingDelayed {\n if (afterMs < 0) {\n throw new Error(`Delay must be non-negative: ${afterMs}`);\n }\n return { type: 'delayed', afterMs };\n}\n\n/** Time window: can fire within [earliest, latest]. */\nexport function window(earliestMs: number, latestMs: number): TimingWindow {\n if (earliestMs < 0) {\n throw new Error(`Earliest must be non-negative: ${earliestMs}`);\n }\n if (latestMs < earliestMs) {\n throw new Error(`Latest (${latestMs}) must be >= earliest (${earliestMs})`);\n }\n return { type: 'window', earliestMs, latestMs };\n}\n\n/**\n * Exact timing: targets the specified time (interval `[at, at]`).\n *\n * The zero-width interval is precise for verification/simulation. Under wall-clock execution it\n * is enforced *softly* — the transition fires at the first opportunity at or after `atMs` (like\n * {@link delayed}) and is never force-disabled for being observed late (TIME-006). Prefer\n * {@link delayed} for a plain lower bound, or {@link window} for a hard bounded window.\n */\nexport function exact(atMs: number): TimingExact {\n if (atMs < 0) {\n throw new Error(`Exact time must be non-negative: ${atMs}`);\n }\n return { type: 'exact', atMs };\n}\n\n// ==================== Query Functions ====================\n\n/** Returns the earliest time (ms) the transition can fire after enabling. */\nexport function earliest(timing: Timing): number {\n switch (timing.type) {\n case 'immediate': return 0;\n case 'deadline': return 0;\n case 'delayed': return timing.afterMs;\n case 'window': return timing.earliestMs;\n case 'exact': return timing.atMs;\n }\n}\n\n/** Returns the latest time (ms) by which the transition must fire. */\nexport function latest(timing: Timing): number {\n switch (timing.type) {\n case 'immediate': return MAX_DURATION_MS;\n case 'deadline': return timing.byMs;\n case 'delayed': return MAX_DURATION_MS;\n case 'window': return timing.latestMs;\n case 'exact': return timing.atMs;\n }\n}\n\n/** Returns true if this timing has a finite deadline. */\nexport function hasDeadline(timing: Timing): boolean {\n switch (timing.type) {\n case 'immediate': return false;\n case 'deadline': return true;\n case 'delayed': return false;\n case 'window': return true;\n case 'exact': return true;\n }\n}\n"],"mappings":";AA0CO,IAAM,kBAAkB,MAAM,MAAM,KAAK,KAAK,KAAK;AAKnD,SAAS,YAA6B;AAC3C,SAAO,EAAE,MAAM,YAAY;AAC7B;AAGO,SAAS,SAAS,MAA8B;AACrD,MAAI,QAAQ,GAAG;AACb,UAAM,IAAI,MAAM,8BAA8B,IAAI,EAAE;AAAA,EACtD;AACA,SAAO,EAAE,MAAM,YAAY,KAAK;AAClC;AAGO,SAAS,QAAQ,SAAgC;AACtD,MAAI,UAAU,GAAG;AACf,UAAM,IAAI,MAAM,+BAA+B,OAAO,EAAE;AAAA,EAC1D;AACA,SAAO,EAAE,MAAM,WAAW,QAAQ;AACpC;AAGO,SAAS,OAAO,YAAoB,UAAgC;AACzE,MAAI,aAAa,GAAG;AAClB,UAAM,IAAI,MAAM,kCAAkC,UAAU,EAAE;AAAA,EAChE;AACA,MAAI,WAAW,YAAY;AACzB,UAAM,IAAI,MAAM,WAAW,QAAQ,0BAA0B,UAAU,GAAG;AAAA,EAC5E;AACA,SAAO,EAAE,MAAM,UAAU,YAAY,SAAS;AAChD;AAUO,SAAS,MAAM,MAA2B;AAC/C,MAAI,OAAO,GAAG;AACZ,UAAM,IAAI,MAAM,oCAAoC,IAAI,EAAE;AAAA,EAC5D;AACA,SAAO,EAAE,MAAM,SAAS,KAAK;AAC/B;AAKO,SAAS,SAAS,QAAwB;AAC/C,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AAAa,aAAO;AAAA,IACzB,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAW,aAAO,OAAO;AAAA,IAC9B,KAAK;AAAU,aAAO,OAAO;AAAA,IAC7B,KAAK;AAAS,aAAO,OAAO;AAAA,EAC9B;AACF;AAGO,SAAS,OAAO,QAAwB;AAC7C,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AAAa,aAAO;AAAA,IACzB,KAAK;AAAY,aAAO,OAAO;AAAA,IAC/B,KAAK;AAAW,aAAO;AAAA,IACvB,KAAK;AAAU,aAAO,OAAO;AAAA,IAC7B,KAAK;AAAS,aAAO,OAAO;AAAA,EAC9B;AACF;AAGO,SAAS,YAAY,QAAyB;AACnD,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AAAa,aAAO;AAAA,IACzB,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAW,aAAO;AAAA,IACvB,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAS,aAAO;AAAA,EACvB;AACF;","names":[]}
|
|
@@ -240,14 +240,20 @@ function flatTransition(name, source, branchIndex, preVector, postVector, inhibi
|
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
// src/verification/
|
|
244
|
-
function
|
|
245
|
-
return { type: "
|
|
243
|
+
// src/verification/analysis/environment-analysis-mode.ts
|
|
244
|
+
function alwaysAvailable() {
|
|
245
|
+
return { type: "always-available" };
|
|
246
246
|
}
|
|
247
247
|
function bounded(maxTokens) {
|
|
248
|
+
if (maxTokens < 0) throw new Error("maxTokens must be non-negative");
|
|
248
249
|
return { type: "bounded", maxTokens };
|
|
249
250
|
}
|
|
250
|
-
function
|
|
251
|
+
function ignore() {
|
|
252
|
+
return { type: "ignore" };
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/verification/encoding/net-flattener.ts
|
|
256
|
+
function flatten(net, environmentPlaces = /* @__PURE__ */ new Set(), environmentMode = alwaysAvailable()) {
|
|
251
257
|
const allPlacesSet = /* @__PURE__ */ new Map();
|
|
252
258
|
for (const p of net.places) {
|
|
253
259
|
allPlacesSet.set(p.name, p);
|
|
@@ -271,10 +277,21 @@ function flatten(net, environmentPlaces = /* @__PURE__ */ new Set(), environment
|
|
|
271
277
|
placeIndex.set(places[i].name, i);
|
|
272
278
|
}
|
|
273
279
|
const environmentBounds = /* @__PURE__ */ new Map();
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
280
|
+
const environmentInjection = /* @__PURE__ */ new Map();
|
|
281
|
+
switch (environmentMode.type) {
|
|
282
|
+
case "always-available":
|
|
283
|
+
for (const ep of environmentPlaces) {
|
|
284
|
+
environmentInjection.set(ep.place.name, null);
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
case "bounded":
|
|
288
|
+
for (const ep of environmentPlaces) {
|
|
289
|
+
environmentBounds.set(ep.place.name, environmentMode.maxTokens);
|
|
290
|
+
environmentInjection.set(ep.place.name, environmentMode.maxTokens);
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
case "ignore":
|
|
294
|
+
break;
|
|
278
295
|
}
|
|
279
296
|
const n = places.length;
|
|
280
297
|
const flatTransitions = [];
|
|
@@ -332,7 +349,8 @@ function flatten(net, environmentPlaces = /* @__PURE__ */ new Set(), environment
|
|
|
332
349
|
places,
|
|
333
350
|
placeIndex,
|
|
334
351
|
transitions: flatTransitions,
|
|
335
|
-
environmentBounds
|
|
352
|
+
environmentBounds,
|
|
353
|
+
environmentInjection
|
|
336
354
|
};
|
|
337
355
|
}
|
|
338
356
|
function enumerateOutputBranches(t) {
|
|
@@ -358,6 +376,13 @@ var IncidenceMatrix = class _IncidenceMatrix {
|
|
|
358
376
|
}
|
|
359
377
|
/**
|
|
360
378
|
* Computes the incidence matrix from a FlatNet.
|
|
379
|
+
*
|
|
380
|
+
* Environment-injected places (VER-006) each contribute one extra **injector
|
|
381
|
+
* column** (a virtual transition that produces one token into that place and
|
|
382
|
+
* consumes nothing). This makes P-invariant computation env-aware: a valid
|
|
383
|
+
* invariant `y` must satisfy `y^T·C = 0` for the injector column too, forcing
|
|
384
|
+
* `y[envPlace] = 0` and thereby discarding closed-net conservation laws (e.g.
|
|
385
|
+
* `IN + OUT = const`) that would otherwise vacuously bound an injectable place.
|
|
361
386
|
*/
|
|
362
387
|
static from(flatNet) {
|
|
363
388
|
const T = flatNet.transitions.length;
|
|
@@ -379,7 +404,21 @@ var IncidenceMatrix = class _IncidenceMatrix {
|
|
|
379
404
|
post.push(postRow);
|
|
380
405
|
incidence.push(incRow);
|
|
381
406
|
}
|
|
382
|
-
|
|
407
|
+
let injectorCount = 0;
|
|
408
|
+
for (const name of flatNet.environmentInjection.keys()) {
|
|
409
|
+
const idx = flatNet.placeIndex.get(name);
|
|
410
|
+
if (idx == null) continue;
|
|
411
|
+
const preRow = new Array(P).fill(0);
|
|
412
|
+
const postRow = new Array(P).fill(0);
|
|
413
|
+
const incRow = new Array(P).fill(0);
|
|
414
|
+
postRow[idx] = 1;
|
|
415
|
+
incRow[idx] = 1;
|
|
416
|
+
pre.push(preRow);
|
|
417
|
+
post.push(postRow);
|
|
418
|
+
incidence.push(incRow);
|
|
419
|
+
injectorCount++;
|
|
420
|
+
}
|
|
421
|
+
return new _IncidenceMatrix(pre, post, incidence, T + injectorCount, P);
|
|
383
422
|
}
|
|
384
423
|
/**
|
|
385
424
|
* Returns C^T (transpose of incidence matrix), dimensions [P][T].
|
|
@@ -824,6 +863,11 @@ function encode(ctx, fp, flatNet, initialMarking, property, invariants, sinkPlac
|
|
|
824
863
|
const ft = flatNet.transitions[t];
|
|
825
864
|
encodeTransitionRule(ctx, fp, reachable, ft, flatNet, invariants, P);
|
|
826
865
|
}
|
|
866
|
+
for (const [name, bound] of flatNet.environmentInjection) {
|
|
867
|
+
const idx = flatNet.placeIndex.get(name);
|
|
868
|
+
if (idx == null) continue;
|
|
869
|
+
encodeInjectionRule(ctx, fp, reachable, idx, bound, P);
|
|
870
|
+
}
|
|
827
871
|
encodeErrorRule(ctx, fp, reachable, error, flatNet, property, sinkPlaces, P);
|
|
828
872
|
return {
|
|
829
873
|
errorExpr: error.call(),
|
|
@@ -860,14 +904,56 @@ function encodeTransitionRule(ctx, fp, reachable, ft, flatNet, invariants, P) {
|
|
|
860
904
|
const qRule = ctx.ForAll(allVars, rule);
|
|
861
905
|
fp.addRule(qRule, `t_${ft.name}`);
|
|
862
906
|
}
|
|
863
|
-
function
|
|
907
|
+
function encodeInjectionRule(ctx, fp, reachable, idx, bound, P) {
|
|
908
|
+
const Int = ctx.Int;
|
|
909
|
+
const mVars = [];
|
|
910
|
+
const mPrimeVars = [];
|
|
911
|
+
for (let i = 0; i < P; i++) {
|
|
912
|
+
mVars.push(Int.const(`m${i}`));
|
|
913
|
+
mPrimeVars.push(Int.const(`mp${i}`));
|
|
914
|
+
}
|
|
915
|
+
const reachBody = reachable.call(...mVars);
|
|
916
|
+
let fire = ctx.Bool.val(true);
|
|
917
|
+
for (let i = 0; i < P; i++) {
|
|
918
|
+
if (i === idx) {
|
|
919
|
+
fire = ctx.And(fire, mPrimeVars[i].eq(mVars[i].add(1)));
|
|
920
|
+
} else {
|
|
921
|
+
fire = ctx.And(fire, mPrimeVars[i].eq(mVars[i]));
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
const guard = bound === null ? ctx.Bool.val(true) : mVars[idx].lt(bound);
|
|
925
|
+
const body = ctx.And(reachBody, guard, fire);
|
|
926
|
+
const head = reachable.call(...mPrimeVars);
|
|
927
|
+
const qRule = ctx.ForAll([...mVars, ...mPrimeVars], ctx.Implies(body, head));
|
|
928
|
+
fp.addRule(qRule, `env_inject_${idx}`);
|
|
929
|
+
}
|
|
930
|
+
function injectedEnvIndices(flatNet) {
|
|
931
|
+
const out = /* @__PURE__ */ new Map();
|
|
932
|
+
for (const [name, bound] of flatNet.environmentInjection) {
|
|
933
|
+
const idx = flatNet.placeIndex.get(name);
|
|
934
|
+
if (idx != null) out.set(idx, bound);
|
|
935
|
+
}
|
|
936
|
+
return out;
|
|
937
|
+
}
|
|
938
|
+
function encodeEnabled(ctx, ft, flatNet, mVars, P, relaxEnv = false) {
|
|
864
939
|
let result = ctx.Bool.val(true);
|
|
940
|
+
const envInj = relaxEnv ? injectedEnvIndices(flatNet) : void 0;
|
|
865
941
|
for (let p = 0; p < P; p++) {
|
|
866
|
-
|
|
867
|
-
|
|
942
|
+
const pre = ft.preVector[p];
|
|
943
|
+
if (pre <= 0) continue;
|
|
944
|
+
if (envInj?.has(p)) {
|
|
945
|
+
const bound = envInj.get(p);
|
|
946
|
+
if (bound !== null && pre > bound) return ctx.Bool.val(false);
|
|
947
|
+
continue;
|
|
868
948
|
}
|
|
949
|
+
result = ctx.And(result, mVars[p].ge(pre));
|
|
869
950
|
}
|
|
870
951
|
for (const p of ft.readPlaces) {
|
|
952
|
+
if (envInj?.has(p)) {
|
|
953
|
+
const bound = envInj.get(p);
|
|
954
|
+
if (bound !== null && bound < 1) return ctx.Bool.val(false);
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
871
957
|
result = ctx.And(result, mVars[p].ge(1));
|
|
872
958
|
}
|
|
873
959
|
for (const p of ft.inhibitorPlaces) {
|
|
@@ -952,7 +1038,15 @@ function encodePropertyViolation(ctx, flatNet, property, sinkPlaces, mVars, P) {
|
|
|
952
1038
|
function encodeDeadlock(ctx, flatNet, mVars, P) {
|
|
953
1039
|
let deadlock = ctx.Bool.val(true);
|
|
954
1040
|
for (const ft of flatNet.transitions) {
|
|
955
|
-
const enabled = encodeEnabled(
|
|
1041
|
+
const enabled = encodeEnabled(
|
|
1042
|
+
ctx,
|
|
1043
|
+
ft,
|
|
1044
|
+
flatNet,
|
|
1045
|
+
mVars,
|
|
1046
|
+
P,
|
|
1047
|
+
/* relaxEnv */
|
|
1048
|
+
true
|
|
1049
|
+
);
|
|
956
1050
|
deadlock = ctx.And(deadlock, ctx.Not(enabled));
|
|
957
1051
|
}
|
|
958
1052
|
return deadlock;
|
|
@@ -1043,7 +1137,7 @@ var SmtVerifier = class _SmtVerifier {
|
|
|
1043
1137
|
_property = deadlockFree();
|
|
1044
1138
|
_environmentPlaces = /* @__PURE__ */ new Set();
|
|
1045
1139
|
_sinkPlaces = /* @__PURE__ */ new Set();
|
|
1046
|
-
_environmentMode =
|
|
1140
|
+
_environmentMode = alwaysAvailable();
|
|
1047
1141
|
_timeoutMs = 6e4;
|
|
1048
1142
|
static forNet(net) {
|
|
1049
1143
|
return new _SmtVerifier(net);
|
|
@@ -1118,7 +1212,7 @@ var SmtVerifier = class _SmtVerifier {
|
|
|
1118
1212
|
}
|
|
1119
1213
|
report.push(` Result: ${structResultStr}
|
|
1120
1214
|
`);
|
|
1121
|
-
if (this._property.type === "deadlock-free" && this._sinkPlaces.size === 0 && structResult.type === "no-potential-deadlock") {
|
|
1215
|
+
if (this._property.type === "deadlock-free" && this._sinkPlaces.size === 0 && structResult.type === "no-potential-deadlock" && this._environmentPlaces.size === 0) {
|
|
1122
1216
|
report.push("=== RESULT ===\n");
|
|
1123
1217
|
report.push("PROVEN (structural): Deadlock-freedom verified by Commoner's theorem.");
|
|
1124
1218
|
report.push(" All siphons contain initially marked traps.");
|
|
@@ -1168,6 +1262,23 @@ var SmtVerifier = class _SmtVerifier {
|
|
|
1168
1262
|
const queryResult = await runner.query(encoding.errorExpr, encoding.reachableDecl);
|
|
1169
1263
|
switch (queryResult.type) {
|
|
1170
1264
|
case "proven": {
|
|
1265
|
+
if (this._environmentPlaces.size > 0 && this._environmentMode.type === "ignore") {
|
|
1266
|
+
const reason = "environment places present but not modeled (mode=ignore); a proof would be vacuous \u2014 use alwaysAvailable() or bounded(k) to model external injection";
|
|
1267
|
+
report.push(` Status: UNSAT, but vacuous under ignore mode
|
|
1268
|
+
`);
|
|
1269
|
+
report.push("=== RESULT ===\n");
|
|
1270
|
+
report.push(`UNKNOWN: ${reason}`);
|
|
1271
|
+
return buildResult(
|
|
1272
|
+
{ type: "unknown", reason },
|
|
1273
|
+
report.join("\n"),
|
|
1274
|
+
invariants,
|
|
1275
|
+
[],
|
|
1276
|
+
[],
|
|
1277
|
+
[],
|
|
1278
|
+
performance.now() - start,
|
|
1279
|
+
{ places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: invariants.length, structuralResult: structResultStr }
|
|
1280
|
+
);
|
|
1281
|
+
}
|
|
1171
1282
|
report.push(" Status: UNSAT (property holds)\n");
|
|
1172
1283
|
const discoveredInvariants = [];
|
|
1173
1284
|
if (queryResult.invariantFormula != null) {
|
|
@@ -1322,8 +1433,9 @@ export {
|
|
|
1322
1433
|
unreachable,
|
|
1323
1434
|
propertyDescription,
|
|
1324
1435
|
flatTransition,
|
|
1325
|
-
|
|
1436
|
+
alwaysAvailable,
|
|
1326
1437
|
bounded,
|
|
1438
|
+
ignore,
|
|
1327
1439
|
flatten,
|
|
1328
1440
|
IncidenceMatrix,
|
|
1329
1441
|
pInvariant,
|
|
@@ -1343,4 +1455,4 @@ export {
|
|
|
1343
1455
|
isProven,
|
|
1344
1456
|
isViolated
|
|
1345
1457
|
};
|
|
1346
|
-
//# sourceMappingURL=chunk-
|
|
1458
|
+
//# sourceMappingURL=chunk-ETNHEAS6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/out.ts","../src/verification/marking-state.ts","../src/verification/smt-property.ts","../src/verification/encoding/flat-transition.ts","../src/verification/analysis/environment-analysis-mode.ts","../src/verification/encoding/net-flattener.ts","../src/verification/encoding/incidence-matrix.ts","../src/verification/invariant/p-invariant.ts","../src/verification/invariant/p-invariant-computer.ts","../src/verification/invariant/structural-check.ts","../src/verification/z3/spacer-runner.ts","../src/verification/encoding/flat-net.ts","../src/verification/z3/smt-encoder.ts","../src/verification/z3/counterexample-decoder.ts","../src/verification/smt-verifier.ts","../src/verification/smt-verification-result.ts"],"sourcesContent":["import type { Place } from './place.js';\n\n/**\n * Output specification with explicit split semantics.\n * Supports composite structures (XOR of ANDs, AND of XORs, etc.)\n *\n * - And: ALL children must receive tokens\n * - Xor: EXACTLY ONE child receives token\n * - Place: Leaf node representing a single output place\n * - Timeout: Timeout branch that activates if action exceeds duration\n * - ForwardInput: Forward consumed input to output on timeout\n */\nexport type Out = OutAnd | OutXor | OutPlace | OutTimeout | OutForwardInput;\n\nexport interface OutAnd {\n readonly type: 'and';\n readonly children: readonly Out[];\n}\n\nexport interface OutXor {\n readonly type: 'xor';\n readonly children: readonly Out[];\n}\n\nexport interface OutPlace {\n readonly type: 'place';\n readonly place: Place<any>;\n}\n\nexport interface OutTimeout {\n readonly type: 'timeout';\n /** Timeout duration in milliseconds. */\n readonly afterMs: number;\n readonly child: Out;\n}\n\nexport interface OutForwardInput {\n readonly type: 'forward-input';\n readonly from: Place<any>;\n readonly to: Place<any>;\n}\n\n// ==================== Factory Functions ====================\n\n/**\n * AND-split: all children must receive tokens.\n *\n * @example\n * ```ts\n * // AND of XOR branches: one of (A,B) AND one of (C,D)\n * and(xorPlaces(placeA, placeB), xorPlaces(placeC, placeD))\n *\n * // AND with a fixed place + XOR branch\n * and(outPlace(always), xorPlaces(left, right))\n * ```\n */\nexport function and(...children: Out[]): OutAnd {\n if (children.length === 0) {\n throw new Error('AND requires at least 1 child');\n }\n return { type: 'and', children };\n}\n\n/** AND-split from places: all places must receive tokens. */\nexport function andPlaces(...places: Place<any>[]): OutAnd {\n return and(...places.map(outPlace));\n}\n\n/** XOR-split: exactly one child receives token. */\nexport function xor(...children: Out[]): OutXor {\n if (children.length < 2) {\n throw new Error('XOR requires at least 2 children');\n }\n return { type: 'xor', children };\n}\n\n/** XOR-split from places: exactly one place receives token. */\nexport function xorPlaces(...places: Place<any>[]): OutXor {\n return xor(...places.map(outPlace));\n}\n\n/** Leaf output spec for a single place. */\nexport function outPlace(p: Place<any>): OutPlace {\n return { type: 'place', place: p };\n}\n\n/** Timeout output: activates if action exceeds duration. */\nexport function timeout(afterMs: number, child: Out): OutTimeout {\n if (afterMs <= 0) {\n throw new Error(`Timeout must be positive: ${afterMs}`);\n }\n return { type: 'timeout', afterMs, child };\n}\n\n/** Timeout output pointing to a single place. */\nexport function timeoutPlace(afterMs: number, p: Place<any>): OutTimeout {\n return timeout(afterMs, outPlace(p));\n}\n\n/** Forward consumed input value to output place on timeout. */\nexport function forwardInput(from: Place<any>, to: Place<any>): OutForwardInput {\n return { type: 'forward-input', from, to };\n}\n\n// ==================== Helper Functions ====================\n\n/** Collects all leaf places from this output spec (flattened). */\nexport function allPlaces(out: Out): Set<Place<any>> {\n const result = new Set<Place<any>>();\n collectPlaces(out, result);\n return result;\n}\n\nfunction collectPlaces(out: Out, result: Set<Place<any>>): void {\n switch (out.type) {\n case 'place':\n result.add(out.place);\n break;\n case 'forward-input':\n result.add(out.to);\n break;\n case 'and':\n case 'xor':\n for (const child of out.children) {\n collectPlaces(child, result);\n }\n break;\n case 'timeout':\n collectPlaces(out.child, result);\n break;\n }\n}\n\n/**\n * Enumerates all possible output branches for structural analysis.\n *\n * - AND = single branch containing all child places (Cartesian product)\n * - XOR = one branch per alternative child\n * - Nested = Cartesian product for AND, union for XOR\n */\nexport function enumerateBranches(out: Out): ReadonlyArray<ReadonlySet<Place<any>>> {\n switch (out.type) {\n case 'place':\n return [new Set([out.place])];\n\n case 'forward-input':\n return [new Set<Place<any>>([out.to])];\n\n case 'and': {\n let result: Set<Place<any>>[] = [new Set()];\n for (const child of out.children) {\n result = crossProduct(result, enumerateBranches(child) as Set<Place<any>>[]);\n }\n return result;\n }\n\n case 'xor': {\n const result: Set<Place<any>>[] = [];\n for (const child of out.children) {\n result.push(...(enumerateBranches(child) as Set<Place<any>>[]));\n }\n return result;\n }\n\n case 'timeout':\n return enumerateBranches(out.child);\n }\n}\n\nfunction crossProduct(\n a: Set<Place<any>>[],\n b: ReadonlyArray<ReadonlySet<Place<any>>>,\n): Set<Place<any>>[] {\n const result: Set<Place<any>>[] = [];\n for (const setA of a) {\n for (const setB of b) {\n const merged = new Set<Place<any>>(setA);\n for (const p of setB) merged.add(p);\n result.push(merged);\n }\n }\n return result;\n}\n","import type { Place } from '../core/place.js';\n\n/** @internal Symbol key restricting construction to the builder and factory methods. */\nconst MARKING_STATE_KEY = Symbol('MarkingState.internal');\n\n/**\n * Immutable snapshot of a Petri net marking for state space analysis.\n *\n * Maps places (by name) to integer token counts. Only stores places with count > 0.\n * Used for invariant computation and structural verification, not runtime execution.\n */\nexport class MarkingState {\n private readonly tokenCounts: ReadonlyMap<string, number>;\n private readonly placesByName: ReadonlyMap<string, Place<any>>;\n\n /** @internal Use {@link MarkingState.builder} or {@link MarkingState.empty} to create instances. */\n constructor(key: symbol, tokenCounts: Map<string, number>, placesByName: Map<string, Place<any>>) {\n if (key !== MARKING_STATE_KEY) throw new Error('Use MarkingState.builder() to create instances');\n this.tokenCounts = tokenCounts;\n this.placesByName = placesByName;\n }\n\n /** Returns the token count for a place (0 if absent). */\n tokens(place: Place<any>): number {\n return this.tokenCounts.get(place.name) ?? 0;\n }\n\n /** Checks if a place has at least one token. */\n hasTokens(place: Place<any>): boolean {\n return this.tokens(place) > 0;\n }\n\n /** Checks if any of the given places has tokens. */\n hasTokensInAny(places: Iterable<Place<any>>): boolean {\n for (const p of places) {\n if (this.hasTokens(p)) return true;\n }\n return false;\n }\n\n /** Returns all places with tokens > 0. */\n placesWithTokens(): Place<any>[] {\n return [...this.placesByName.values()];\n }\n\n /** Returns the total number of tokens. */\n totalTokens(): number {\n let sum = 0;\n for (const count of this.tokenCounts.values()) sum += count;\n return sum;\n }\n\n /** Checks if no tokens exist anywhere. */\n isEmpty(): boolean {\n return this.tokenCounts.size === 0;\n }\n\n toString(): string {\n if (this.tokenCounts.size === 0) return '{}';\n const entries = [...this.tokenCounts.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, count]) => `${name}:${count}`);\n return `{${entries.join(', ')}}`;\n }\n\n static empty(): MarkingState {\n return new MarkingState(MARKING_STATE_KEY, new Map(), new Map());\n }\n\n static builder(): MarkingStateBuilder {\n return new MarkingStateBuilder();\n }\n}\n\nexport class MarkingStateBuilder {\n private readonly tokenCounts = new Map<string, number>();\n private readonly placesByName = new Map<string, Place<any>>();\n\n /** Sets the token count for a place. */\n tokens(place: Place<any>, count: number): this {\n if (count < 0) throw new Error(`Token count cannot be negative: ${count}`);\n if (count > 0) {\n this.tokenCounts.set(place.name, count);\n this.placesByName.set(place.name, place);\n } else {\n this.tokenCounts.delete(place.name);\n this.placesByName.delete(place.name);\n }\n return this;\n }\n\n /** Adds tokens to a place. */\n addTokens(place: Place<any>, count: number): this {\n if (count < 0) throw new Error(`Token count cannot be negative: ${count}`);\n if (count > 0) {\n const current = this.tokenCounts.get(place.name) ?? 0;\n this.tokenCounts.set(place.name, current + count);\n this.placesByName.set(place.name, place);\n }\n return this;\n }\n\n /** Removes tokens from a place. Throws if insufficient. */\n removeTokens(place: Place<any>, count: number): this {\n const current = this.tokenCounts.get(place.name) ?? 0;\n const newCount = current - count;\n if (newCount < 0) {\n throw new Error(\n `Cannot remove ${count} tokens from ${place.name} (has ${current})`,\n );\n }\n if (newCount === 0) {\n this.tokenCounts.delete(place.name);\n this.placesByName.delete(place.name);\n } else {\n this.tokenCounts.set(place.name, newCount);\n }\n return this;\n }\n\n /** Copies all token counts from another marking state. */\n copyFrom(other: MarkingState): this {\n for (const p of other.placesWithTokens()) {\n this.tokenCounts.set(p.name, other.tokens(p));\n this.placesByName.set(p.name, p);\n }\n return this;\n }\n\n build(): MarkingState {\n return new MarkingState(MARKING_STATE_KEY, new Map(this.tokenCounts), new Map(this.placesByName));\n }\n}\n","import type { Place } from '../core/place.js';\n\n/**\n * Safety properties that can be verified via IC3/PDR.\n *\n * Each property is encoded as an error condition: if a reachable state\n * violates the property, Spacer finds a counterexample. If no violation\n * is reachable, the property is proven.\n */\nexport type SmtProperty = DeadlockFree | MutualExclusion | PlaceBound | Unreachable;\n\n/** Deadlock-freedom: no reachable marking has all transitions disabled. */\nexport interface DeadlockFree {\n readonly type: 'deadlock-free';\n}\n\n/** Mutual exclusion: two places never have tokens simultaneously. */\nexport interface MutualExclusion {\n readonly type: 'mutual-exclusion';\n readonly p1: Place<any>;\n readonly p2: Place<any>;\n}\n\n/** Place bound: a place never exceeds a given token count. */\nexport interface PlaceBound {\n readonly type: 'place-bound';\n readonly place: Place<any>;\n readonly bound: number;\n}\n\n/** Unreachability: the given places never all have tokens simultaneously. */\nexport interface Unreachable {\n readonly type: 'unreachable';\n readonly places: ReadonlySet<Place<any>>;\n}\n\n// Factory functions\n\nexport function deadlockFree(): DeadlockFree {\n return { type: 'deadlock-free' };\n}\n\nexport function mutualExclusion(p1: Place<any>, p2: Place<any>): MutualExclusion {\n return { type: 'mutual-exclusion', p1, p2 };\n}\n\nexport function placeBound(place: Place<any>, bound: number): PlaceBound {\n return { type: 'place-bound', place, bound };\n}\n\nexport function unreachable(places: ReadonlySet<Place<any>>): Unreachable {\n return { type: 'unreachable', places: new Set(places) };\n}\n\n/** Human-readable description of a property. */\nexport function propertyDescription(prop: SmtProperty): string {\n switch (prop.type) {\n case 'deadlock-free':\n return 'Deadlock-freedom';\n case 'mutual-exclusion':\n return `Mutual exclusion of ${prop.p1.name} and ${prop.p2.name}`;\n case 'place-bound':\n return `Place ${prop.place.name} bounded by ${prop.bound}`;\n case 'unreachable':\n return `Unreachability of marking with tokens in {${[...prop.places].map(p => p.name).join(', ')}}`;\n }\n}\n","import type { Transition } from '../../core/transition.js';\n\n/**\n * A flattened transition with pre/post vectors for SMT encoding.\n *\n * Each Transition with XOR outputs is expanded into multiple FlatTransitions\n * (one per branch). Non-XOR transitions map 1:1.\n */\nexport interface FlatTransition {\n /** Display name (e.g. \"Search_b0\", \"Search_b1\"). */\n readonly name: string;\n /** The original transition. */\n readonly source: Transition;\n /** Which XOR branch (-1 if no XOR). */\n readonly branchIndex: number;\n /** Tokens consumed per place (indexed by place index). */\n readonly preVector: readonly number[];\n /** Tokens produced per place (indexed by place index). */\n readonly postVector: readonly number[];\n /** Place indices where inhibitor arcs block firing. */\n readonly inhibitorPlaces: readonly number[];\n /** Place indices requiring a token without consuming. */\n readonly readPlaces: readonly number[];\n /** Place indices set to 0 on firing. */\n readonly resetPlaces: readonly number[];\n /** True at index i means place i uses All/AtLeast semantics. */\n readonly consumeAll: readonly boolean[];\n}\n\nexport function flatTransition(\n name: string,\n source: Transition,\n branchIndex: number,\n preVector: number[],\n postVector: number[],\n inhibitorPlaces: number[],\n readPlaces: number[],\n resetPlaces: number[],\n consumeAll: boolean[],\n): FlatTransition {\n return {\n name,\n source,\n branchIndex,\n preVector,\n postVector,\n inhibitorPlaces,\n readPlaces,\n resetPlaces,\n consumeAll,\n };\n}\n","/**\n * Analysis mode for environment places in state class graph construction.\n */\nexport type EnvironmentAnalysisMode =\n | { readonly type: 'always-available' }\n | { readonly type: 'bounded'; readonly maxTokens: number }\n | { readonly type: 'ignore' };\n\n/** Assumes environment places always have sufficient tokens. */\nexport function alwaysAvailable(): EnvironmentAnalysisMode {\n return { type: 'always-available' };\n}\n\n/** Analyzes with a bounded number of tokens in environment places. */\nexport function bounded(maxTokens: number): EnvironmentAnalysisMode {\n if (maxTokens < 0) throw new Error('maxTokens must be non-negative');\n return { type: 'bounded', maxTokens };\n}\n\n/** Treats environment places as regular places (default). */\nexport function ignore(): EnvironmentAnalysisMode {\n return { type: 'ignore' };\n}\n","/**\n * @module net-flattener\n *\n * Flattens a PetriNet into integer-indexed pre/post vectors for SMT encoding.\n *\n * **XOR expansion**: Transitions with XOR output specs are expanded into multiple\n * flat transitions — one per deterministic branch. Each branch produces tokens to\n * exactly one XOR child's places. This converts non-deterministic output routing\n * into separate transitions that the SMT solver can reason about independently.\n *\n * **Vector construction**: For each flat transition, builds:\n * - `preVector[p]`: tokens consumed from place p (input cardinality)\n * - `postVector[p]`: tokens produced to place p (from the selected branch)\n * - `consumeAll[p]`: true for `all`/`at-least` inputs (consume everything)\n * - Index arrays for inhibitor, read, and reset arcs\n *\n * Places are sorted by name for stable, deterministic indexing across runs.\n */\nimport type { PetriNet } from '../../core/petri-net.js';\nimport type { Place, EnvironmentPlace } from '../../core/place.js';\nimport type { Out } from '../../core/out.js';\nimport type { FlatNet } from './flat-net.js';\nimport { flatTransition } from './flat-transition.js';\nimport { enumerateBranches, allPlaces as outAllPlaces } from '../../core/out.js';\nimport { type EnvironmentAnalysisMode, alwaysAvailable } from '../analysis/environment-analysis-mode.js';\n\n// The SMT path shares the single 3-mode EnvironmentAnalysisMode with the state\n// class graph (VER-006): AlwaysAvailable / Bounded(k) / Ignore. Re-exported here\n// for the encoding barrel so existing `libpetri/verification` consumers resolve it.\nexport { type EnvironmentAnalysisMode, alwaysAvailable, bounded, ignore } from '../analysis/environment-analysis-mode.js';\n\n/**\n * Flattens a PetriNet into a FlatNet suitable for SMT encoding.\n *\n * Flattening involves:\n * 1. Assigning each place a stable integer index (sorted by name)\n * 2. Expanding XOR outputs into separate flat transitions (one per branch)\n * 3. Building pre/post vectors from input/output specs\n * 4. Recording inhibitor, read, and reset arcs\n * 5. Setting environment bounds for bounded analysis mode\n */\nexport function flatten(\n net: PetriNet,\n environmentPlaces: Set<EnvironmentPlace<any>> = new Set(),\n environmentMode: EnvironmentAnalysisMode = alwaysAvailable(),\n): FlatNet {\n // 1. Collect ALL places\n const allPlacesSet = new Map<string, Place<any>>();\n for (const p of net.places) {\n allPlacesSet.set(p.name, p);\n }\n for (const t of net.transitions) {\n for (const inSpec of t.inputSpecs) {\n allPlacesSet.set(inSpec.place.name, inSpec.place);\n }\n if (t.outputSpec !== null) {\n for (const p of outAllPlaces(t.outputSpec)) {\n allPlacesSet.set(p.name, p);\n }\n }\n for (const arc of t.inhibitors) allPlacesSet.set(arc.place.name, arc.place);\n for (const arc of t.reads) allPlacesSet.set(arc.place.name, arc.place);\n for (const arc of t.resets) allPlacesSet.set(arc.place.name, arc.place);\n }\n\n // Sort by name for stable indexing\n const places = [...allPlacesSet.values()].sort((a, b) => a.name.localeCompare(b.name));\n\n const placeIndex = new Map<string, number>();\n for (let i = 0; i < places.length; i++) {\n placeIndex.set(places[i]!.name, i);\n }\n\n // 2. Compute environment bounds (legacy post-cap) and the injection map.\n // The injection map drives the encoder's env-injection rule and the\n // incidence-matrix injector columns; bounds remain a harmless extra cap.\n const environmentBounds = new Map<string, number>();\n const environmentInjection = new Map<string, number | null>();\n switch (environmentMode.type) {\n case 'always-available':\n for (const ep of environmentPlaces) {\n environmentInjection.set(ep.place.name, null);\n }\n break;\n case 'bounded':\n for (const ep of environmentPlaces) {\n environmentBounds.set(ep.place.name, environmentMode.maxTokens);\n environmentInjection.set(ep.place.name, environmentMode.maxTokens);\n }\n break;\n case 'ignore':\n // Not modeled: env places stay ordinary (frozen at their initial count).\n break;\n }\n\n // 3. Expand transitions\n const n = places.length;\n const flatTransitions = [];\n\n for (const transition of net.transitions) {\n const branches = enumerateOutputBranches(transition);\n\n for (let branchIdx = 0; branchIdx < branches.length; branchIdx++) {\n const branchPlaces = branches[branchIdx]!;\n const name = branches.length > 1\n ? `${transition.name}_b${branchIdx}`\n : transition.name;\n\n // Build pre-vector and consumeAll flags\n const preVector = new Array<number>(n).fill(0);\n const consumeAll = new Array<boolean>(n).fill(false);\n\n for (const inSpec of transition.inputSpecs) {\n const idx = placeIndex.get(inSpec.place.name);\n if (idx === undefined) continue;\n\n switch (inSpec.type) {\n case 'one':\n preVector[idx] = 1;\n break;\n case 'exactly':\n preVector[idx] = inSpec.count;\n break;\n case 'all':\n preVector[idx] = 1;\n consumeAll[idx] = true;\n break;\n case 'at-least':\n preVector[idx] = inSpec.minimum;\n consumeAll[idx] = true;\n break;\n }\n }\n\n // Build post-vector from branch output places\n const postVector = new Array<number>(n).fill(0);\n for (const p of branchPlaces) {\n const idx = placeIndex.get(p.name);\n if (idx !== undefined) {\n postVector[idx] = 1;\n }\n }\n\n // Inhibitor places\n const inhibitorPlaces = transition.inhibitors\n .map(arc => placeIndex.get(arc.place.name))\n .filter((idx): idx is number => idx !== undefined);\n\n // Read places\n const readPlaces = transition.reads\n .map(arc => placeIndex.get(arc.place.name))\n .filter((idx): idx is number => idx !== undefined);\n\n // Reset places\n const resetPlaces = transition.resets\n .map(arc => placeIndex.get(arc.place.name))\n .filter((idx): idx is number => idx !== undefined);\n\n flatTransitions.push(flatTransition(\n name,\n transition,\n branches.length > 1 ? branchIdx : -1,\n preVector,\n postVector,\n inhibitorPlaces,\n readPlaces,\n resetPlaces,\n consumeAll,\n ));\n }\n }\n\n return {\n places,\n placeIndex,\n transitions: flatTransitions,\n environmentBounds,\n environmentInjection,\n };\n}\n\nfunction enumerateOutputBranches(t: { outputSpec: Out | null }): ReadonlySet<Place<any>>[] {\n if (t.outputSpec !== null) {\n return enumerateBranches(t.outputSpec) as ReadonlySet<Place<any>>[];\n }\n // No outputs (sink transition)\n return [new Set()];\n}\n","import type { FlatNet } from './flat-net.js';\n\n/**\n * Incidence matrix for a flattened Petri net.\n *\n * The incidence matrix C is defined as C[t][p] = post[t][p] - pre[t][p].\n * It captures the net effect of each transition on each place.\n *\n * P-invariants are solutions to y^T * C = 0, found via null space\n * computation on C^T.\n */\nexport class IncidenceMatrix {\n private readonly _pre: readonly (readonly number[])[];\n private readonly _post: readonly (readonly number[])[];\n private readonly _incidence: readonly (readonly number[])[];\n private readonly _numTransitions: number;\n private readonly _numPlaces: number;\n\n private constructor(\n pre: number[][],\n post: number[][],\n incidence: number[][],\n numTransitions: number,\n numPlaces: number,\n ) {\n this._pre = pre;\n this._post = post;\n this._incidence = incidence;\n this._numTransitions = numTransitions;\n this._numPlaces = numPlaces;\n }\n\n /**\n * Computes the incidence matrix from a FlatNet.\n *\n * Environment-injected places (VER-006) each contribute one extra **injector\n * column** (a virtual transition that produces one token into that place and\n * consumes nothing). This makes P-invariant computation env-aware: a valid\n * invariant `y` must satisfy `y^T·C = 0` for the injector column too, forcing\n * `y[envPlace] = 0` and thereby discarding closed-net conservation laws (e.g.\n * `IN + OUT = const`) that would otherwise vacuously bound an injectable place.\n */\n static from(flatNet: FlatNet): IncidenceMatrix {\n const T = flatNet.transitions.length;\n const P = flatNet.places.length;\n\n const pre: number[][] = [];\n const post: number[][] = [];\n const incidence: number[][] = [];\n\n for (let t = 0; t < T; t++) {\n const ft = flatNet.transitions[t]!;\n const preRow = new Array<number>(P);\n const postRow = new Array<number>(P);\n const incRow = new Array<number>(P);\n\n for (let p = 0; p < P; p++) {\n preRow[p] = ft.preVector[p]!;\n postRow[p] = ft.postVector[p]!;\n incRow[p] = postRow[p]! - preRow[p]!;\n }\n\n pre.push(preRow);\n post.push(postRow);\n incidence.push(incRow);\n }\n\n // Injector columns (one per injected environment place): pre = 0, post = e_p.\n let injectorCount = 0;\n for (const name of flatNet.environmentInjection.keys()) {\n const idx = flatNet.placeIndex.get(name);\n if (idx == null) continue;\n const preRow = new Array<number>(P).fill(0);\n const postRow = new Array<number>(P).fill(0);\n const incRow = new Array<number>(P).fill(0);\n postRow[idx] = 1;\n incRow[idx] = 1;\n pre.push(preRow);\n post.push(postRow);\n incidence.push(incRow);\n injectorCount++;\n }\n\n return new IncidenceMatrix(pre, post, incidence, T + injectorCount, P);\n }\n\n /**\n * Returns C^T (transpose of incidence matrix), dimensions [P][T].\n * Used for P-invariant computation: null space of C^T gives P-invariants.\n */\n transposedIncidence(): number[][] {\n const ct: number[][] = [];\n for (let p = 0; p < this._numPlaces; p++) {\n const row = new Array<number>(this._numTransitions);\n for (let t = 0; t < this._numTransitions; t++) {\n row[t] = this._incidence[t]![p]!;\n }\n ct.push(row);\n }\n return ct;\n }\n\n /** Returns the pre-matrix (tokens consumed). T×P. */\n pre(): readonly (readonly number[])[] { return this._pre; }\n\n /** Returns the post-matrix (tokens produced). T×P. */\n post(): readonly (readonly number[])[] { return this._post; }\n\n /** Returns the incidence matrix C[t][p] = post - pre. T×P. */\n incidence(): readonly (readonly number[])[] { return this._incidence; }\n\n numTransitions(): number { return this._numTransitions; }\n numPlaces(): number { return this._numPlaces; }\n}\n","/**\n * A P-invariant (place invariant) of a Petri net.\n *\n * A P-invariant is a vector y such that y^T * C = 0, where C is the\n * incidence matrix. This means that for any reachable marking M:\n * sum(y_i * M_i) = constant, where constant = sum(y_i * M0_i).\n *\n * P-invariants provide structural bounds on places and are used as\n * strengthening lemmas for the IC3/PDR engine.\n */\nexport interface PInvariant {\n /** Weight vector (one entry per place index). */\n readonly weights: readonly number[];\n /** The invariant value sum(y_i * M0_i). */\n readonly constant: number;\n /** Set of place indices where weight != 0. */\n readonly support: ReadonlySet<number>;\n}\n\nexport function pInvariant(weights: number[], constant: number, support: Set<number>): PInvariant {\n return { weights, constant, support };\n}\n\nexport function pInvariantToString(inv: PInvariant): string {\n const parts: string[] = [];\n for (const i of inv.support) {\n if (inv.weights[i] !== 1) {\n parts.push(`${inv.weights[i]}*p${i}`);\n } else {\n parts.push(`p${i}`);\n }\n }\n return `PInvariant[${parts.join(' + ')} = ${inv.constant}]`;\n}\n","/**\n * @module p-invariant-computer\n *\n * Computes P-invariants of a Petri net via integer Gaussian elimination (Farkas' algorithm).\n *\n * **Algorithm**: A P-invariant is a non-negative integer vector y such that y^T · C = 0\n * (where C is the incidence matrix). This expresses a conservation law: the weighted\n * token sum Σ(y_i · M[i]) is constant across all reachable markings.\n *\n * **Farkas variant**: Constructs the augmented matrix [C^T | I_P] and row-reduces\n * the C^T portion to zero using integer elimination (no floating point). Rows where\n * the C^T part becomes all-zero yield invariant vectors from the identity part.\n * Row normalization by GCD keeps values small during elimination.\n *\n * **Integer Gaussian elimination**: Each elimination step multiplies rows by pivot\n * coefficients (a·row - b·pivotRow) to avoid fractions. This preserves integer\n * arithmetic throughout, critical for exact invariant computation.\n *\n * Invariants are used to strengthen SMT queries (added as constraints on M').\n */\nimport type { FlatNet } from '../encoding/flat-net.js';\nimport type { IncidenceMatrix } from '../encoding/incidence-matrix.js';\nimport type { MarkingState } from '../marking-state.js';\nimport type { PInvariant } from './p-invariant.js';\nimport { pInvariant } from './p-invariant.js';\n\n/**\n * Computes P-invariants of a Petri net via integer Gaussian elimination.\n *\n * P-invariants are non-negative integer vectors y where y^T * C = 0.\n * They express conservation laws: the weighted token sum is constant\n * across all reachable markings.\n *\n * Algorithm: compute the null space of C^T using integer row reduction\n * with an augmented identity matrix (Farkas' algorithm variant).\n */\nexport function computePInvariants(\n matrix: IncidenceMatrix,\n flatNet: FlatNet,\n initialMarking: MarkingState,\n): PInvariant[] {\n const P = matrix.numPlaces();\n const T = matrix.numTransitions();\n\n if (P === 0 || T === 0) return [];\n\n // We want to find y such that y^T * C = 0, i.e., C^T * y = 0\n // Start with augmented matrix [C^T | I_P]\n // Row-reduce C^T part to zero; the I_P part gives the invariant vectors.\n const ct = matrix.transposedIncidence(); // P × T\n\n // Augmented matrix: P rows, T + P columns\n // Use regular numbers (safe for nets with < ~50 places/transitions)\n const cols = T + P;\n const augmented: number[][] = [];\n for (let i = 0; i < P; i++) {\n const row = new Array<number>(cols).fill(0);\n for (let j = 0; j < T; j++) {\n row[j] = ct[i]![j]!;\n }\n row[T + i] = 1; // identity part\n augmented.push(row);\n }\n\n // Integer Gaussian elimination on the C^T part (columns 0..T-1)\n let pivotRow = 0;\n for (let col = 0; col < T && pivotRow < P; col++) {\n // Find pivot (non-zero entry in this column)\n let pivot = -1;\n for (let row = pivotRow; row < P; row++) {\n if (augmented[row]![col] !== 0) {\n pivot = row;\n break;\n }\n }\n if (pivot === -1) continue; // free variable\n\n // Swap pivot row\n if (pivot !== pivotRow) {\n const tmp = augmented[pivotRow]!;\n augmented[pivotRow] = augmented[pivot]!;\n augmented[pivot] = tmp;\n }\n\n // Eliminate this column in all other rows\n for (let row = 0; row < P; row++) {\n if (row === pivotRow || augmented[row]![col] === 0) continue;\n\n const a = augmented[pivotRow]![col]!;\n const b = augmented[row]![col]!;\n\n // row = a*row - b*pivotRow (keeps integers, eliminates col)\n for (let c = 0; c < cols; c++) {\n augmented[row]![c] = a * augmented[row]![c]! - b * augmented[pivotRow]![c]!;\n }\n\n // Normalize by GCD to keep values small\n normalizeRow(augmented[row]!, cols);\n }\n\n pivotRow++;\n }\n\n // Extract invariants: rows where C^T part is all zeros\n const invariants: PInvariant[] = [];\n for (let row = 0; row < P; row++) {\n let isZero = true;\n for (let col = 0; col < T; col++) {\n if (augmented[row]![col] !== 0) {\n isZero = false;\n break;\n }\n }\n if (!isZero) continue;\n\n // Extract the weight vector from the identity part\n const weights = new Array<number>(P);\n let allNonNegative = true;\n let hasPositive = false;\n\n for (let i = 0; i < P; i++) {\n weights[i] = augmented[row]![T + i]!;\n if (weights[i]! < 0) {\n allNonNegative = false;\n break;\n }\n if (weights[i]! > 0) hasPositive = true;\n }\n\n // We want semi-positive invariants (all weights >= 0, at least one > 0)\n if (!allNonNegative) {\n // Try negating\n let allNonPositive = true;\n for (let i = 0; i < P; i++) {\n if (augmented[row]![T + i]! > 0) {\n allNonPositive = false;\n break;\n }\n }\n if (allNonPositive) {\n for (let i = 0; i < P; i++) {\n weights[i] = -augmented[row]![T + i]!;\n }\n hasPositive = true;\n allNonNegative = true;\n }\n }\n\n if (!allNonNegative || !hasPositive) continue;\n\n // Normalize: divide by GCD of weights\n let g = 0;\n for (const w of weights) {\n if (w > 0) g = gcd(g, w);\n }\n if (g > 1) {\n for (let i = 0; i < P; i++) {\n weights[i] = weights[i]! / g;\n }\n }\n\n // Compute support and constant\n const support = new Set<number>();\n let constant = 0;\n for (let i = 0; i < P; i++) {\n if (weights[i] !== 0) {\n support.add(i);\n const place = flatNet.places[i]!;\n constant += weights[i]! * initialMarking.tokens(place);\n }\n }\n\n invariants.push(pInvariant(weights, constant, support));\n }\n\n return invariants;\n}\n\n/**\n * Checks if every place is covered by at least one P-invariant.\n * If true, the net is structurally bounded.\n */\nexport function isCoveredByInvariants(invariants: readonly PInvariant[], numPlaces: number): boolean {\n const covered = new Array<boolean>(numPlaces).fill(false);\n for (const inv of invariants) {\n for (const idx of inv.support) {\n if (idx < numPlaces) covered[idx] = true;\n }\n }\n return covered.every(c => c);\n}\n\nfunction normalizeRow(row: number[], cols: number): void {\n let g = 0;\n for (let c = 0; c < cols; c++) {\n if (row[c] !== 0) {\n g = gcd(g, Math.abs(row[c]!));\n }\n }\n if (g > 1) {\n for (let c = 0; c < cols; c++) {\n row[c] = row[c]! / g;\n }\n }\n}\n\nfunction gcd(a: number, b: number): number {\n while (b !== 0) {\n const t = b;\n b = a % b;\n a = t;\n }\n return a;\n}\n","/**\n * @module structural-check\n *\n * Structural deadlock pre-check using siphon/trap analysis (Commoner's theorem).\n *\n * **Commoner's theorem**: A Petri net is deadlock-free if every siphon contains\n * an initially marked trap.\n *\n * **Siphon**: A set of places S where every transition that outputs to S also\n * inputs from S. Key property: once all places in a siphon become empty,\n * they can never be re-marked. An empty siphon can cause deadlock.\n *\n * **Trap**: A set of places S where every transition that inputs from S also\n * outputs to S. Key property: once any place in a trap is marked,\n * the trap remains marked forever.\n *\n * **Algorithm**: For each place, compute the minimal siphon containing it via\n * fixed-point expansion. For each siphon, find the maximal trap within it\n * (fixed-point contraction). If every siphon contains an initially-marked\n * trap, deadlock-freedom is proven structurally — no SMT query needed.\n *\n * Limited to nets with ≤50 places to bound enumeration cost.\n */\nimport type { FlatNet } from '../encoding/flat-net.js';\nimport type { MarkingState } from '../marking-state.js';\n\nconst MAX_PLACES_FOR_SIPHON_ANALYSIS = 50;\n\n/**\n * Result of structural deadlock check using siphon/trap analysis.\n */\nexport type StructuralCheckResult =\n | { readonly type: 'no-potential-deadlock' }\n | { readonly type: 'potential-deadlock'; readonly siphon: ReadonlySet<number> }\n | { readonly type: 'inconclusive'; readonly reason: string };\n\n/**\n * Structural deadlock pre-check using siphon/trap analysis.\n *\n * Commoner's theorem: a Petri net is deadlock-free if every siphon\n * contains a marked trap.\n *\n * A siphon is a set of places S such that every transition with\n * an output in S also has an input in S. Once empty, a siphon stays empty.\n *\n * A trap is a set of places S such that every transition with\n * an input in S also has an output in S. Once marked, a trap stays marked.\n */\nexport function structuralCheck(flatNet: FlatNet, initialMarking: MarkingState): StructuralCheckResult {\n const P = flatNet.places.length;\n\n if (P === 0) {\n return { type: 'no-potential-deadlock' };\n }\n\n if (P > MAX_PLACES_FOR_SIPHON_ANALYSIS) {\n return { type: 'inconclusive', reason: `Net has ${P} places, siphon enumeration skipped` };\n }\n\n const siphons = findMinimalSiphons(flatNet);\n\n if (siphons.length === 0) {\n return { type: 'no-potential-deadlock' };\n }\n\n for (const siphon of siphons) {\n const trap = findMaximalTrapIn(flatNet, siphon);\n\n if (trap.size === 0 || !isMarked(trap, flatNet, initialMarking)) {\n return { type: 'potential-deadlock', siphon };\n }\n }\n\n return { type: 'no-potential-deadlock' };\n}\n\n/**\n * Finds minimal siphons by checking all non-empty subsets of deadlock-enabling places.\n * Uses a fixed-point approach: start from each place and grow the siphon.\n */\nexport function findMinimalSiphons(flatNet: FlatNet): ReadonlySet<number>[] {\n const P = flatNet.places.length;\n const siphons: Set<number>[] = [];\n\n // Pre-compute: for each place, which transitions have it as output?\n const placeAsOutput: number[][] = [];\n for (let p = 0; p < P; p++) {\n placeAsOutput.push([]);\n }\n\n for (let t = 0; t < flatNet.transitions.length; t++) {\n const ft = flatNet.transitions[t]!;\n for (let p = 0; p < P; p++) {\n if (ft.postVector[p]! > 0) {\n placeAsOutput[p]!.push(t);\n }\n }\n }\n\n for (let startPlace = 0; startPlace < P; startPlace++) {\n const siphon = computeSiphonContaining(startPlace, flatNet, placeAsOutput);\n if (siphon !== null && siphon.size > 0) {\n let isMinimal = true;\n const toRemove: number[] = [];\n for (let i = 0; i < siphons.length; i++) {\n const existing = siphons[i]!;\n if (setsEqual(existing, siphon)) {\n isMinimal = false;\n break;\n }\n if (isSubsetOf(existing, siphon)) {\n isMinimal = false;\n break;\n }\n if (isSubsetOf(siphon, existing)) {\n toRemove.push(i);\n }\n }\n for (let i = toRemove.length - 1; i >= 0; i--) {\n siphons.splice(toRemove[i]!, 1);\n }\n if (isMinimal) {\n siphons.push(siphon);\n }\n }\n }\n\n return siphons;\n}\n\nfunction computeSiphonContaining(\n startPlace: number,\n flatNet: FlatNet,\n placeAsOutput: number[][],\n): Set<number> | null {\n const siphon = new Set<number>();\n siphon.add(startPlace);\n\n let changed = true;\n while (changed) {\n changed = false;\n const snapshot = [...siphon];\n\n for (const p of snapshot) {\n for (const t of placeAsOutput[p]!) {\n const ft = flatNet.transitions[t]!;\n\n let hasInputInSiphon = false;\n for (let q = 0; q < flatNet.places.length; q++) {\n if (ft.preVector[q]! > 0 && siphon.has(q)) {\n hasInputInSiphon = true;\n break;\n }\n }\n\n if (!hasInputInSiphon) {\n let added = false;\n for (let q = 0; q < flatNet.places.length; q++) {\n if (ft.preVector[q]! > 0) {\n if (!siphon.has(q)) {\n siphon.add(q);\n changed = true;\n }\n added = true;\n break;\n }\n }\n if (!added) {\n return null;\n }\n }\n }\n }\n }\n\n return siphon;\n}\n\n/**\n * Finds the maximal trap within a given set of places.\n * Uses fixed-point: start with the full set and remove places that violate the trap condition.\n */\nexport function findMaximalTrapIn(flatNet: FlatNet, places: ReadonlySet<number>): ReadonlySet<number> {\n const trap = new Set(places);\n\n let changed = true;\n while (changed) {\n changed = false;\n const toRemove: number[] = [];\n\n for (const p of trap) {\n let satisfies = true;\n for (let t = 0; t < flatNet.transitions.length; t++) {\n const ft = flatNet.transitions[t]!;\n if (ft.preVector[p]! > 0) {\n let outputsToTrap = false;\n for (const q of trap) {\n if (ft.postVector[q]! > 0) {\n outputsToTrap = true;\n break;\n }\n }\n if (!outputsToTrap) {\n satisfies = false;\n break;\n }\n }\n }\n if (!satisfies) {\n toRemove.push(p);\n }\n }\n\n if (toRemove.length > 0) {\n for (const p of toRemove) trap.delete(p);\n changed = true;\n }\n }\n\n return trap;\n}\n\nfunction isMarked(placeIndices: ReadonlySet<number>, flatNet: FlatNet, marking: MarkingState): boolean {\n for (const idx of placeIndices) {\n const place = flatNet.places[idx]!;\n if (marking.tokens(place) > 0) return true;\n }\n return false;\n}\n\nfunction setsEqual(a: ReadonlySet<number>, b: ReadonlySet<number>): boolean {\n if (a.size !== b.size) return false;\n for (const v of a) {\n if (!b.has(v)) return false;\n }\n return true;\n}\n\nfunction isSubsetOf(sub: ReadonlySet<number>, sup: ReadonlySet<number>): boolean {\n if (sub.size > sup.size) return false;\n for (const v of sub) {\n if (!sup.has(v)) return false;\n }\n return true;\n}\n","import { init } from 'z3-solver';\nimport type { Bool, Expr, FuncDecl } from 'z3-solver';\n\n/**\n * Result of a Spacer query.\n */\nexport type QueryResult = QueryProven | QueryViolated | QueryUnknown;\n\n/** Property proven: no reachable error state (UNSAT). */\nexport interface QueryProven {\n readonly type: 'proven';\n readonly invariantFormula: string | null;\n readonly levelInvariants: readonly string[];\n}\n\n/** Counterexample found (SAT). The answer is the derivation tree. */\nexport interface QueryViolated {\n readonly type: 'violated';\n readonly answer: Expr | null;\n}\n\n/** Solver could not determine (timeout, resource limit). */\nexport interface QueryUnknown {\n readonly type: 'unknown';\n readonly reason: string;\n}\n\n/**\n * The Z3 context and helpers returned by SpacerRunner.create().\n * Exposes the context object for building expressions.\n */\nexport interface SpacerContext {\n /** The Z3 high-level context for building expressions. */\n readonly ctx: ReturnType<Awaited<ReturnType<typeof init>>['Context']>;\n /** The Z3 Fixedpoint solver instance (Spacer engine). Z3 types are complex; using any. */\n readonly fp: any;\n\n /** Queries whether the error state is reachable. */\n query(errorExpr: Bool, reachableDecl?: FuncDecl): Promise<QueryResult>;\n\n /** Releases Z3 resources. */\n dispose(): void;\n}\n\n// Use a type alias for the Z3 context to avoid the deep inference\ntype Z3Context = ReturnType<Awaited<ReturnType<typeof init>>['Context']>;\n\n/**\n * Creates a Spacer runner with the given timeout.\n *\n * Uses Z3's Spacer engine (CHC solver based on IC3/PDR) to prove or\n * disprove safety properties.\n */\nexport async function createSpacerRunner(timeoutMs: number): Promise<SpacerContext> {\n const { Context } = await init();\n const ctx = new Context('main') as Z3Context;\n const fp = new (ctx as any).Fixedpoint() as any;\n\n // Configure Spacer engine\n fp.set('engine', 'spacer');\n if (timeoutMs > 0) {\n fp.set('timeout', Math.min(timeoutMs, 2147483647));\n }\n\n async function query(errorExpr: Bool, reachableDecl?: FuncDecl): Promise<QueryResult> {\n try {\n const status = await fp.query(errorExpr);\n\n if (status === 'unsat') {\n let invariantFormula: string | null = null;\n const levelInvariants: string[] = [];\n\n try {\n const answer = fp.getAnswer();\n if (answer != null) {\n invariantFormula = answer.toString();\n }\n } catch {\n // Some configurations don't produce answers\n }\n\n if (reachableDecl != null) {\n try {\n const levels = fp.getNumLevels(reachableDecl);\n for (let i = 0; i < levels; i++) {\n const cover = fp.getCoverDelta(i, reachableDecl);\n if (cover != null && !(ctx as any).isTrue(cover)) {\n levelInvariants.push(`Level ${i}: ${cover.toString()}`);\n }\n }\n } catch {\n // Level queries may not be available\n }\n }\n\n return { type: 'proven', invariantFormula, levelInvariants };\n }\n\n if (status === 'sat') {\n let answer: Expr | null = null;\n try {\n answer = fp.getAnswer();\n } catch {\n // Some configurations don't produce answers\n }\n return { type: 'violated', answer };\n }\n\n // unknown\n return { type: 'unknown', reason: fp.getReasonUnknown() };\n } catch (e: any) {\n return { type: 'unknown', reason: `Z3 exception: ${e.message ?? e}` };\n }\n }\n\n function dispose(): void {\n try {\n fp.release();\n } catch {\n // ignore\n }\n }\n\n return {\n ctx,\n fp,\n query,\n dispose,\n } as SpacerContext;\n}\n","import type { Place } from '../../core/place.js';\nimport type { FlatTransition } from './flat-transition.js';\n\n/**\n * A flattened Petri net with indexed places and XOR-expanded transitions.\n *\n * Intermediate representation between the high-level PetriNet and Z3 CHC encoding.\n */\nexport interface FlatNet {\n /** Ordered list of places (index = position). */\n readonly places: readonly Place<any>[];\n /** Reverse lookup: place name -> index. */\n readonly placeIndex: ReadonlyMap<string, number>;\n /** XOR-expanded flat transitions. */\n readonly transitions: readonly FlatTransition[];\n /** For bounded environment places: place name -> max tokens. */\n readonly environmentBounds: ReadonlyMap<string, number>;\n /**\n * Environment places whose tokens the analysis MODELS as externally injected\n * (VER-006). Maps env place name -> injection bound: a number caps injection\n * (`Bounded(k)`), `null` means unbounded (`AlwaysAvailable`). Absent entries\n * (incl. `Ignore` mode) are not injected. The encoder emits one injection CHC\n * rule per entry and the incidence matrix gains one injector column per entry\n * so closed-net P-invariants over these places are correctly discarded.\n */\n readonly environmentInjection: ReadonlyMap<string, number | null>;\n}\n\nexport function flatNetPlaceCount(net: FlatNet): number {\n return net.places.length;\n}\n\nexport function flatNetTransitionCount(net: FlatNet): number {\n return net.transitions.length;\n}\n\nexport function flatNetIndexOf(net: FlatNet, place: Place<any>): number {\n return net.placeIndex.get(place.name) ?? -1;\n}\n","/**\n * @module smt-encoder\n *\n * Encodes a flattened Petri net as Constrained Horn Clauses (CHC) for Z3's Spacer engine.\n *\n * **CHC encoding strategy**: The net's state space is modeled as integer vectors\n * (one variable per place = token count). Three rule types:\n *\n * 1. **Init**: `Reachable(M0)` — the initial marking is reachable\n * 2. **Transition**: `Reachable(M') :- Reachable(M) ∧ enabled(M,t) ∧ fire(M,M',t)` —\n * one rule per flat transition (XOR branches are separate transitions)\n * 3. **Error**: `Error() :- Reachable(M) ∧ violation(M)` — safety property violation\n *\n * Transition rules include: non-negativity constraints on M', P-invariant strengthening\n * clauses, and environment bounds for bounded analysis.\n *\n * Z3 types are complex and partially untyped; the ctx/fp parameters use `any`.\n */\nimport type { Arith, Bool, FuncDecl } from 'z3-solver';\nimport type { FlatNet } from '../encoding/flat-net.js';\nimport type { FlatTransition } from '../encoding/flat-transition.js';\nimport type { MarkingState } from '../marking-state.js';\nimport type { SmtProperty } from '../smt-property.js';\nimport type { PInvariant } from '../invariant/p-invariant.js';\nimport type { Place } from '../../core/place.js';\nimport { flatNetIndexOf } from '../encoding/flat-net.js';\n\n/** Z3 high-level context. Typed as `any` because z3-solver's TS types are incomplete. */\ntype Z3Context = any;\n/** Z3 Fixedpoint solver instance. Typed as `any` because z3-solver's TS types are incomplete. */\ntype Z3Fixedpoint = any;\n\n/**\n * Result of CHC encoding.\n */\nexport interface EncodingResult {\n readonly errorExpr: Bool;\n readonly reachableDecl: FuncDecl;\n}\n\n/**\n * Encodes a flattened Petri net as Constrained Horn Clauses (CHC) for Z3's Spacer engine.\n *\n * CHC rules:\n * - Reachable(M0) — initial state is reachable\n * - Reachable(M') :- Reachable(M) AND enabled(M,t) AND fire(M,M',t) — transition rules\n * - Error() :- Reachable(M) AND property_violation(M) — safety property\n */\nexport function encode(\n ctx: Z3Context,\n fp: Z3Fixedpoint,\n flatNet: FlatNet,\n initialMarking: MarkingState,\n property: SmtProperty,\n invariants: readonly PInvariant[],\n sinkPlaces: ReadonlySet<Place<any>> = new Set(),\n): EncodingResult {\n const P = flatNet.places.length;\n const Int = ctx.Int;\n const Bool_ = ctx.Bool;\n\n // Create sorts array for function declaration\n const intSort = Int.sort();\n const boolSort = Bool_.sort();\n const markingSorts: any[] = new Array(P).fill(intSort);\n\n // Create the Reachable relation: (Int, Int, ...) -> Bool\n const reachable: FuncDecl = ctx.Function.declare('Reachable', ...markingSorts, boolSort);\n fp.registerRelation(reachable);\n\n // Create the Error relation: () -> Bool\n const error: FuncDecl = ctx.Function.declare('Error', boolSort);\n fp.registerRelation(error);\n\n // === Rule 1: Initial state ===\n // Reachable(m0_0, m0_1, ..., m0_{P-1})\n const m0Args: Arith[] = [];\n for (let i = 0; i < P; i++) {\n const tokens = initialMarking.tokens(flatNet.places[i]!);\n m0Args.push(Int.val(tokens));\n }\n const initFact = (reachable as any).call(...m0Args) as Bool;\n fp.addRule(initFact, 'init');\n\n // === Rule 2: Transition rules ===\n for (let t = 0; t < flatNet.transitions.length; t++) {\n const ft = flatNet.transitions[t]!;\n encodeTransitionRule(ctx, fp, reachable, ft, flatNet, invariants, P);\n }\n\n // === Rule 2b: Environment-injection rules (VER-006) ===\n // Per injected env place p: Reachable(M') :- Reachable(M) ∧ [M[p] < bound] ∧\n // M'[p] = M[p]+1 ∧ (∀q≠p) M'[q] = M[q]. Unbounded (AlwaysAvailable) omits the\n // guard so p can grow without limit. These are NOT flat transitions, so the\n // deadlock encoding (which iterates flatNet.transitions) never sees them and\n // deadlock-freedom does not become trivially true. P-invariants are NOT\n // conjoined here — injection deliberately breaks closed-net conservation.\n for (const [name, bound] of flatNet.environmentInjection) {\n const idx = flatNet.placeIndex.get(name);\n if (idx == null) continue;\n encodeInjectionRule(ctx, fp, reachable, idx, bound, P);\n }\n\n // === Rule 3: Error rule (property violation) ===\n encodeErrorRule(ctx, fp, reachable, error, flatNet, property, sinkPlaces, P);\n\n return {\n errorExpr: (error as any).call() as Bool,\n reachableDecl: reachable,\n };\n}\n\nfunction encodeTransitionRule(\n ctx: Z3Context,\n fp: Z3Fixedpoint,\n reachable: FuncDecl,\n ft: FlatTransition,\n flatNet: FlatNet,\n invariants: readonly PInvariant[],\n P: number,\n): void {\n const Int = ctx.Int;\n\n // Create named variables for current and next marking\n const mVars: Arith[] = [];\n const mPrimeVars: Arith[] = [];\n for (let i = 0; i < P; i++) {\n mVars.push(Int.const(`m${i}`));\n mPrimeVars.push(Int.const(`mp${i}`));\n }\n\n // Body: Reachable(M) AND enabled(M,t) AND fire(M,M',t) AND non-negativity(M') AND invariants(M') AND env bounds(M')\n const reachBody = (reachable as any).call(...mVars) as Bool;\n const enabled = encodeEnabled(ctx, ft, flatNet, mVars, P);\n const fireRelation = encodeFire(ctx, ft, flatNet, mVars, mPrimeVars, P);\n\n // Non-negativity of M'\n let nonNeg: Bool = ctx.Bool.val(true);\n for (let i = 0; i < P; i++) {\n nonNeg = ctx.And(nonNeg, mPrimeVars[i]!.ge(0));\n }\n\n // P-invariant constraints on M'\n const invConstraints = encodeInvariantConstraints(ctx, invariants, mPrimeVars, P);\n\n // Environment bounds on M'\n let envBounds: Bool = ctx.Bool.val(true);\n for (const [name, bound] of flatNet.environmentBounds) {\n const idx = flatNet.placeIndex.get(name);\n if (idx != null) {\n envBounds = ctx.And(envBounds, mPrimeVars[idx]!.le(bound));\n }\n }\n\n // Body conjunction\n const body = ctx.And(reachBody, enabled, fireRelation, nonNeg, invConstraints, envBounds);\n\n // Head: Reachable(M')\n const head = (reachable as any).call(...mPrimeVars) as Bool;\n\n // Rule: forall M, M'. body => head\n const allVars = [...mVars, ...mPrimeVars];\n const rule = ctx.Implies(body, head);\n const qRule = ctx.ForAll(allVars, rule);\n\n fp.addRule(qRule, `t_${ft.name}`);\n}\n\n/**\n * Encodes one environment-injection rule (VER-006): the external world adds a\n * token to environment place `idx`. `bound === null` ⇒ unbounded (AlwaysAvailable);\n * a number ⇒ guarded so the place never exceeds `bound` (Bounded). All other\n * columns are copied unchanged. No P-invariant strengthening (injection breaks\n * conservation by design); non-negativity is implied by `M[idx] ≥ 0 ⇒ M'[idx] ≥ 1`.\n */\nfunction encodeInjectionRule(\n ctx: Z3Context,\n fp: Z3Fixedpoint,\n reachable: FuncDecl,\n idx: number,\n bound: number | null,\n P: number,\n): void {\n const Int = ctx.Int;\n\n const mVars: Arith[] = [];\n const mPrimeVars: Arith[] = [];\n for (let i = 0; i < P; i++) {\n mVars.push(Int.const(`m${i}`));\n mPrimeVars.push(Int.const(`mp${i}`));\n }\n\n const reachBody = (reachable as any).call(...mVars) as Bool;\n\n let fire: Bool = ctx.Bool.val(true);\n for (let i = 0; i < P; i++) {\n if (i === idx) {\n fire = ctx.And(fire, mPrimeVars[i]!.eq(mVars[i]!.add(1)));\n } else {\n fire = ctx.And(fire, mPrimeVars[i]!.eq(mVars[i]!));\n }\n }\n\n // Bounded injection: only inject while still below the cap.\n const guard: Bool = bound === null ? ctx.Bool.val(true) : mVars[idx]!.lt(bound);\n\n const body = ctx.And(reachBody, guard, fire);\n const head = (reachable as any).call(...mPrimeVars) as Bool;\n const qRule = ctx.ForAll([...mVars, ...mPrimeVars], ctx.Implies(body, head));\n\n fp.addRule(qRule, `env_inject_${idx}`);\n}\n\n/** Maps injected environment-place index -> injection bound (null = unbounded). */\nfunction injectedEnvIndices(flatNet: FlatNet): Map<number, number | null> {\n const out = new Map<number, number | null>();\n for (const [name, bound] of flatNet.environmentInjection) {\n const idx = flatNet.placeIndex.get(name);\n if (idx != null) out.set(idx, bound);\n }\n return out;\n}\n\n/**\n * Encodes the enablement predicate for a flat transition.\n *\n * When `relaxEnv` is true (used only by the deadlock check), input/read\n * requirements on injectable environment places are treated as satisfiable by\n * external injection — `AlwaysAvailable` always satisfies them, `Bounded(k)`\n * satisfies them iff the required cardinality is ≤ k (a compile-time check on the\n * arc weight, not on the marking). This mirrors the state class graph's\n * always-available enablement (VER-006) so a reactive net merely *waiting for\n * input* is not reported as a deadlock; only a marking that no injection could\n * ever re-enable counts. Transition firing rules always use the strict form\n * (`relaxEnv` false) because firing genuinely consumes tokens.\n */\nfunction encodeEnabled(\n ctx: Z3Context,\n ft: FlatTransition,\n flatNet: FlatNet,\n mVars: Arith[],\n P: number,\n relaxEnv = false,\n): Bool {\n let result: Bool = ctx.Bool.val(true);\n const envInj = relaxEnv ? injectedEnvIndices(flatNet) : undefined;\n\n // Input requirements: M[p] >= pre[p] (relaxed for injectable env inputs).\n for (let p = 0; p < P; p++) {\n const pre = ft.preVector[p]!;\n if (pre <= 0) continue;\n if (envInj?.has(p)) {\n const bound = envInj.get(p)!;\n if (bound !== null && pre > bound) return ctx.Bool.val(false); // never enableable\n continue; // satisfiable by injection\n }\n result = ctx.And(result, mVars[p]!.ge(pre));\n }\n\n // Read arcs: M[p] >= 1 (relaxed for injectable env inputs).\n for (const p of ft.readPlaces) {\n if (envInj?.has(p)) {\n const bound = envInj.get(p)!;\n if (bound !== null && bound < 1) return ctx.Bool.val(false);\n continue;\n }\n result = ctx.And(result, mVars[p]!.ge(1));\n }\n\n // Inhibitor arcs: M[p] == 0\n for (const p of ft.inhibitorPlaces) {\n result = ctx.And(result, mVars[p]!.eq(0));\n }\n\n // Non-negativity of current marking\n for (let p = 0; p < P; p++) {\n result = ctx.And(result, mVars[p]!.ge(0));\n }\n\n return result;\n}\n\nfunction encodeFire(\n ctx: Z3Context,\n ft: FlatTransition,\n _flatNet: FlatNet,\n mVars: Arith[],\n mPrimeVars: Arith[],\n P: number,\n): Bool {\n let result: Bool = ctx.Bool.val(true);\n\n for (let p = 0; p < P; p++) {\n const isReset = ft.resetPlaces.includes(p);\n\n if (isReset || ft.consumeAll[p]) {\n // Reset/consumeAll: M'[p] = post[p]\n result = ctx.And(result, mPrimeVars[p]!.eq(ft.postVector[p]!));\n } else {\n // Standard: M'[p] = M[p] - pre[p] + post[p]\n const delta = ft.postVector[p]! - ft.preVector[p]!;\n if (delta === 0) {\n result = ctx.And(result, mPrimeVars[p]!.eq(mVars[p]!));\n } else {\n result = ctx.And(result, mPrimeVars[p]!.eq(mVars[p]!.add(delta)));\n }\n }\n }\n\n return result;\n}\n\nfunction encodeErrorRule(\n ctx: Z3Context,\n fp: Z3Fixedpoint,\n reachable: FuncDecl,\n error: FuncDecl,\n flatNet: FlatNet,\n property: SmtProperty,\n sinkPlaces: ReadonlySet<Place<any>>,\n P: number,\n): void {\n const Int = ctx.Int;\n\n // Create variables for the error rule\n const mVars: Arith[] = [];\n for (let i = 0; i < P; i++) {\n mVars.push(Int.const(`em${i}`));\n }\n\n const reachBody = (reachable as any).call(...mVars) as Bool;\n const violation = encodePropertyViolation(ctx, flatNet, property, sinkPlaces, mVars, P);\n\n const head = (error as any).call() as Bool;\n const body = ctx.And(reachBody, violation);\n const rule = ctx.Implies(body, head);\n const qRule = ctx.ForAll(mVars, rule);\n\n fp.addRule(qRule, `error_${property.type}`);\n}\n\nfunction encodePropertyViolation(\n ctx: Z3Context,\n flatNet: FlatNet,\n property: SmtProperty,\n sinkPlaces: ReadonlySet<Place<any>>,\n mVars: Arith[],\n P: number,\n): Bool {\n switch (property.type) {\n case 'deadlock-free': {\n const deadlock = encodeDeadlock(ctx, flatNet, mVars, P);\n if (sinkPlaces.size > 0) {\n // Deadlock is only a violation if NOT at any expected sink place\n let notAtSink: Bool = ctx.Bool.val(true);\n for (const sink of sinkPlaces) {\n const idx = flatNetIndexOf(flatNet, sink);\n if (idx >= 0) {\n notAtSink = ctx.And(notAtSink, mVars[idx]!.eq(0));\n }\n }\n return ctx.And(deadlock, notAtSink);\n }\n return deadlock;\n }\n\n case 'mutual-exclusion': {\n const idx1 = flatNetIndexOf(flatNet, property.p1);\n const idx2 = flatNetIndexOf(flatNet, property.p2);\n if (idx1 < 0) throw new Error(`MutualExclusion references unknown place: ${property.p1.name}`);\n if (idx2 < 0) throw new Error(`MutualExclusion references unknown place: ${property.p2.name}`);\n return ctx.And(mVars[idx1]!.ge(1), mVars[idx2]!.ge(1));\n }\n\n case 'place-bound': {\n const idx = flatNetIndexOf(flatNet, property.place);\n if (idx < 0) throw new Error(`PlaceBound references unknown place: ${property.place.name}`);\n return mVars[idx]!.gt(property.bound);\n }\n\n case 'unreachable': {\n let allMarked: Bool = ctx.Bool.val(true);\n for (const place of property.places) {\n const idx = flatNetIndexOf(flatNet, place);\n if (idx >= 0) {\n allMarked = ctx.And(allMarked, mVars[idx]!.ge(1));\n }\n }\n return allMarked;\n }\n }\n}\n\n/**\n * Encodes the deadlock condition: no transition is enabled. Environment inputs\n * are treated as injectable (`relaxEnv`), so a marking that an external injection\n * could re-enable is NOT a deadlock — only a genuinely stuck marking is (VER-006).\n */\nfunction encodeDeadlock(\n ctx: Z3Context,\n flatNet: FlatNet,\n mVars: Arith[],\n P: number,\n): Bool {\n let deadlock: Bool = ctx.Bool.val(true);\n\n for (const ft of flatNet.transitions) {\n const enabled = encodeEnabled(ctx, ft, flatNet, mVars, P, /* relaxEnv */ true);\n deadlock = ctx.And(deadlock, ctx.Not(enabled));\n }\n\n return deadlock;\n}\n\nfunction encodeInvariantConstraints(\n ctx: Z3Context,\n invariants: readonly PInvariant[],\n mVars: Arith[],\n P: number,\n): Bool {\n let result: Bool = ctx.Bool.val(true);\n\n for (const inv of invariants) {\n // sum(y_i * M[i]) == constant\n let sum: Arith = ctx.Int.val(0);\n for (const idx of inv.support) {\n if (idx < P) {\n sum = sum.add(mVars[idx]!.mul(inv.weights[idx]!));\n }\n }\n result = ctx.And(result, sum.eq(inv.constant));\n }\n\n return result;\n}\n","import type { Expr } from 'z3-solver';\nimport { MarkingState } from '../marking-state.js';\nimport type { FlatNet } from '../encoding/flat-net.js';\n\n/**\n * Result of counterexample decoding.\n */\nexport interface DecodedTrace {\n readonly trace: readonly MarkingState[];\n readonly transitions: readonly string[];\n}\n\n/**\n * Decodes Z3 Spacer counterexample answers into Petri net marking traces.\n *\n * When Spacer finds a counterexample (property violation), it produces\n * a derivation tree showing how the error state is reachable. This function\n * extracts the marking at each step to produce a human-readable trace.\n */\nexport function decode(ctx: any, answer: Expr | null, flatNet: FlatNet): DecodedTrace {\n const trace: MarkingState[] = [];\n const transitions: string[] = [];\n\n if (answer == null) {\n return { trace, transitions };\n }\n\n try {\n extractTrace(ctx, answer, flatNet, trace, transitions);\n } catch {\n // Z3 answer format varies; gracefully degrade\n }\n\n return { trace, transitions };\n}\n\n/**\n * Recursively traverses the Z3 proof tree to extract marking states.\n */\nfunction extractTrace(\n ctx: any,\n expr: any,\n flatNet: FlatNet,\n trace: MarkingState[],\n transitions: string[],\n): void {\n if (expr == null) return;\n\n // Check if this is a function application\n if (!ctx.isApp(expr)) return;\n\n let name: string;\n try {\n const decl = expr.decl();\n name = String(decl.name());\n } catch {\n return;\n }\n\n // Check if this is a Reachable application with integer arguments\n const P = flatNet.places.length;\n if (name === 'Reachable') {\n const numArgs = expr.numArgs();\n if (numArgs === P) {\n const marking = extractMarking(ctx, expr, flatNet);\n if (marking != null) {\n trace.push(marking);\n }\n }\n }\n\n // Recurse into children to find the derivation chain\n try {\n const numArgs = expr.numArgs();\n for (let i = 0; i < numArgs; i++) {\n const child = expr.arg(i);\n extractTrace(ctx, child, flatNet, trace, transitions);\n }\n } catch {\n // Not all expressions support arg()\n }\n\n // Try to extract transition name from rule application\n if (name.startsWith('t_')) {\n transitions.push(name.substring(2));\n }\n}\n\n/**\n * Extracts a MarkingState from a Reachable(...) application.\n */\nfunction extractMarking(ctx: any, reachableApp: any, flatNet: FlatNet): MarkingState | null {\n const P = flatNet.places.length;\n if (reachableApp.numArgs() !== P) return null;\n\n const builder = MarkingState.builder();\n for (let i = 0; i < P; i++) {\n const arg = reachableApp.arg(i);\n if (ctx.isIntVal(arg)) {\n const tokens = Number(arg.value());\n if (tokens > 0) {\n builder.tokens(flatNet.places[i]!, tokens);\n }\n } else {\n // Non-concrete value in counterexample\n return null;\n }\n }\n return builder.build();\n}\n","import type { PetriNet } from '../core/petri-net.js';\nimport type { EnvironmentPlace, Place } from '../core/place.js';\nimport { MarkingState, MarkingStateBuilder } from './marking-state.js';\nimport type { SmtProperty } from './smt-property.js';\nimport { deadlockFree, propertyDescription } from './smt-property.js';\nimport type { SmtVerificationResult, SmtStatistics, Verdict } from './smt-verification-result.js';\nimport type { PInvariant } from './invariant/p-invariant.js';\nimport type { FlatNet } from './encoding/flat-net.js';\nimport { flatten } from './encoding/net-flattener.js';\nimport { type EnvironmentAnalysisMode, alwaysAvailable } from './analysis/environment-analysis-mode.js';\nimport { IncidenceMatrix } from './encoding/incidence-matrix.js';\nimport { computePInvariants, isCoveredByInvariants } from './invariant/p-invariant-computer.js';\nimport { structuralCheck } from './invariant/structural-check.js';\nimport { createSpacerRunner } from './z3/spacer-runner.js';\nimport { encode } from './z3/smt-encoder.js';\nimport { decode } from './z3/counterexample-decoder.js';\n\n/**\n * IC3/PDR-based safety verifier for Petri nets using Z3's Spacer engine.\n *\n * Proves safety properties (especially deadlock-freedom) without\n * enumerating all reachable states. IC3 constructs inductive invariants\n * incrementally, which works well for bounded nets.\n *\n * Key design decisions:\n * - Operates on the marking projection (integer vectors) — no timing\n * - An untimed deadlock-freedom proof is stronger than needed\n * (timing can only restrict behavior)\n * - Guards are ignored — over-approximation is sound for safety properties\n * - If a counterexample is found, it may be spurious in timed/guarded\n * semantics — the report notes this\n *\n * Verification Pipeline:\n * 1. Flatten — expand XOR, index places, build pre/post vectors\n * 2. Structural pre-check — siphon/trap analysis (may prove early)\n * 3. P-invariants — compute conservation laws for strengthening\n * 4. SMT encode + query — IC3/PDR via Z3 Spacer\n * 5. Decode result — proof or counterexample trace\n */\nexport class SmtVerifier {\n private _initialMarking: MarkingState = MarkingState.empty();\n private _property: SmtProperty = deadlockFree();\n private readonly _environmentPlaces = new Set<EnvironmentPlace<any>>();\n private readonly _sinkPlaces = new Set<Place<any>>();\n private _environmentMode: EnvironmentAnalysisMode = alwaysAvailable();\n private _timeoutMs: number = 60_000;\n\n private constructor(private readonly net: PetriNet) {}\n\n static forNet(net: PetriNet): SmtVerifier {\n return new SmtVerifier(net);\n }\n\n initialMarking(marking: MarkingState): this;\n initialMarking(configurator: (builder: MarkingStateBuilder) => void): this;\n initialMarking(arg: MarkingState | ((builder: MarkingStateBuilder) => void)): this {\n if (arg instanceof MarkingState) {\n this._initialMarking = arg;\n } else {\n const builder = MarkingState.builder();\n arg(builder);\n this._initialMarking = builder.build();\n }\n return this;\n }\n\n property(property: SmtProperty): this {\n this._property = property;\n return this;\n }\n\n environmentPlaces(...places: EnvironmentPlace<any>[]): this {\n for (const p of places) this._environmentPlaces.add(p);\n return this;\n }\n\n environmentMode(mode: EnvironmentAnalysisMode): this {\n this._environmentMode = mode;\n return this;\n }\n\n /**\n * Declares expected sink (terminal) places for deadlock-freedom analysis.\n * Markings where any sink place has a token are not considered deadlocks.\n */\n sinkPlaces(...places: Place<any>[]): this {\n for (const p of places) this._sinkPlaces.add(p);\n return this;\n }\n\n timeout(ms: number): this {\n this._timeoutMs = ms;\n return this;\n }\n\n /**\n * Runs the verification pipeline.\n */\n async verify(): Promise<SmtVerificationResult> {\n const start = performance.now();\n const report: string[] = [];\n report.push('=== IC3/PDR SAFETY VERIFICATION ===\\n');\n report.push(`Net: ${this.net.name}`);\n const propDesc = this._sinkPlaces.size === 0\n ? propertyDescription(this._property)\n : `${propertyDescription(this._property)} (sinks: ${[...this._sinkPlaces].map(p => p.name).join(', ')})`;\n report.push(`Property: ${propDesc}`);\n report.push(`Timeout: ${(this._timeoutMs / 1000).toFixed(0)}s\\n`);\n\n // Phase 1: Flatten\n report.push('Phase 1: Flattening net...');\n const flatNet = flatten(this.net, this._environmentPlaces, this._environmentMode);\n report.push(` Places: ${flatNet.places.length}`);\n report.push(` Transitions (expanded): ${flatNet.transitions.length}`);\n if (flatNet.environmentBounds.size > 0) {\n report.push(` Environment bounds: ${flatNet.environmentBounds.size} places`);\n }\n report.push('');\n\n // Phase 2: Structural pre-check\n report.push('Phase 2: Structural pre-check (siphon/trap)...');\n const structResult = structuralCheck(flatNet, this._initialMarking);\n let structResultStr: string;\n switch (structResult.type) {\n case 'no-potential-deadlock':\n structResultStr = 'no potential deadlock';\n break;\n case 'potential-deadlock':\n structResultStr = `potential deadlock (siphon: {${[...structResult.siphon].join(',')}})`;\n break;\n case 'inconclusive':\n structResultStr = `inconclusive (${structResult.reason})`;\n break;\n }\n report.push(` Result: ${structResultStr}\\n`);\n\n // If structural check proves deadlock-freedom for DeadlockFree property\n // (only valid when no sink places — structural check doesn't account for sinks).\n // Skipped when environment places are registered: the siphon/trap analysis runs\n // on the closed net and is blind to env injection (VER-006), so its early proof\n // could be unsound — fall through to the (injection-aware) SMT encoding instead.\n if (\n this._property.type === 'deadlock-free' &&\n this._sinkPlaces.size === 0 &&\n structResult.type === 'no-potential-deadlock' &&\n this._environmentPlaces.size === 0\n ) {\n report.push('=== RESULT ===\\n');\n report.push('PROVEN (structural): Deadlock-freedom verified by Commoner\\'s theorem.');\n report.push(' All siphons contain initially marked traps.');\n return buildResult(\n { type: 'proven', method: 'structural', inductiveInvariant: null },\n report.join('\\n'), [], [], [], [],\n performance.now() - start,\n { places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: 0, structuralResult: structResultStr },\n );\n }\n\n // Phase 3: P-invariants\n report.push('Phase 3: Computing P-invariants...');\n const matrix = IncidenceMatrix.from(flatNet);\n const invariants = computePInvariants(matrix, flatNet, this._initialMarking);\n report.push(` Found: ${invariants.length} P-invariant(s)`);\n const structurallyBounded = isCoveredByInvariants(invariants, flatNet.places.length);\n report.push(` Structurally bounded: ${structurallyBounded ? 'YES' : 'NO'}`);\n for (const inv of invariants) {\n report.push(` ${formatInvariant(inv, flatNet)}`);\n }\n report.push('');\n\n // Phase 4: SMT encode + query via Spacer\n report.push('Phase 4: IC3/PDR verification via Z3 Spacer...');\n\n let runner;\n try {\n runner = await createSpacerRunner(this._timeoutMs);\n } catch (e: any) {\n report.push(` ERROR: ${e.message ?? e}\\n`);\n report.push('=== RESULT ===\\n');\n report.push(`UNKNOWN: Z3 initialization error: ${e.message ?? e}`);\n return buildResult(\n { type: 'unknown', reason: `Z3 init error: ${e.message ?? e}` },\n report.join('\\n'), invariants, [], [], [],\n performance.now() - start,\n { places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: invariants.length, structuralResult: structResultStr },\n );\n }\n\n try {\n const encoding = encode(runner.ctx, runner.fp, flatNet, this._initialMarking, this._property, invariants, this._sinkPlaces);\n const queryResult = await runner.query(encoding.errorExpr, encoding.reachableDecl);\n\n switch (queryResult.type) {\n case 'proven': {\n // Guard against silent vacuous proofs (VER-006): in `ignore` mode the\n // encoding does not model env injection, so env-gated transitions never\n // fire and ANY safety bound is trivially \"proven\". Refuse to certify —\n // downgrade to UNKNOWN with actionable guidance.\n if (this._environmentPlaces.size > 0 && this._environmentMode.type === 'ignore') {\n const reason =\n 'environment places present but not modeled (mode=ignore); a proof would be ' +\n 'vacuous — use alwaysAvailable() or bounded(k) to model external injection';\n report.push(` Status: UNSAT, but vacuous under ignore mode\\n`);\n report.push('=== RESULT ===\\n');\n report.push(`UNKNOWN: ${reason}`);\n return buildResult(\n { type: 'unknown', reason },\n report.join('\\n'), invariants, [], [], [],\n performance.now() - start,\n { places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: invariants.length, structuralResult: structResultStr },\n );\n }\n\n report.push(' Status: UNSAT (property holds)\\n');\n\n // Decode IC3-synthesized invariants with place name substitution\n const discoveredInvariants: string[] = [];\n if (queryResult.invariantFormula != null) {\n discoveredInvariants.push(substituteNames(queryResult.invariantFormula, flatNet));\n }\n for (const level of queryResult.levelInvariants) {\n discoveredInvariants.push(substituteNames(level, flatNet));\n }\n\n // Phase 5: Inductive invariant\n if (discoveredInvariants.length > 0) {\n report.push('Phase 5: Inductive invariant (discovered by IC3)');\n report.push(` Spacer synthesized: ${discoveredInvariants[0]}`);\n report.push(' This formula is INDUCTIVE: preserved by all transitions.');\n if (discoveredInvariants.length > 1) {\n report.push(' Per-level clauses:');\n for (let i = 1; i < discoveredInvariants.length; i++) {\n report.push(` ${discoveredInvariants[i]}`);\n }\n }\n report.push('');\n }\n\n report.push('=== RESULT ===\\n');\n report.push(`PROVEN (IC3/PDR): ${propDesc}`);\n report.push(' Z3 Spacer proved no reachable state violates the property.');\n report.push(' NOTE: Verification ignores timing constraints and JS guards.');\n report.push(' An untimed proof is STRONGER than a timed one (timing only restricts behavior).');\n\n return buildResult(\n {\n type: 'proven',\n method: 'IC3/PDR',\n inductiveInvariant: queryResult.invariantFormula != null\n ? substituteNames(queryResult.invariantFormula, flatNet)\n : null,\n },\n report.join('\\n'), invariants, discoveredInvariants, [], [],\n performance.now() - start,\n { places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: invariants.length, structuralResult: structResultStr },\n );\n }\n\n case 'violated': {\n report.push(' Status: SAT (counterexample found)\\n');\n\n const decoded = decode(runner.ctx, queryResult.answer, flatNet);\n\n report.push('=== RESULT ===\\n');\n report.push(`VIOLATED: ${propDesc}`);\n if (decoded.trace.length > 0) {\n report.push(` Counterexample trace (${decoded.trace.length} states):`);\n for (let i = 0; i < decoded.trace.length; i++) {\n report.push(` ${i}: ${decoded.trace[i]}`);\n }\n }\n if (decoded.transitions.length > 0) {\n report.push(` Firing sequence: ${decoded.transitions.join(' -> ')}`);\n }\n report.push('\\n WARNING: This counterexample is in UNTIMED semantics.');\n report.push(' It may be spurious if timing constraints prevent this sequence.');\n report.push(' JS guards are also ignored in this analysis.');\n\n return buildResult(\n { type: 'violated' },\n report.join('\\n'), invariants, [], decoded.trace as MarkingState[], decoded.transitions as string[],\n performance.now() - start,\n { places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: invariants.length, structuralResult: structResultStr },\n );\n }\n\n case 'unknown': {\n report.push(` Status: UNKNOWN (${queryResult.reason})\\n`);\n report.push('=== RESULT ===\\n');\n report.push(`UNKNOWN: Could not determine ${propDesc}`);\n report.push(` Reason: ${queryResult.reason}`);\n\n return buildResult(\n { type: 'unknown', reason: queryResult.reason },\n report.join('\\n'), invariants, [], [], [],\n performance.now() - start,\n { places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: invariants.length, structuralResult: structResultStr },\n );\n }\n }\n } catch (e: any) {\n report.push(` ERROR: ${e.message ?? e}\\n`);\n report.push('=== RESULT ===\\n');\n report.push(`UNKNOWN: Z3 solver error: ${e.message ?? e}`);\n\n return buildResult(\n { type: 'unknown', reason: `Z3 error: ${e.message ?? e}` },\n report.join('\\n'), invariants, [], [], [],\n performance.now() - start,\n { places: flatNet.places.length, transitions: flatNet.transitions.length, invariantsFound: invariants.length, structuralResult: structResultStr },\n );\n } finally {\n runner.dispose();\n }\n }\n}\n\n/**\n * Substitutes Z3 variable names (m0, m1, ...) with place names in a formula string.\n */\nfunction substituteNames(formula: string, flatNet: FlatNet): string {\n // Replace from highest index first to avoid m1 matching inside m10\n for (let i = flatNet.places.length - 1; i >= 0; i--) {\n formula = formula.replace(new RegExp(`\\\\bm${i}\\\\b`, 'g'), flatNet.places[i]!.name);\n }\n return formula;\n}\n\nfunction formatInvariant(inv: PInvariant, flatNet: FlatNet): string {\n const parts: string[] = [];\n for (const idx of inv.support) {\n if (inv.weights[idx] !== 1) {\n parts.push(`${inv.weights[idx]}*${flatNet.places[idx]!.name}`);\n } else {\n parts.push(flatNet.places[idx]!.name);\n }\n }\n return `${parts.join(' + ')} = ${inv.constant}`;\n}\n\nfunction buildResult(\n verdict: Verdict,\n report: string,\n invariants: readonly PInvariant[],\n discoveredInvariants: readonly string[],\n trace: readonly MarkingState[],\n transitions: readonly string[],\n elapsedMs: number,\n statistics: SmtStatistics,\n): SmtVerificationResult {\n return { verdict, report, invariants, discoveredInvariants, counterexampleTrace: trace, counterexampleTransitions: transitions, elapsedMs, statistics };\n}\n","import type { MarkingState } from './marking-state.js';\nimport type { PInvariant } from './invariant/p-invariant.js';\n\n/**\n * Verification verdict.\n */\nexport type Verdict = Proven | Violated | Unknown;\n\n/** Property proven safe. No reachable state violates it. */\nexport interface Proven {\n readonly type: 'proven';\n readonly method: string;\n readonly inductiveInvariant: string | null;\n}\n\n/** Property violated. A counterexample trace is available. */\nexport interface Violated {\n readonly type: 'violated';\n}\n\n/** Could not determine. */\nexport interface Unknown {\n readonly type: 'unknown';\n readonly reason: string;\n}\n\n/**\n * Solver statistics.\n */\nexport interface SmtStatistics {\n readonly places: number;\n readonly transitions: number;\n readonly invariantsFound: number;\n readonly structuralResult: string;\n}\n\n/**\n * Result of SMT-based verification.\n */\nexport interface SmtVerificationResult {\n readonly verdict: Verdict;\n readonly report: string;\n readonly invariants: readonly PInvariant[];\n readonly discoveredInvariants: readonly string[];\n readonly counterexampleTrace: readonly MarkingState[];\n readonly counterexampleTransitions: readonly string[];\n readonly elapsedMs: number;\n readonly statistics: SmtStatistics;\n}\n\nexport function isProven(result: SmtVerificationResult): boolean {\n return result.verdict.type === 'proven';\n}\n\nexport function isViolated(result: SmtVerificationResult): boolean {\n return result.verdict.type === 'violated';\n}\n"],"mappings":";AAwDO,SAAS,OAAO,UAAyB;AAC9C,MAAI,SAAS,WAAW,GAAG;AACzB,UAAM,IAAI,MAAM,+BAA+B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AM,IAAI,QAAQ;AAC/C;AAEA,SAAS,YACP,SACA,QACA,YACA,sBACA,OACA,aACA,WACA,YACuB;AACvB,SAAO,EAAE,SAAS,QAAQ,YAAY,sBAAsB,qBAAqB,OAAO,2BAA2B,aAAa,WAAW,WAAW;AACxJ;;;AC7SO,SAAS,SAAS,QAAwC;AAC/D,SAAO,OAAO,QAAQ,SAAS;AACjC;AAEO,SAAS,WAAW,QAAwC;AACjE,SAAO,OAAO,QAAQ,SAAS;AACjC;","names":[]}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
earliest,
|
|
3
3
|
hasDeadline,
|
|
4
4
|
latest
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ATT7U5H5.js";
|
|
6
6
|
|
|
7
7
|
// src/export/styles.ts
|
|
8
8
|
var NODE_STYLES = {
|
|
@@ -708,4 +708,4 @@ export {
|
|
|
708
708
|
renderDot,
|
|
709
709
|
dotExport
|
|
710
710
|
};
|
|
711
|
-
//# sourceMappingURL=chunk-
|
|
711
|
+
//# sourceMappingURL=chunk-ULX3OG6H.js.map
|
package/dist/debug/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Writable } from 'node:stream';
|
|
2
|
-
import { P as PetriNet, b as Transition, T as Token } from '../petri-net-
|
|
3
|
-
import { E as EventStore, N as NetEvent } from '../event-store-
|
|
2
|
+
import { P as PetriNet, b as Transition, T as Token } from '../petri-net-C3asscb4.js';
|
|
3
|
+
import { E as EventStore, N as NetEvent } from '../event-store-E_ahsEc9.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Commands sent from debug UI client to server via WebSocket.
|
package/dist/debug/index.js
CHANGED
package/dist/doclet/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Application } from 'typedoc';
|
|
2
|
-
import { P as PetriNet, S as SubnetDef, o as Instance } from '../petri-net-
|
|
2
|
+
import { P as PetriNet, S as SubnetDef, o as Instance } from '../petri-net-C3asscb4.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* TypeDoc plugin for `@petrinet` and `@subnet` tags — auto-generates
|
package/dist/doclet/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
dotExport,
|
|
4
4
|
nodeStyle,
|
|
5
5
|
sanitize
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-ULX3OG6H.js";
|
|
7
|
+
import "../chunk-ATT7U5H5.js";
|
|
8
8
|
|
|
9
9
|
// src/doclet/petri-net-plugin.ts
|
|
10
10
|
import {
|
|
@@ -446,7 +446,7 @@ function escapeLabel(s) {
|
|
|
446
446
|
|
|
447
447
|
// src/doclet/petri-net-plugin.ts
|
|
448
448
|
async function getDotExport() {
|
|
449
|
-
const mod = await import("../dot-exporter-
|
|
449
|
+
const mod = await import("../dot-exporter-TYC6FUAD.js");
|
|
450
450
|
return mod.dotExport;
|
|
451
451
|
}
|
|
452
452
|
var TAG_PETRINET = "@petrinet";
|