libpetri 1.8.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/{chunk-B2D5DMTO.js → chunk-4L6JVKH4.js} +165 -8
- package/dist/chunk-4L6JVKH4.js.map +1 -0
- package/dist/chunk-H62Z76FY.js +1346 -0
- package/dist/chunk-H62Z76FY.js.map +1 -0
- package/dist/chunk-SXK2Z45Z.js +50 -0
- package/dist/chunk-SXK2Z45Z.js.map +1 -0
- package/dist/debug/index.d.ts +50 -3
- package/dist/debug/index.js +64 -6
- package/dist/debug/index.js.map +1 -1
- package/dist/doclet/index.d.ts +152 -31
- package/dist/doclet/index.js +458 -57
- package/dist/doclet/index.js.map +1 -1
- package/dist/doclet/resources/petrinet-diagrams.css +384 -7
- package/dist/doclet/resources/petrinet-diagrams.js +7214 -106
- package/dist/dot-exporter-PMHOQHZ3.js +8 -0
- package/dist/{event-store-BnyHh3TF.d.ts → event-store-2zkXeQkd.d.ts} +1 -1
- package/dist/export/index.d.ts +16 -2
- package/dist/export/index.js +1 -1
- package/dist/index.d.ts +41 -5
- package/dist/index.js +1221 -35
- package/dist/index.js.map +1 -1
- package/dist/petri-net-BDrj4XZE.d.ts +1461 -0
- package/dist/render-P6GROU7J.js +16 -0
- package/dist/render-P6GROU7J.js.map +1 -0
- package/dist/verification/index.d.ts +3 -144
- package/dist/verification/index.js +30 -1214
- package/dist/verification/index.js.map +1 -1
- package/dist/viewer/index.d.ts +196 -0
- package/dist/viewer/index.js +442 -0
- package/dist/viewer/index.js.map +1 -0
- package/dist/viewer/viewer-static.iife.js +3 -0
- package/dist/viewer/viewer.css +503 -0
- package/dist/viewer/viewer.iife.js +7219 -0
- package/package.json +17 -8
- package/dist/chunk-B2D5DMTO.js.map +0 -1
- package/dist/chunk-VQ4XMJTD.js +0 -107
- package/dist/chunk-VQ4XMJTD.js.map +0 -1
- package/dist/dot-exporter-3CVCH6J4.js +0 -8
- package/dist/petri-net-D-GN9g_D.d.ts +0 -570
- /package/dist/{dot-exporter-3CVCH6J4.js.map → dot-exporter-PMHOQHZ3.js.map} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/viewer/render.ts
|
|
2
|
+
import { instance as vizInstance } from "@viz-js/viz";
|
|
3
|
+
var vizPromise = null;
|
|
4
|
+
function getViz() {
|
|
5
|
+
if (!vizPromise) vizPromise = vizInstance();
|
|
6
|
+
return vizPromise;
|
|
7
|
+
}
|
|
8
|
+
async function renderDotToSvg(dotSource) {
|
|
9
|
+
const viz = await getViz();
|
|
10
|
+
return viz.renderSVGElement(dotSource, { engine: "dot" });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getViz,
|
|
14
|
+
renderDotToSvg
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=render-P6GROU7J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/viewer/render.ts"],"sourcesContent":["/**\n * DOT → SVG rendering for the canonical libpetri viewer.\n *\n * Wraps `@viz-js/viz` and memoizes the wasm-backed instance so multiple\n * `mount()` calls on the same page reuse a single Viz instance. Behaviour\n * matches the older `render-dom` module byte-for-byte; see {@link render-dom}\n * for the original. This file exists so the viewer module is self-contained\n * and can be bundled as an IIFE for embedding into the doclet/Javadoc/Rustdoc\n * outputs.\n *\n * Browser-only: requires `@viz-js/viz` at runtime.\n *\n * @module viewer/render\n */\n\nimport { instance as vizInstance } from '@viz-js/viz';\n\ntype Viz = Awaited<ReturnType<typeof vizInstance>>;\n\nlet vizPromise: Promise<Viz> | null = null;\n\n/** Memoize the viz.js instance so the wasm loads only once per page. */\nexport function getViz(): Promise<Viz> {\n if (!vizPromise) vizPromise = vizInstance();\n return vizPromise;\n}\n\n/**\n * Render a DOT source string to an SVGSVGElement.\n *\n * Layout engine is pinned to `dot` (deterministic across runs); libpetri\n * exporters emit byte-stable DOT per spec EXP-014 so the same DOT yields\n * the same SVG.\n */\nexport async function renderDotToSvg(dotSource: string): Promise<SVGSVGElement> {\n const viz = await getViz();\n return viz.renderSVGElement(dotSource, { engine: 'dot' });\n}\n"],"mappings":";AAeA,SAAS,YAAY,mBAAmB;AAIxC,IAAI,aAAkC;AAG/B,SAAS,SAAuB;AACrC,MAAI,CAAC,WAAY,cAAa,YAAY;AAC1C,SAAO;AACT;AASA,eAAsB,eAAe,WAA2C;AAC9E,QAAM,MAAM,MAAM,OAAO;AACzB,SAAO,IAAI,iBAAiB,WAAW,EAAE,QAAQ,MAAM,CAAC;AAC1D;","names":[]}
|
|
@@ -1,47 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as Transition, a as Place, P as PetriNet, E as EnvironmentPlace, aG as MarkingState, aH as PInvariant, aI as MarkingStateBuilder, aJ as SmtProperty, aK as SmtVerificationResult } from '../petri-net-BDrj4XZE.js';
|
|
2
|
+
export { aL as DeadlockFree, aM as MutualExclusion, aN as PlaceBound, aO as Proven, aP as SmtStatistics, aQ as TokenSupplier, aR as Unknown, aS as Unreachable, aT as Verdict, X as VerificationHarness, Y as VerificationResult, aU as Violated, aV as deadlockFree, aW as isProven, aX as isViolated, aY as mutualExclusion, aZ as pInvariant, a_ as pInvariantToString, a$ as placeBound, b0 as propertyDescription, b1 as unreachable } from '../petri-net-BDrj4XZE.js';
|
|
2
3
|
import { Expr, init, Bool, FuncDecl } from 'z3-solver';
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* Immutable snapshot of a Petri net marking for state space analysis.
|
|
6
|
-
*
|
|
7
|
-
* Maps places (by name) to integer token counts. Only stores places with count > 0.
|
|
8
|
-
* Used for invariant computation and structural verification, not runtime execution.
|
|
9
|
-
*/
|
|
10
|
-
declare class MarkingState {
|
|
11
|
-
private readonly tokenCounts;
|
|
12
|
-
private readonly placesByName;
|
|
13
|
-
/** @internal Use {@link MarkingState.builder} or {@link MarkingState.empty} to create instances. */
|
|
14
|
-
constructor(key: symbol, tokenCounts: Map<string, number>, placesByName: Map<string, Place<any>>);
|
|
15
|
-
/** Returns the token count for a place (0 if absent). */
|
|
16
|
-
tokens(place: Place<any>): number;
|
|
17
|
-
/** Checks if a place has at least one token. */
|
|
18
|
-
hasTokens(place: Place<any>): boolean;
|
|
19
|
-
/** Checks if any of the given places has tokens. */
|
|
20
|
-
hasTokensInAny(places: Iterable<Place<any>>): boolean;
|
|
21
|
-
/** Returns all places with tokens > 0. */
|
|
22
|
-
placesWithTokens(): Place<any>[];
|
|
23
|
-
/** Returns the total number of tokens. */
|
|
24
|
-
totalTokens(): number;
|
|
25
|
-
/** Checks if no tokens exist anywhere. */
|
|
26
|
-
isEmpty(): boolean;
|
|
27
|
-
toString(): string;
|
|
28
|
-
static empty(): MarkingState;
|
|
29
|
-
static builder(): MarkingStateBuilder;
|
|
30
|
-
}
|
|
31
|
-
declare class MarkingStateBuilder {
|
|
32
|
-
private readonly tokenCounts;
|
|
33
|
-
private readonly placesByName;
|
|
34
|
-
/** Sets the token count for a place. */
|
|
35
|
-
tokens(place: Place<any>, count: number): this;
|
|
36
|
-
/** Adds tokens to a place. */
|
|
37
|
-
addTokens(place: Place<any>, count: number): this;
|
|
38
|
-
/** Removes tokens from a place. Throws if insufficient. */
|
|
39
|
-
removeTokens(place: Place<any>, count: number): this;
|
|
40
|
-
/** Copies all token counts from another marking state. */
|
|
41
|
-
copyFrom(other: MarkingState): this;
|
|
42
|
-
build(): MarkingState;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
5
|
/**
|
|
46
6
|
* A flattened transition with pre/post vectors for SMT encoding.
|
|
47
7
|
*
|
|
@@ -166,27 +126,6 @@ declare function bounded$1(maxTokens: number): EnvironmentAnalysisMode$1;
|
|
|
166
126
|
*/
|
|
167
127
|
declare function flatten(net: PetriNet, environmentPlaces?: Set<EnvironmentPlace<any>>, environmentMode?: EnvironmentAnalysisMode$1): FlatNet;
|
|
168
128
|
|
|
169
|
-
/**
|
|
170
|
-
* A P-invariant (place invariant) of a Petri net.
|
|
171
|
-
*
|
|
172
|
-
* A P-invariant is a vector y such that y^T * C = 0, where C is the
|
|
173
|
-
* incidence matrix. This means that for any reachable marking M:
|
|
174
|
-
* sum(y_i * M_i) = constant, where constant = sum(y_i * M0_i).
|
|
175
|
-
*
|
|
176
|
-
* P-invariants provide structural bounds on places and are used as
|
|
177
|
-
* strengthening lemmas for the IC3/PDR engine.
|
|
178
|
-
*/
|
|
179
|
-
interface PInvariant {
|
|
180
|
-
/** Weight vector (one entry per place index). */
|
|
181
|
-
readonly weights: readonly number[];
|
|
182
|
-
/** The invariant value sum(y_i * M0_i). */
|
|
183
|
-
readonly constant: number;
|
|
184
|
-
/** Set of place indices where weight != 0. */
|
|
185
|
-
readonly support: ReadonlySet<number>;
|
|
186
|
-
}
|
|
187
|
-
declare function pInvariant(weights: number[], constant: number, support: Set<number>): PInvariant;
|
|
188
|
-
declare function pInvariantToString(inv: PInvariant): string;
|
|
189
|
-
|
|
190
129
|
/**
|
|
191
130
|
* @module p-invariant-computer
|
|
192
131
|
*
|
|
@@ -285,86 +224,6 @@ declare function findMinimalSiphons(flatNet: FlatNet): ReadonlySet<number>[];
|
|
|
285
224
|
*/
|
|
286
225
|
declare function findMaximalTrapIn(flatNet: FlatNet, places: ReadonlySet<number>): ReadonlySet<number>;
|
|
287
226
|
|
|
288
|
-
/**
|
|
289
|
-
* Safety properties that can be verified via IC3/PDR.
|
|
290
|
-
*
|
|
291
|
-
* Each property is encoded as an error condition: if a reachable state
|
|
292
|
-
* violates the property, Spacer finds a counterexample. If no violation
|
|
293
|
-
* is reachable, the property is proven.
|
|
294
|
-
*/
|
|
295
|
-
type SmtProperty = DeadlockFree | MutualExclusion | PlaceBound | Unreachable;
|
|
296
|
-
/** Deadlock-freedom: no reachable marking has all transitions disabled. */
|
|
297
|
-
interface DeadlockFree {
|
|
298
|
-
readonly type: 'deadlock-free';
|
|
299
|
-
}
|
|
300
|
-
/** Mutual exclusion: two places never have tokens simultaneously. */
|
|
301
|
-
interface MutualExclusion {
|
|
302
|
-
readonly type: 'mutual-exclusion';
|
|
303
|
-
readonly p1: Place<any>;
|
|
304
|
-
readonly p2: Place<any>;
|
|
305
|
-
}
|
|
306
|
-
/** Place bound: a place never exceeds a given token count. */
|
|
307
|
-
interface PlaceBound {
|
|
308
|
-
readonly type: 'place-bound';
|
|
309
|
-
readonly place: Place<any>;
|
|
310
|
-
readonly bound: number;
|
|
311
|
-
}
|
|
312
|
-
/** Unreachability: the given places never all have tokens simultaneously. */
|
|
313
|
-
interface Unreachable {
|
|
314
|
-
readonly type: 'unreachable';
|
|
315
|
-
readonly places: ReadonlySet<Place<any>>;
|
|
316
|
-
}
|
|
317
|
-
declare function deadlockFree(): DeadlockFree;
|
|
318
|
-
declare function mutualExclusion(p1: Place<any>, p2: Place<any>): MutualExclusion;
|
|
319
|
-
declare function placeBound(place: Place<any>, bound: number): PlaceBound;
|
|
320
|
-
declare function unreachable(places: ReadonlySet<Place<any>>): Unreachable;
|
|
321
|
-
/** Human-readable description of a property. */
|
|
322
|
-
declare function propertyDescription(prop: SmtProperty): string;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Verification verdict.
|
|
326
|
-
*/
|
|
327
|
-
type Verdict = Proven | Violated | Unknown;
|
|
328
|
-
/** Property proven safe. No reachable state violates it. */
|
|
329
|
-
interface Proven {
|
|
330
|
-
readonly type: 'proven';
|
|
331
|
-
readonly method: string;
|
|
332
|
-
readonly inductiveInvariant: string | null;
|
|
333
|
-
}
|
|
334
|
-
/** Property violated. A counterexample trace is available. */
|
|
335
|
-
interface Violated {
|
|
336
|
-
readonly type: 'violated';
|
|
337
|
-
}
|
|
338
|
-
/** Could not determine. */
|
|
339
|
-
interface Unknown {
|
|
340
|
-
readonly type: 'unknown';
|
|
341
|
-
readonly reason: string;
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Solver statistics.
|
|
345
|
-
*/
|
|
346
|
-
interface SmtStatistics {
|
|
347
|
-
readonly places: number;
|
|
348
|
-
readonly transitions: number;
|
|
349
|
-
readonly invariantsFound: number;
|
|
350
|
-
readonly structuralResult: string;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Result of SMT-based verification.
|
|
354
|
-
*/
|
|
355
|
-
interface SmtVerificationResult {
|
|
356
|
-
readonly verdict: Verdict;
|
|
357
|
-
readonly report: string;
|
|
358
|
-
readonly invariants: readonly PInvariant[];
|
|
359
|
-
readonly discoveredInvariants: readonly string[];
|
|
360
|
-
readonly counterexampleTrace: readonly MarkingState[];
|
|
361
|
-
readonly counterexampleTransitions: readonly string[];
|
|
362
|
-
readonly elapsedMs: number;
|
|
363
|
-
readonly statistics: SmtStatistics;
|
|
364
|
-
}
|
|
365
|
-
declare function isProven(result: SmtVerificationResult): boolean;
|
|
366
|
-
declare function isViolated(result: SmtVerificationResult): boolean;
|
|
367
|
-
|
|
368
227
|
/**
|
|
369
228
|
* IC3/PDR-based safety verifier for Petri nets using Z3's Spacer engine.
|
|
370
229
|
*
|
|
@@ -702,4 +561,4 @@ declare class TimePetriNetAnalyzerBuilder {
|
|
|
702
561
|
build(): TimePetriNetAnalyzer;
|
|
703
562
|
}
|
|
704
563
|
|
|
705
|
-
export { type EnvironmentAnalysisMode as AnalysisEnvironmentMode, type BranchEdge, DBM, type
|
|
564
|
+
export { type EnvironmentAnalysisMode as AnalysisEnvironmentMode, type BranchEdge, DBM, type DecodedTrace, type EncodingResult, type EnvironmentAnalysisMode$1 as EnvironmentAnalysisMode, type FlatNet, type FlatTransition, IncidenceMatrix, type LivenessResult, MarkingState, MarkingStateBuilder, PInvariant, type QueryProven, type QueryResult, type QueryUnknown, type QueryViolated, SmtProperty, SmtVerificationResult, SmtVerifier, type SpacerContext, StateClass, StateClassGraph, type StructuralCheckResult, TimePetriNetAnalyzer, TimePetriNetAnalyzerBuilder, type XorBranchAnalysis, type XorBranchInfo, alwaysAvailable as analysisAlwaysAvailable, bounded as analysisBounded, ignore as analysisIgnore, bounded$1 as bounded, computePInvariants, computeSCCs, createSpacerRunner, decode, encode, findMaximalTrapIn, findMinimalSiphons, findTerminalSCCs, flatNetIndexOf, flatNetPlaceCount, flatNetTransitionCount, flatTransition, flatten, isCoveredByInvariants, structuralCheck, unbounded };
|