libpetri 4.0.0 → 5.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/dist/{chunk-KO6TSB47.js → chunk-4HMFNYTH.js} +2 -2
- package/dist/{chunk-WYCGGQAW.js → chunk-75KEJQGC.js} +198 -58
- package/dist/chunk-75KEJQGC.js.map +1 -0
- package/dist/debug/index.d.ts +2 -2
- package/dist/doclet/index.d.ts +1 -1
- package/dist/doclet/resources/petrinet-diagrams.js +1 -1
- package/dist/{event-store-2FOAeUyh.d.ts → event-store-hlH3-bzJ.d.ts} +1 -1
- package/dist/export/index.d.ts +1 -1
- package/dist/index.d.ts +46 -13
- package/dist/index.js +134 -75
- package/dist/index.js.map +1 -1
- package/dist/{petri-net-hduM6tJf.d.ts → petri-net-CH7UvjOW.d.ts} +55 -4
- package/dist/render-dom/index.js +1 -1
- package/dist/verification/index.d.ts +36 -47
- package/dist/verification/index.js +3 -1
- package/dist/verification/index.js.map +1 -1
- package/dist/viewer/index.js +1 -1
- package/dist/viewer/viewer.iife.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-WYCGGQAW.js.map +0 -1
- /package/dist/{chunk-KO6TSB47.js.map → chunk-4HMFNYTH.js.map} +0 -0
|
@@ -817,6 +817,24 @@ declare class InterfaceBuilder {
|
|
|
817
817
|
build(): Interface;
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
+
/**
|
|
821
|
+
* Analysis mode for environment places in state class graph construction.
|
|
822
|
+
*/
|
|
823
|
+
type EnvironmentAnalysisMode = {
|
|
824
|
+
readonly type: 'always-available';
|
|
825
|
+
} | {
|
|
826
|
+
readonly type: 'bounded';
|
|
827
|
+
readonly maxTokens: number;
|
|
828
|
+
} | {
|
|
829
|
+
readonly type: 'ignore';
|
|
830
|
+
};
|
|
831
|
+
/** Assumes environment places always have sufficient tokens. */
|
|
832
|
+
declare function alwaysAvailable(): EnvironmentAnalysisMode;
|
|
833
|
+
/** Analyzes with a bounded number of tokens in environment places. */
|
|
834
|
+
declare function bounded(maxTokens: number): EnvironmentAnalysisMode;
|
|
835
|
+
/** Treats environment places as regular places. */
|
|
836
|
+
declare function ignore(): EnvironmentAnalysisMode;
|
|
837
|
+
|
|
820
838
|
/**
|
|
821
839
|
* Safety properties that can be verified via IC3/PDR.
|
|
822
840
|
*
|
|
@@ -824,11 +842,30 @@ declare class InterfaceBuilder {
|
|
|
824
842
|
* violates the property, Spacer finds a counterexample. If no violation
|
|
825
843
|
* is reachable, the property is proven.
|
|
826
844
|
*/
|
|
827
|
-
type SmtProperty = DeadlockFree | MutualExclusion | PlaceBound | Unreachable | BranchPlaceBound | JoinedOrDeadLettered;
|
|
828
|
-
/**
|
|
845
|
+
type SmtProperty = DeadlockFree | TerminatesAtSink | MutualExclusion | PlaceBound | Unreachable | BranchPlaceBound | JoinedOrDeadLettered;
|
|
846
|
+
/**
|
|
847
|
+
* Deadlock-freedom: no reachable quiescent marking strands a token (VER-002).
|
|
848
|
+
*
|
|
849
|
+
* Violated when a reachable marking is quiescent (every transition disabled) and
|
|
850
|
+
* holds a token in a place that is not a declared sink. The empty marking strands
|
|
851
|
+
* nothing and never violates. This is workflow-net proper completion; for the
|
|
852
|
+
* weaker "did the net reach a terminal at all", see {@link TerminatesAtSink},
|
|
853
|
+
* which inverts on the empty marking.
|
|
854
|
+
*/
|
|
829
855
|
interface DeadlockFree {
|
|
830
856
|
readonly type: 'deadlock-free';
|
|
831
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* Termination at a declared sink: every reachable quiescent marking has at least
|
|
860
|
+
* one declared sink marked (VER-002).
|
|
861
|
+
*
|
|
862
|
+
* Violated when a reachable marking is quiescent and no declared sink holds a
|
|
863
|
+
* token. Says nothing about tokens left elsewhere. Meaningful only with at least
|
|
864
|
+
* one sink declared; with none, every quiescent marking violates vacuously.
|
|
865
|
+
*/
|
|
866
|
+
interface TerminatesAtSink {
|
|
867
|
+
readonly type: 'terminates-at-sink';
|
|
868
|
+
}
|
|
832
869
|
/** Mutual exclusion: two places never have tokens simultaneously. */
|
|
833
870
|
interface MutualExclusion {
|
|
834
871
|
readonly type: 'mutual-exclusion';
|
|
@@ -872,6 +909,8 @@ interface JoinedOrDeadLettered {
|
|
|
872
909
|
readonly pending: Place<any>;
|
|
873
910
|
}
|
|
874
911
|
declare function deadlockFree(): DeadlockFree;
|
|
912
|
+
/** Quiescence reaches a declared sink (VER-002). See {@link TerminatesAtSink}. */
|
|
913
|
+
declare function terminatesAtSink(): TerminatesAtSink;
|
|
875
914
|
declare function mutualExclusion(p1: Place<any>, p2: Place<any>): MutualExclusion;
|
|
876
915
|
declare function placeBound(place: Place<any>, bound: number): PlaceBound;
|
|
877
916
|
declare function unreachable(places: ReadonlySet<Place<any>>): Unreachable;
|
|
@@ -1202,7 +1241,19 @@ declare class SubnetDef<P = void> {
|
|
|
1202
1241
|
* {@link SmtVerificationResult}s
|
|
1203
1242
|
* @throws when an input or in-out port is missing a harness generator
|
|
1204
1243
|
*/
|
|
1205
|
-
verify(harness: VerificationHarness<P
|
|
1244
|
+
verify(harness: VerificationHarness<P>,
|
|
1245
|
+
/**
|
|
1246
|
+
* How injection into the synthetic environment places is modeled (VER-006,
|
|
1247
|
+
* MOD-051 AC3).
|
|
1248
|
+
*
|
|
1249
|
+
* The synthetic net has environment places by construction, so this decides what a
|
|
1250
|
+
* verdict means. The default over-approximates: a `proven` under
|
|
1251
|
+
* `alwaysAvailable()` holds for any environment. Pass `bounded(k)` to prove a
|
|
1252
|
+
* property that holds only when the environment injects at most `k` tokens.
|
|
1253
|
+
* `ignore()` is accepted but cannot yield `proven` — VER-006 refuses to certify a
|
|
1254
|
+
* proof that holds only because injection was never modeled.
|
|
1255
|
+
*/
|
|
1256
|
+
environmentMode?: EnvironmentAnalysisMode): Promise<VerificationResult>;
|
|
1206
1257
|
static builder<P = void>(name: string): SubnetDefBuilder<P>;
|
|
1207
1258
|
/**
|
|
1208
1259
|
* Retrofit utility per **MOD-014**: wraps an existing closed {@link PetriNet}
|
|
@@ -1796,4 +1847,4 @@ declare class PetriNetBuilder {
|
|
|
1796
1847
|
private buildWithFusion;
|
|
1797
1848
|
}
|
|
1798
1849
|
|
|
1799
|
-
export { type VerificationHarness as $, type Arc as A, type Port as B, type Channel as C, type PortDirection as D, type EnvironmentPlace as E, FusionSet as F, SubnetDefBuilder as G, type SubnetInstance as H, type In as I, type Timing as J, type KeyFn as K, type LogFn as L, MAX_DURATION_MS as M, type NameId as N, type Out as O, PetriNet as P, type TimingDeadline as Q, type TimingDelayed as R, SubnetDef as S, type Token as T, type TimingExact as U, type TimingImmediate as V, type TimingWindow as W, TokenInput as X, TokenOutput as Y, type TransitionAction as Z, TransitionBuilder as _, type Place as a, type
|
|
1850
|
+
export { type VerificationHarness as $, type Arc as A, type Port as B, type Channel as C, type PortDirection as D, type EnvironmentPlace as E, FusionSet as F, SubnetDefBuilder as G, type SubnetInstance as H, type In as I, type Timing as J, type KeyFn as K, type LogFn as L, MAX_DURATION_MS as M, type NameId as N, type Out as O, PetriNet as P, type TimingDeadline as Q, type TimingDelayed as R, SubnetDef as S, type Token as T, type TimingExact as U, type TimingImmediate as V, type TimingWindow as W, TokenInput as X, TokenOutput as Y, type TransitionAction as Z, TransitionBuilder as _, type Place as a, type TerminatesAtSink as a$, type VerificationResult as a0, all as a1, allPlaces as a2, and as a3, andPlaces as a4, arcPlace as a5, atLeast as a6, consumptionCount as a7, deadline as a8, delayed as a9, requiredCount as aA, resetArc as aB, timeout as aC, timeoutPlace as aD, tokenAt as aE, tokenOf as aF, transform as aG, transformAsync as aH, transformFrom as aI, unitToken as aJ, window as aK, withTimeout as aL, xor as aM, xorPlaces as aN, type EnvironmentAnalysisMode as aO, type PInvariant as aP, MarkingState as aQ, type SmtProperty as aR, MarkingStateBuilder as aS, type SmtVerificationResult as aT, type BranchPlaceBound as aU, type DeadlockFree as aV, type JoinedOrDeadLettered as aW, type MutualExclusion as aX, type PlaceBound as aY, type Proven as aZ, type SmtStatistics as a_, earliest as aa, enumerateBranches as ab, environmentPlace as ac, exact as ad, exactly as ae, fork as af, forwardInput as ag, hasDeadline as ah, immediate as ai, inhibitorArc as aj, inputArc as ak, isPassthrough as al, isUnit as am, keyForPlace as an, latest as ao, matchCorrelates as ap, matchKey as aq, matchSpec as ar, nameId as as, one as at, outPlace as au, outputArc as av, passthrough as aw, place as ax, produce as ay, readArc as az, Transition as b, type TokenSupplier as b0, type Unknown as b1, type Unreachable as b2, type Verdict as b3, type Violated as b4, alwaysAvailable as b5, bounded as b6, ignore as b7, branchPlaceBound as b8, deadlockFree as b9, isProven as ba, isViolated as bb, joinedOrDeadLettered as bc, mutualExclusion as bd, pInvariant as be, pInvariantToString as bf, placeBound as bg, propertyDescription as bh, terminatesAtSink as bi, unreachable as bj, TransitionContext as c, type ArcInhibitor as d, type ArcInput as e, type ArcOutput as f, type ArcRead as g, type ArcReset as h, ComposeBindings as i, FusionSetBuilder as j, type InAll as k, type InAtLeast as l, type InExactly as m, type InOne as n, Instance as o, Interface as p, InterfaceBuilder as q, type MatchKey as r, type MatchSpec as s, type OutAnd as t, type OutForwardInput as u, type OutPlace as v, type OutTimeout as w, type OutXor as x, type OutputEntry as y, PetriNetBuilder as z };
|
package/dist/render-dom/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as Transition, a as Place, P as PetriNet, E as EnvironmentPlace, aO as
|
|
2
|
-
export {
|
|
1
|
+
import { b as Transition, a as Place, P as PetriNet, E as EnvironmentPlace, aO as EnvironmentAnalysisMode, aP as PInvariant, aQ as MarkingState, aR as SmtProperty, aS as MarkingStateBuilder, aT as SmtVerificationResult } from '../petri-net-CH7UvjOW.js';
|
|
2
|
+
export { aU as BranchPlaceBound, aV as DeadlockFree, aW as JoinedOrDeadLettered, aX as MutualExclusion, aY as PlaceBound, aZ as Proven, a_ as SmtStatistics, a$ as TerminatesAtSink, b0 as TokenSupplier, b1 as Unknown, b2 as Unreachable, b3 as Verdict, $ as VerificationHarness, a0 as VerificationResult, b4 as Violated, b5 as alwaysAvailable, b5 as analysisAlwaysAvailable, b6 as analysisBounded, b7 as analysisIgnore, b6 as bounded, b8 as branchPlaceBound, b9 as deadlockFree, b7 as ignore, ba as isProven, bb as isViolated, bc as joinedOrDeadLettered, bd as mutualExclusion, be as pInvariant, bf as pInvariantToString, bg as placeBound, bh as propertyDescription, bi as terminatesAtSink, bj as unreachable } from '../petri-net-CH7UvjOW.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A flattened transition with pre/post vectors for SMT encoding.
|
|
@@ -99,24 +99,6 @@ declare class IncidenceMatrix {
|
|
|
99
99
|
numPlaces(): number;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* Analysis mode for environment places in state class graph construction.
|
|
104
|
-
*/
|
|
105
|
-
type EnvironmentAnalysisMode = {
|
|
106
|
-
readonly type: 'always-available';
|
|
107
|
-
} | {
|
|
108
|
-
readonly type: 'bounded';
|
|
109
|
-
readonly maxTokens: number;
|
|
110
|
-
} | {
|
|
111
|
-
readonly type: 'ignore';
|
|
112
|
-
};
|
|
113
|
-
/** Assumes environment places always have sufficient tokens. */
|
|
114
|
-
declare function alwaysAvailable(): EnvironmentAnalysisMode;
|
|
115
|
-
/** Analyzes with a bounded number of tokens in environment places. */
|
|
116
|
-
declare function bounded(maxTokens: number): EnvironmentAnalysisMode;
|
|
117
|
-
/** Treats environment places as regular places (default). */
|
|
118
|
-
declare function ignore(): EnvironmentAnalysisMode;
|
|
119
|
-
|
|
120
102
|
/**
|
|
121
103
|
* @module net-flattener
|
|
122
104
|
*
|
|
@@ -504,29 +486,6 @@ type FragmentMode = 'base' | 'extended';
|
|
|
504
486
|
*/
|
|
505
487
|
type PrioritySemantics = 'none' | 'conflict';
|
|
506
488
|
|
|
507
|
-
/**
|
|
508
|
-
* IC3/PDR-based safety verifier for Petri nets using Z3's Spacer engine.
|
|
509
|
-
*
|
|
510
|
-
* Proves safety properties (especially deadlock-freedom) without
|
|
511
|
-
* enumerating all reachable states. IC3 constructs inductive invariants
|
|
512
|
-
* incrementally, which works well for bounded nets.
|
|
513
|
-
*
|
|
514
|
-
* Key design decisions:
|
|
515
|
-
* - Operates on the marking projection (integer vectors) — no timing
|
|
516
|
-
* - An untimed deadlock-freedom proof is stronger than needed
|
|
517
|
-
* (timing can only restrict behavior)
|
|
518
|
-
* - Input specifications are purely structural (IO-006) — there is no per-arc
|
|
519
|
-
* predicate for the encoder to be blind to
|
|
520
|
-
* - If a counterexample is found, it may be spurious in timed semantics —
|
|
521
|
-
* the report notes this
|
|
522
|
-
*
|
|
523
|
-
* Verification Pipeline:
|
|
524
|
-
* 1. Flatten — expand XOR, index places, build pre/post vectors
|
|
525
|
-
* 2. Structural pre-check — siphon/trap analysis (may prove early)
|
|
526
|
-
* 3. P-invariants — compute conservation laws for strengthening
|
|
527
|
-
* 4. SMT encode + query — IC3/PDR via Z3 Spacer
|
|
528
|
-
* 5. Decode result — proof or counterexample trace
|
|
529
|
-
*/
|
|
530
489
|
declare class SmtVerifier {
|
|
531
490
|
private readonly net;
|
|
532
491
|
private _initialMarking;
|
|
@@ -599,13 +558,26 @@ declare class SmtVerifier {
|
|
|
599
558
|
* into a chain whose other combinations avoid it (dropped by the H1 guard). On a
|
|
600
559
|
* net with a few reset arcs that can lose every law of the chains those arcs
|
|
601
560
|
* touch, and without them IC3 has to rediscover the conservation of each chain —
|
|
602
|
-
* on a ~100-place net it does not within any practical budget.
|
|
603
|
-
*
|
|
561
|
+
* on a ~100-place net it does not within any practical budget.
|
|
562
|
+
*
|
|
563
|
+
* **Turn this on if the net has any `all()` / `atLeast(n)` or reset arc on a busy
|
|
564
|
+
* place** — draining an input queue is the everyday case. Every basis row whose
|
|
565
|
+
* support touches such a place fails the H1 guard and is dropped, so the encoders
|
|
566
|
+
* run on a deficient invariant set and nothing in the report says a law is missing
|
|
567
|
+
* beyond the `Dropped` lines.
|
|
568
|
+
*
|
|
569
|
+
* This reaches the **name-coloured** encoder (NU-050) as well as the flat one, and
|
|
570
|
+
* it matters most there. On a 113-place ν-net, whole-net deadlock-freedom went from
|
|
571
|
+
* `unknown` after 50 minutes to `proven` in about 15 seconds with this option as the
|
|
572
|
+
* only change; on the flat path, reachability-safety queries that timed out at 120 s
|
|
573
|
+
* close in about a second.
|
|
604
574
|
*
|
|
605
575
|
* Soundness is unchanged: the semiflows pass the same exact re-validation as the
|
|
606
576
|
* basis rows, the union is pure strengthening (`Semiflow.lean`,
|
|
607
577
|
* `semiflow_union_sound`), and the certificate check re-proves the strengthened
|
|
608
|
-
* invariant
|
|
578
|
+
* invariant — that check is flat-path only, so a coloured `proven` reports
|
|
579
|
+
* `Certificate check: not applicable (name-coloured encoding)`. Off by default so
|
|
580
|
+
* reports stay byte-equal.
|
|
609
581
|
*/
|
|
610
582
|
semiflowInvariants(enabled: boolean): this;
|
|
611
583
|
/**
|
|
@@ -645,6 +617,23 @@ declare class SmtVerifier {
|
|
|
645
617
|
* dead-letter-drain stalls the eager, priority-ordered executor never produces.
|
|
646
618
|
*/
|
|
647
619
|
prioritySemantics(semantics: PrioritySemantics): this;
|
|
620
|
+
/**
|
|
621
|
+
* The name-coloured plan and its encoding, or a null plan when the net is outside
|
|
622
|
+
* the fragment (NU-050) and a null encoding when the property names a place the net
|
|
623
|
+
* does not resolve.
|
|
624
|
+
*
|
|
625
|
+
* {@link verify} and {@link encodeScripts} share this deliberately. They used to
|
|
626
|
+
* invoke `buildColouredPlan` and `encodeColoured` separately, so handing the encoder
|
|
627
|
+
* the wrong one of the two lists changed only one of them — and the script-parity
|
|
628
|
+
* goldens are generated from `encodeScripts`. Unifying the invocation closes that. It
|
|
629
|
+
* does not make the two paths identical: each still computes its own invariant and
|
|
630
|
+
* semiflow lists, so they can still drift through the arguments rather than the call.
|
|
631
|
+
*
|
|
632
|
+
* `invariants` is what the encoder conjoins into every rule body (the null-space
|
|
633
|
+
* basis, unioned with the semiflows when VER-007 is enabled); `semiflows` sets the
|
|
634
|
+
* colour-slot bound k (NU-053). They are not the same list.
|
|
635
|
+
*/
|
|
636
|
+
private colouredAttempt;
|
|
648
637
|
/**
|
|
649
638
|
* The SMT-LIB2 scripts {@link verify} would send to z3 for this configuration,
|
|
650
639
|
* without running a solver (VER-013 AC1): the HORN query (flat, or name-coloured
|
|
@@ -1109,4 +1098,4 @@ declare class TimePetriNetAnalyzerBuilder {
|
|
|
1109
1098
|
build(): TimePetriNetAnalyzer;
|
|
1110
1099
|
}
|
|
1111
1100
|
|
|
1112
|
-
export { type AbstractState,
|
|
1101
|
+
export { type AbstractState, EnvironmentAnalysisMode as AnalysisEnvironmentMode, type BranchEdge, type CertificateCheckOutcome, type CertificateVc, DBM, DUMP_ENV, type DecodedTrace, type EncodedScripts, EnvironmentAnalysisMode, type FlatNet, type FlatTransition, IncidenceMatrix, type LivenessResult, MIN_Z3_VERSION, MarkingState, MarkingStateBuilder, PInvariant, type PrioritySemantics, type QueryProven, type QueryResult, type QueryUnknown, type QueryViolated, type ReplayOptions, type ReplayOutcome, type ReplayStep, type SmtEncoding, SmtProperty, SmtVerificationResult, SmtVerifier, StateClass, StateClassGraph, type StructuralCheckResult, TimePetriNetAnalyzer, TimePetriNetAnalyzerBuilder, type XorBranchAnalysis, type XorBranchInfo, type Z3Exit, Z3ProcessError, type Z3Reply, type Z3Solver, Z3Unavailable, type Z3Version, Z3_ENV, canonicalInvariantOrder, checkCertificate, computePInvariants, computePSemiflows, computeSCCs, decode, decodeStateSet, encode, encodeStepRelationSmt2, findMaximalTrapIn, findMinimalSiphons, findTerminalSCCs, flatNetIndexOf, flatNetPlaceCount, flatNetTransitionCount, flatTransition, flatten, formatZ3Version, isCoveredByInvariants, parseZ3Version, placeholderCertificate, replayCounterexample, resolveZ3, runZ3Spacer, runZ3Text, strengthenWithSemiflows, structuralCheck, vcScript, z3Available, z3SolverAt };
|
|
@@ -50,11 +50,12 @@ import {
|
|
|
50
50
|
runZ3Text,
|
|
51
51
|
strengthenWithSemiflows,
|
|
52
52
|
structuralCheck,
|
|
53
|
+
terminatesAtSink,
|
|
53
54
|
unreachable,
|
|
54
55
|
vcScript,
|
|
55
56
|
z3Available,
|
|
56
57
|
z3SolverAt
|
|
57
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-75KEJQGC.js";
|
|
58
59
|
import "../chunk-ATT7U5H5.js";
|
|
59
60
|
|
|
60
61
|
// src/verification/analysis/scc-analyzer.ts
|
|
@@ -462,6 +463,7 @@ export {
|
|
|
462
463
|
runZ3Text,
|
|
463
464
|
strengthenWithSemiflows,
|
|
464
465
|
structuralCheck,
|
|
466
|
+
terminatesAtSink,
|
|
465
467
|
unreachable,
|
|
466
468
|
vcScript,
|
|
467
469
|
z3Available,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/verification/analysis/scc-analyzer.ts","../../src/verification/analysis/time-petri-net-analyzer.ts"],"sourcesContent":["/**\n * Strongly Connected Component analysis using Tarjan's algorithm.\n * Generic over node type T. Uses a key function for Map-based lookups.\n */\n\n/** Computes all SCCs in a graph. O(V + E) via Tarjan's algorithm. */\nexport function computeSCCs<T>(\n nodes: Iterable<T>,\n successors: (node: T) => Iterable<T>,\n): Set<T>[] {\n const nodeArray = [...nodes];\n const indexMap = new Map<T, number>();\n const lowlink = new Map<T, number>();\n const onStack = new Set<T>();\n const stack: T[] = [];\n const sccs: Set<T>[] = [];\n let index = 0;\n\n function strongConnect(v: T): void {\n indexMap.set(v, index);\n lowlink.set(v, index);\n index++;\n stack.push(v);\n onStack.add(v);\n\n for (const w of successors(v)) {\n if (!indexMap.has(w)) {\n strongConnect(w);\n lowlink.set(v, Math.min(lowlink.get(v)!, lowlink.get(w)!));\n } else if (onStack.has(w)) {\n lowlink.set(v, Math.min(lowlink.get(v)!, indexMap.get(w)!));\n }\n }\n\n if (lowlink.get(v) === indexMap.get(v)) {\n const scc = new Set<T>();\n let w: T;\n do {\n w = stack.pop()!;\n onStack.delete(w);\n scc.add(w);\n } while (w !== v);\n sccs.push(scc);\n }\n }\n\n for (const node of nodeArray) {\n if (!indexMap.has(node)) {\n strongConnect(node);\n }\n }\n\n return sccs;\n}\n\n/** Finds terminal (bottom) SCCs — SCCs with no outgoing edges to other SCCs. */\nexport function findTerminalSCCs<T>(\n nodes: Iterable<T>,\n successors: (node: T) => Iterable<T>,\n): Set<T>[] {\n const allSCCs = computeSCCs(nodes, successors);\n\n const terminal: Set<T>[] = [];\n for (const scc of allSCCs) {\n let isTerminal = true;\n for (const node of scc) {\n for (const succ of successors(node)) {\n if (!scc.has(succ)) {\n isTerminal = false;\n break;\n }\n }\n if (!isTerminal) break;\n }\n if (isTerminal) {\n terminal.push(scc);\n }\n }\n\n return terminal;\n}\n","import type { Place } from '../../core/place.js';\nimport type { EnvironmentPlace } from '../../core/place.js';\nimport type { Transition } from '../../core/transition.js';\nimport type { PetriNet } from '../../core/petri-net.js';\nimport { enumerateBranches } from '../../core/out.js';\nimport { MarkingState } from '../marking-state.js';\nimport { StateClassGraph } from './state-class-graph.js';\nimport type { StateClass } from './state-class.js';\nimport { computeSCCs, findTerminalSCCs } from './scc-analyzer.js';\nimport type { EnvironmentAnalysisMode } from './environment-analysis-mode.js';\nimport { ignore } from './environment-analysis-mode.js';\n\n/** Result of liveness analysis. */\nexport interface LivenessResult {\n readonly stateClassGraph: StateClassGraph;\n readonly allSCCs: Set<StateClass>[];\n readonly terminalSCCs: Set<StateClass>[];\n readonly goalClasses: Set<StateClass>;\n readonly canReachGoal: Set<StateClass>;\n readonly isGoalLive: boolean;\n readonly isL4Live: boolean;\n readonly isComplete: boolean;\n readonly report: string;\n}\n\n/** Information about XOR branch coverage for a single transition. */\nexport interface XorBranchInfo {\n readonly totalBranches: number;\n readonly takenBranches: Set<number>;\n readonly untakenBranches: Set<number>;\n readonly branchOutputs: ReadonlyArray<ReadonlySet<Place<any>>>;\n}\n\n/** Result of XOR branch analysis. */\nexport interface XorBranchAnalysis {\n readonly transitionBranches: Map<Transition, XorBranchInfo>;\n unreachableBranches(): Map<Transition, Set<number>>;\n isXorComplete(): boolean;\n report(): string;\n}\n\n/**\n * Formal analyzer for Time Petri Nets using the State Class Graph method.\n * Implements Berthomieu-Diaz (1991) analysis.\n */\nexport class TimePetriNetAnalyzer {\n private readonly net: PetriNet;\n private readonly initialMarking: MarkingState;\n private readonly goalPlaces: Set<Place<any>>;\n private readonly maxClasses: number;\n private readonly environmentPlaces: Set<EnvironmentPlace<any>>;\n private readonly environmentMode: EnvironmentAnalysisMode;\n\n /** @internal Called by builder — use `TimePetriNetAnalyzer.forNet()` instead. */\n static create(\n net: PetriNet,\n initialMarking: MarkingState,\n goalPlaces: Set<Place<any>>,\n maxClasses: number,\n environmentPlaces: Set<EnvironmentPlace<any>>,\n environmentMode: EnvironmentAnalysisMode,\n ): TimePetriNetAnalyzer {\n return new TimePetriNetAnalyzer(net, initialMarking, goalPlaces, maxClasses, environmentPlaces, environmentMode);\n }\n\n private constructor(\n net: PetriNet,\n initialMarking: MarkingState,\n goalPlaces: Set<Place<any>>,\n maxClasses: number,\n environmentPlaces: Set<EnvironmentPlace<any>>,\n environmentMode: EnvironmentAnalysisMode,\n ) {\n this.net = net;\n this.initialMarking = initialMarking;\n this.goalPlaces = goalPlaces;\n this.maxClasses = maxClasses;\n this.environmentPlaces = environmentPlaces;\n this.environmentMode = environmentMode;\n }\n\n static forNet(net: PetriNet): TimePetriNetAnalyzerBuilder {\n return new TimePetriNetAnalyzerBuilder(net);\n }\n\n /** Performs formal liveness analysis. */\n analyze(): LivenessResult {\n const report: string[] = [];\n report.push('=== TIME PETRI NET FORMAL ANALYSIS ===\\n');\n report.push(`Method: State Class Graph (Berthomieu-Diaz 1991)`);\n report.push(`Net: ${this.net.name}`);\n report.push(`Places: ${this.net.places.size}`);\n report.push(`Transitions: ${this.net.transitions.size}`);\n report.push(`Goal places: [${[...this.goalPlaces].map(p => p.name).join(', ')}]\\n`);\n\n // Phase 1: Build State Class Graph\n report.push('Phase 1: Building State Class Graph...');\n if (this.environmentPlaces.size > 0) {\n report.push(` Environment places: ${this.environmentPlaces.size}`);\n report.push(` Environment mode: ${this.environmentMode.type}`);\n }\n const scg = StateClassGraph.build(this.net, this.initialMarking, this.maxClasses, this.environmentPlaces, this.environmentMode);\n report.push(` State classes: ${scg.size()}`);\n report.push(` Edges: ${scg.edgeCount()}`);\n report.push(` Complete: ${scg.isComplete() ? 'YES' : 'NO (truncated)'}`);\n\n if (!scg.isComplete()) {\n report.push(` WARNING: State class graph truncated at ${this.maxClasses} classes. Analysis may be incomplete.`);\n }\n report.push('');\n\n // Phase 2: Identify goal state classes\n report.push('Phase 2: Identifying goal state classes...');\n const goalClasses = new Set<StateClass>();\n for (const sc of scg.stateClasses()) {\n if (sc.marking.hasTokensInAny(this.goalPlaces)) {\n goalClasses.add(sc);\n }\n }\n report.push(` Goal state classes: ${goalClasses.size}\\n`);\n\n // Phase 3: Compute SCCs\n report.push('Phase 3: Computing Strongly Connected Components...');\n const successorFn = (sc: StateClass) => scg.successors(sc);\n const allSCCs = computeSCCs(scg.stateClasses(), successorFn);\n const terminalSCCs = findTerminalSCCs(scg.stateClasses(), successorFn);\n\n report.push(` Total SCCs: ${allSCCs.length}`);\n report.push(` Terminal SCCs: ${terminalSCCs.length}\\n`);\n\n // Phase 4: Check goal liveness\n report.push('Phase 4: Verifying Goal Liveness...');\n report.push(' Property: From every reachable state, a goal state is reachable');\n\n const terminalSCCsWithGoal: Set<StateClass>[] = [];\n const terminalSCCsWithoutGoal: Set<StateClass>[] = [];\n\n for (const scc of terminalSCCs) {\n let hasGoal = false;\n for (const sc of scc) {\n if (goalClasses.has(sc)) { hasGoal = true; break; }\n }\n (hasGoal ? terminalSCCsWithGoal : terminalSCCsWithoutGoal).push(scc);\n }\n\n report.push(` Terminal SCCs with goal: ${terminalSCCsWithGoal.length}`);\n report.push(` Terminal SCCs without goal: ${terminalSCCsWithoutGoal.length}`);\n\n const canReachGoal = computeBackwardReachability(scg, goalClasses);\n const statesNotReachingGoal = scg.size() - canReachGoal.size;\n\n report.push(` States that can reach goal: ${canReachGoal.size}/${scg.size()}\\n`);\n\n const isGoalLive = terminalSCCsWithoutGoal.length === 0 && statesNotReachingGoal === 0;\n\n // Phase 5: Check classical liveness (L4)\n report.push('Phase 5: Verifying Classical Liveness (L4)...');\n report.push(' Property: Every transition can fire from every reachable marking');\n\n const allTransitions = new Set(this.net.transitions);\n const terminalSCCsMissingTransitions: Set<StateClass>[] = [];\n\n for (const scc of terminalSCCs) {\n const transitionsInSCC = new Set<Transition>();\n for (const sc of scc) {\n for (const t of scg.enabledTransitions(sc)) {\n const edges = scg.branchEdges(sc, t);\n for (const edge of edges) {\n if (scc.has(edge.target)) {\n transitionsInSCC.add(t);\n }\n }\n }\n }\n let missingAny = false;\n for (const t of allTransitions) {\n if (!transitionsInSCC.has(t)) { missingAny = true; break; }\n }\n if (missingAny) {\n terminalSCCsMissingTransitions.push(scc);\n const missing = [...allTransitions].filter(t => !transitionsInSCC.has(t));\n report.push(` Terminal SCC missing transitions: [${missing.map(t => t.name).join(', ')}]`);\n }\n }\n\n const isL4Live = terminalSCCsMissingTransitions.length === 0 && scg.isComplete();\n\n // Summary\n report.push('\\n=== ANALYSIS RESULT ===\\n');\n\n if (isGoalLive && scg.isComplete()) {\n report.push('GOAL LIVENESS VERIFIED');\n report.push(' From every reachable state class, a goal marking is reachable.');\n } else if (isGoalLive && !scg.isComplete()) {\n report.push('GOAL LIVENESS LIKELY (incomplete proof)');\n } else {\n report.push('GOAL LIVENESS VIOLATION');\n if (terminalSCCsWithoutGoal.length > 0) {\n report.push(` ${terminalSCCsWithoutGoal.length} terminal SCC(s) have no goal state.`);\n }\n if (statesNotReachingGoal > 0) {\n report.push(` ${statesNotReachingGoal} state class(es) cannot reach goal.`);\n }\n }\n\n report.push('');\n\n if (isL4Live) {\n report.push('CLASSICAL LIVENESS (L4) VERIFIED');\n } else {\n report.push('CLASSICAL LIVENESS (L4) NOT VERIFIED');\n if (terminalSCCsMissingTransitions.length > 0) {\n report.push(\" Some terminal SCCs don't contain all transitions.\");\n }\n if (!scg.isComplete()) {\n report.push(' (State class graph incomplete - cannot prove L4)');\n }\n }\n\n return {\n stateClassGraph: scg,\n allSCCs,\n terminalSCCs,\n goalClasses,\n canReachGoal,\n isGoalLive,\n isL4Live,\n isComplete: scg.isComplete(),\n report: report.join('\\n'),\n };\n }\n\n /** Analyzes XOR branch coverage for a built state class graph. */\n static analyzeXorBranches(scg: StateClassGraph): XorBranchAnalysis {\n const result = new Map<Transition, XorBranchInfo>();\n\n for (const transition of scg.net.transitions) {\n if (transition.outputSpec === null) continue;\n\n const allBranches = enumerateBranches(transition.outputSpec);\n if (allBranches.length <= 1) continue;\n\n const takenBranches = new Set<number>();\n for (const sc of scg.stateClasses()) {\n const edges = scg.branchEdges(sc, transition);\n for (const edge of edges) {\n takenBranches.add(edge.branchIndex);\n }\n }\n\n const untakenBranches = new Set<number>();\n for (let i = 0; i < allBranches.length; i++) {\n if (!takenBranches.has(i)) untakenBranches.add(i);\n }\n\n result.set(transition, {\n totalBranches: allBranches.length,\n takenBranches,\n untakenBranches,\n branchOutputs: allBranches,\n });\n }\n\n return createXorBranchAnalysis(result);\n }\n}\n\nfunction createXorBranchAnalysis(transitionBranches: Map<Transition, XorBranchInfo>): XorBranchAnalysis {\n return {\n transitionBranches,\n unreachableBranches(): Map<Transition, Set<number>> {\n const result = new Map<Transition, Set<number>>();\n for (const [t, info] of transitionBranches) {\n if (info.untakenBranches.size > 0) {\n result.set(t, info.untakenBranches);\n }\n }\n return result;\n },\n isXorComplete(): boolean {\n for (const info of transitionBranches.values()) {\n if (info.untakenBranches.size > 0) return false;\n }\n return true;\n },\n report(): string {\n if (transitionBranches.size === 0) return 'No XOR transitions in net.';\n\n const lines: string[] = [];\n lines.push('XOR Branch Coverage Analysis');\n lines.push('============================\\n');\n\n for (const [t, info] of transitionBranches) {\n lines.push(`Transition: ${t.name}`);\n lines.push(` Branches: ${info.totalBranches}`);\n lines.push(` Taken: [${[...info.takenBranches].join(', ')}]`);\n\n if (info.untakenBranches.size > 0) {\n lines.push(` UNREACHABLE: [${[...info.untakenBranches].join(', ')}]`);\n for (const idx of info.untakenBranches) {\n const places = [...info.branchOutputs[idx]!].map(p => p.name).join(', ');\n lines.push(` Branch ${idx} outputs: [${places}]`);\n }\n } else {\n lines.push(' All branches reachable');\n }\n lines.push('');\n }\n\n if (this.isXorComplete()) {\n lines.push('RESULT: All XOR branches are reachable.');\n } else {\n lines.push('RESULT: Some XOR branches are unreachable!');\n }\n\n return lines.join('\\n');\n },\n };\n}\n\nfunction computeBackwardReachability(scg: StateClassGraph, goals: Set<StateClass>): Set<StateClass> {\n const reachable = new Set(goals);\n const queue = [...goals];\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n for (const pred of scg.predecessors(current)) {\n if (!reachable.has(pred)) {\n reachable.add(pred);\n queue.push(pred);\n }\n }\n }\n\n return reachable;\n}\n\n/** Builder for TimePetriNetAnalyzer. */\nexport class TimePetriNetAnalyzerBuilder {\n private readonly net: PetriNet;\n private _initialMarking: MarkingState = MarkingState.empty();\n private readonly _goalPlaces = new Set<Place<any>>();\n private _maxClasses = 100_000;\n private readonly _environmentPlaces = new Set<EnvironmentPlace<any>>();\n private _environmentMode: EnvironmentAnalysisMode = ignore();\n\n constructor(net: PetriNet) {\n this.net = net;\n }\n\n initialMarking(marking: MarkingState): this {\n this._initialMarking = marking;\n return this;\n }\n\n goalPlaces(...places: Place<any>[]): this {\n for (const p of places) this._goalPlaces.add(p);\n return this;\n }\n\n maxClasses(max: number): this {\n this._maxClasses = max;\n return this;\n }\n\n environmentPlaces(...places: EnvironmentPlace<any>[]): this {\n for (const ep of places) this._environmentPlaces.add(ep);\n return this;\n }\n\n environmentMode(mode: EnvironmentAnalysisMode): this {\n this._environmentMode = mode;\n return this;\n }\n\n build(): TimePetriNetAnalyzer {\n if (this._goalPlaces.size === 0) {\n throw new Error('At least one goal place must be specified');\n }\n return TimePetriNetAnalyzer.create(\n this.net,\n this._initialMarking,\n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;AAAA,EACb;AAAA,EAEA,eAAe,SAA6B;AAC1C,SAAK,kBAAkB;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,cAAc,QAA4B;AACxC,eAAW,KAAK,OAAQ,MAAK,YAAY,IAAI,CAAC;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,KAAmB;AAC5B,SAAK,cAAc;AACnB,WAAO;AAAA,EACT;AAAA,EAEA,qBAAqB,QAAuC;AAC1D,eAAW,MAAM,OAAQ,MAAK,mBAAmB,IAAI,EAAE;AACvD,WAAO;AAAA,EACT;AAAA,EAEA,gBAAgB,MAAqC;AACnD,SAAK,mBAAmB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,QAA8B;AAC5B,QAAI,KAAK,YAAY,SAAS,GAAG;AAC/B,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC7D;AACA,WAAO,qBAAqB;AAAA,MAC1B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/verification/analysis/scc-analyzer.ts","../../src/verification/analysis/time-petri-net-analyzer.ts"],"sourcesContent":["/**\n * Strongly Connected Component analysis using Tarjan's algorithm.\n * Generic over node type T. Uses a key function for Map-based lookups.\n */\n\n/** Computes all SCCs in a graph. O(V + E) via Tarjan's algorithm. */\nexport function computeSCCs<T>(\n nodes: Iterable<T>,\n successors: (node: T) => Iterable<T>,\n): Set<T>[] {\n const nodeArray = [...nodes];\n const indexMap = new Map<T, number>();\n const lowlink = new Map<T, number>();\n const onStack = new Set<T>();\n const stack: T[] = [];\n const sccs: Set<T>[] = [];\n let index = 0;\n\n function strongConnect(v: T): void {\n indexMap.set(v, index);\n lowlink.set(v, index);\n index++;\n stack.push(v);\n onStack.add(v);\n\n for (const w of successors(v)) {\n if (!indexMap.has(w)) {\n strongConnect(w);\n lowlink.set(v, Math.min(lowlink.get(v)!, lowlink.get(w)!));\n } else if (onStack.has(w)) {\n lowlink.set(v, Math.min(lowlink.get(v)!, indexMap.get(w)!));\n }\n }\n\n if (lowlink.get(v) === indexMap.get(v)) {\n const scc = new Set<T>();\n let w: T;\n do {\n w = stack.pop()!;\n onStack.delete(w);\n scc.add(w);\n } while (w !== v);\n sccs.push(scc);\n }\n }\n\n for (const node of nodeArray) {\n if (!indexMap.has(node)) {\n strongConnect(node);\n }\n }\n\n return sccs;\n}\n\n/** Finds terminal (bottom) SCCs — SCCs with no outgoing edges to other SCCs. */\nexport function findTerminalSCCs<T>(\n nodes: Iterable<T>,\n successors: (node: T) => Iterable<T>,\n): Set<T>[] {\n const allSCCs = computeSCCs(nodes, successors);\n\n const terminal: Set<T>[] = [];\n for (const scc of allSCCs) {\n let isTerminal = true;\n for (const node of scc) {\n for (const succ of successors(node)) {\n if (!scc.has(succ)) {\n isTerminal = false;\n break;\n }\n }\n if (!isTerminal) break;\n }\n if (isTerminal) {\n terminal.push(scc);\n }\n }\n\n return terminal;\n}\n","import type { Place } from '../../core/place.js';\nimport type { EnvironmentPlace } from '../../core/place.js';\nimport type { Transition } from '../../core/transition.js';\nimport type { PetriNet } from '../../core/petri-net.js';\nimport { enumerateBranches } from '../../core/out.js';\nimport { MarkingState } from '../marking-state.js';\nimport { StateClassGraph } from './state-class-graph.js';\nimport type { StateClass } from './state-class.js';\nimport { computeSCCs, findTerminalSCCs } from './scc-analyzer.js';\nimport type { EnvironmentAnalysisMode } from './environment-analysis-mode.js';\nimport { ignore } from './environment-analysis-mode.js';\n\n/** Result of liveness analysis. */\nexport interface LivenessResult {\n readonly stateClassGraph: StateClassGraph;\n readonly allSCCs: Set<StateClass>[];\n readonly terminalSCCs: Set<StateClass>[];\n readonly goalClasses: Set<StateClass>;\n readonly canReachGoal: Set<StateClass>;\n readonly isGoalLive: boolean;\n readonly isL4Live: boolean;\n readonly isComplete: boolean;\n readonly report: string;\n}\n\n/** Information about XOR branch coverage for a single transition. */\nexport interface XorBranchInfo {\n readonly totalBranches: number;\n readonly takenBranches: Set<number>;\n readonly untakenBranches: Set<number>;\n readonly branchOutputs: ReadonlyArray<ReadonlySet<Place<any>>>;\n}\n\n/** Result of XOR branch analysis. */\nexport interface XorBranchAnalysis {\n readonly transitionBranches: Map<Transition, XorBranchInfo>;\n unreachableBranches(): Map<Transition, Set<number>>;\n isXorComplete(): boolean;\n report(): string;\n}\n\n/**\n * Formal analyzer for Time Petri Nets using the State Class Graph method.\n * Implements Berthomieu-Diaz (1991) analysis.\n */\nexport class TimePetriNetAnalyzer {\n private readonly net: PetriNet;\n private readonly initialMarking: MarkingState;\n private readonly goalPlaces: Set<Place<any>>;\n private readonly maxClasses: number;\n private readonly environmentPlaces: Set<EnvironmentPlace<any>>;\n private readonly environmentMode: EnvironmentAnalysisMode;\n\n /** @internal Called by builder — use `TimePetriNetAnalyzer.forNet()` instead. */\n static create(\n net: PetriNet,\n initialMarking: MarkingState,\n goalPlaces: Set<Place<any>>,\n maxClasses: number,\n environmentPlaces: Set<EnvironmentPlace<any>>,\n environmentMode: EnvironmentAnalysisMode,\n ): TimePetriNetAnalyzer {\n return new TimePetriNetAnalyzer(net, initialMarking, goalPlaces, maxClasses, environmentPlaces, environmentMode);\n }\n\n private constructor(\n net: PetriNet,\n initialMarking: MarkingState,\n goalPlaces: Set<Place<any>>,\n maxClasses: number,\n environmentPlaces: Set<EnvironmentPlace<any>>,\n environmentMode: EnvironmentAnalysisMode,\n ) {\n this.net = net;\n this.initialMarking = initialMarking;\n this.goalPlaces = goalPlaces;\n this.maxClasses = maxClasses;\n this.environmentPlaces = environmentPlaces;\n this.environmentMode = environmentMode;\n }\n\n static forNet(net: PetriNet): TimePetriNetAnalyzerBuilder {\n return new TimePetriNetAnalyzerBuilder(net);\n }\n\n /** Performs formal liveness analysis. */\n analyze(): LivenessResult {\n const report: string[] = [];\n report.push('=== TIME PETRI NET FORMAL ANALYSIS ===\\n');\n report.push(`Method: State Class Graph (Berthomieu-Diaz 1991)`);\n report.push(`Net: ${this.net.name}`);\n report.push(`Places: ${this.net.places.size}`);\n report.push(`Transitions: ${this.net.transitions.size}`);\n report.push(`Goal places: [${[...this.goalPlaces].map(p => p.name).join(', ')}]\\n`);\n\n // Phase 1: Build State Class Graph\n report.push('Phase 1: Building State Class Graph...');\n if (this.environmentPlaces.size > 0) {\n report.push(` Environment places: ${this.environmentPlaces.size}`);\n report.push(` Environment mode: ${this.environmentMode.type}`);\n }\n const scg = StateClassGraph.build(this.net, this.initialMarking, this.maxClasses, this.environmentPlaces, this.environmentMode);\n report.push(` State classes: ${scg.size()}`);\n report.push(` Edges: ${scg.edgeCount()}`);\n report.push(` Complete: ${scg.isComplete() ? 'YES' : 'NO (truncated)'}`);\n\n if (!scg.isComplete()) {\n report.push(` WARNING: State class graph truncated at ${this.maxClasses} classes. Analysis may be incomplete.`);\n }\n report.push('');\n\n // Phase 2: Identify goal state classes\n report.push('Phase 2: Identifying goal state classes...');\n const goalClasses = new Set<StateClass>();\n for (const sc of scg.stateClasses()) {\n if (sc.marking.hasTokensInAny(this.goalPlaces)) {\n goalClasses.add(sc);\n }\n }\n report.push(` Goal state classes: ${goalClasses.size}\\n`);\n\n // Phase 3: Compute SCCs\n report.push('Phase 3: Computing Strongly Connected Components...');\n const successorFn = (sc: StateClass) => scg.successors(sc);\n const allSCCs = computeSCCs(scg.stateClasses(), successorFn);\n const terminalSCCs = findTerminalSCCs(scg.stateClasses(), successorFn);\n\n report.push(` Total SCCs: ${allSCCs.length}`);\n report.push(` Terminal SCCs: ${terminalSCCs.length}\\n`);\n\n // Phase 4: Check goal liveness\n report.push('Phase 4: Verifying Goal Liveness...');\n report.push(' Property: From every reachable state, a goal state is reachable');\n\n const terminalSCCsWithGoal: Set<StateClass>[] = [];\n const terminalSCCsWithoutGoal: Set<StateClass>[] = [];\n\n for (const scc of terminalSCCs) {\n let hasGoal = false;\n for (const sc of scc) {\n if (goalClasses.has(sc)) { hasGoal = true; break; }\n }\n (hasGoal ? terminalSCCsWithGoal : terminalSCCsWithoutGoal).push(scc);\n }\n\n report.push(` Terminal SCCs with goal: ${terminalSCCsWithGoal.length}`);\n report.push(` Terminal SCCs without goal: ${terminalSCCsWithoutGoal.length}`);\n\n const canReachGoal = computeBackwardReachability(scg, goalClasses);\n const statesNotReachingGoal = scg.size() - canReachGoal.size;\n\n report.push(` States that can reach goal: ${canReachGoal.size}/${scg.size()}\\n`);\n\n const isGoalLive = terminalSCCsWithoutGoal.length === 0 && statesNotReachingGoal === 0;\n\n // Phase 5: Check classical liveness (L4)\n report.push('Phase 5: Verifying Classical Liveness (L4)...');\n report.push(' Property: Every transition can fire from every reachable marking');\n\n const allTransitions = new Set(this.net.transitions);\n const terminalSCCsMissingTransitions: Set<StateClass>[] = [];\n\n for (const scc of terminalSCCs) {\n const transitionsInSCC = new Set<Transition>();\n for (const sc of scc) {\n for (const t of scg.enabledTransitions(sc)) {\n const edges = scg.branchEdges(sc, t);\n for (const edge of edges) {\n if (scc.has(edge.target)) {\n transitionsInSCC.add(t);\n }\n }\n }\n }\n let missingAny = false;\n for (const t of allTransitions) {\n if (!transitionsInSCC.has(t)) { missingAny = true; break; }\n }\n if (missingAny) {\n terminalSCCsMissingTransitions.push(scc);\n const missing = [...allTransitions].filter(t => !transitionsInSCC.has(t));\n report.push(` Terminal SCC missing transitions: [${missing.map(t => t.name).join(', ')}]`);\n }\n }\n\n const isL4Live = terminalSCCsMissingTransitions.length === 0 && scg.isComplete();\n\n // Summary\n report.push('\\n=== ANALYSIS RESULT ===\\n');\n\n if (isGoalLive && scg.isComplete()) {\n report.push('GOAL LIVENESS VERIFIED');\n report.push(' From every reachable state class, a goal marking is reachable.');\n } else if (isGoalLive && !scg.isComplete()) {\n report.push('GOAL LIVENESS LIKELY (incomplete proof)');\n } else {\n report.push('GOAL LIVENESS VIOLATION');\n if (terminalSCCsWithoutGoal.length > 0) {\n report.push(` ${terminalSCCsWithoutGoal.length} terminal SCC(s) have no goal state.`);\n }\n if (statesNotReachingGoal > 0) {\n report.push(` ${statesNotReachingGoal} state class(es) cannot reach goal.`);\n }\n }\n\n report.push('');\n\n if (isL4Live) {\n report.push('CLASSICAL LIVENESS (L4) VERIFIED');\n } else {\n report.push('CLASSICAL LIVENESS (L4) NOT VERIFIED');\n if (terminalSCCsMissingTransitions.length > 0) {\n report.push(\" Some terminal SCCs don't contain all transitions.\");\n }\n if (!scg.isComplete()) {\n report.push(' (State class graph incomplete - cannot prove L4)');\n }\n }\n\n return {\n stateClassGraph: scg,\n allSCCs,\n terminalSCCs,\n goalClasses,\n canReachGoal,\n isGoalLive,\n isL4Live,\n isComplete: scg.isComplete(),\n report: report.join('\\n'),\n };\n }\n\n /** Analyzes XOR branch coverage for a built state class graph. */\n static analyzeXorBranches(scg: StateClassGraph): XorBranchAnalysis {\n const result = new Map<Transition, XorBranchInfo>();\n\n for (const transition of scg.net.transitions) {\n if (transition.outputSpec === null) continue;\n\n const allBranches = enumerateBranches(transition.outputSpec);\n if (allBranches.length <= 1) continue;\n\n const takenBranches = new Set<number>();\n for (const sc of scg.stateClasses()) {\n const edges = scg.branchEdges(sc, transition);\n for (const edge of edges) {\n takenBranches.add(edge.branchIndex);\n }\n }\n\n const untakenBranches = new Set<number>();\n for (let i = 0; i < allBranches.length; i++) {\n if (!takenBranches.has(i)) untakenBranches.add(i);\n }\n\n result.set(transition, {\n totalBranches: allBranches.length,\n takenBranches,\n untakenBranches,\n branchOutputs: allBranches,\n });\n }\n\n return createXorBranchAnalysis(result);\n }\n}\n\nfunction createXorBranchAnalysis(transitionBranches: Map<Transition, XorBranchInfo>): XorBranchAnalysis {\n return {\n transitionBranches,\n unreachableBranches(): Map<Transition, Set<number>> {\n const result = new Map<Transition, Set<number>>();\n for (const [t, info] of transitionBranches) {\n if (info.untakenBranches.size > 0) {\n result.set(t, info.untakenBranches);\n }\n }\n return result;\n },\n isXorComplete(): boolean {\n for (const info of transitionBranches.values()) {\n if (info.untakenBranches.size > 0) return false;\n }\n return true;\n },\n report(): string {\n if (transitionBranches.size === 0) return 'No XOR transitions in net.';\n\n const lines: string[] = [];\n lines.push('XOR Branch Coverage Analysis');\n lines.push('============================\\n');\n\n for (const [t, info] of transitionBranches) {\n lines.push(`Transition: ${t.name}`);\n lines.push(` Branches: ${info.totalBranches}`);\n lines.push(` Taken: [${[...info.takenBranches].join(', ')}]`);\n\n if (info.untakenBranches.size > 0) {\n lines.push(` UNREACHABLE: [${[...info.untakenBranches].join(', ')}]`);\n for (const idx of info.untakenBranches) {\n const places = [...info.branchOutputs[idx]!].map(p => p.name).join(', ');\n lines.push(` Branch ${idx} outputs: [${places}]`);\n }\n } else {\n lines.push(' All branches reachable');\n }\n lines.push('');\n }\n\n if (this.isXorComplete()) {\n lines.push('RESULT: All XOR branches are reachable.');\n } else {\n lines.push('RESULT: Some XOR branches are unreachable!');\n }\n\n return lines.join('\\n');\n },\n };\n}\n\nfunction computeBackwardReachability(scg: StateClassGraph, goals: Set<StateClass>): Set<StateClass> {\n const reachable = new Set(goals);\n const queue = [...goals];\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n for (const pred of scg.predecessors(current)) {\n if (!reachable.has(pred)) {\n reachable.add(pred);\n queue.push(pred);\n }\n }\n }\n\n return reachable;\n}\n\n/** Builder for TimePetriNetAnalyzer. */\nexport class TimePetriNetAnalyzerBuilder {\n private readonly net: PetriNet;\n private _initialMarking: MarkingState = MarkingState.empty();\n private readonly _goalPlaces = new Set<Place<any>>();\n private _maxClasses = 100_000;\n private readonly _environmentPlaces = new Set<EnvironmentPlace<any>>();\n private _environmentMode: EnvironmentAnalysisMode = ignore();\n\n constructor(net: PetriNet) {\n this.net = net;\n }\n\n initialMarking(marking: MarkingState): this {\n this._initialMarking = marking;\n return this;\n }\n\n goalPlaces(...places: Place<any>[]): this {\n for (const p of places) this._goalPlaces.add(p);\n return this;\n }\n\n maxClasses(max: number): this {\n this._maxClasses = max;\n return this;\n }\n\n environmentPlaces(...places: EnvironmentPlace<any>[]): this {\n for (const ep of places) this._environmentPlaces.add(ep);\n return this;\n }\n\n environmentMode(mode: EnvironmentAnalysisMode): this {\n this._environmentMode = mode;\n return this;\n }\n\n build(): TimePetriNetAnalyzer {\n if (this._goalPlaces.size === 0) {\n throw new Error('At least one goal place must be specified');\n }\n return TimePetriNetAnalyzer.create(\n this.net,\n this._initialMarking,\n this._goalPlaces,\n this._maxClasses,\n this._environmentPlaces,\n this._environmentMode,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,SAAS,YACd,OACA,YACU;AACV,QAAM,YAAY,CAAC,GAAG,KAAK;AAC3B,QAAM,WAAW,oBAAI,IAAe;AACpC,QAAM,UAAU,oBAAI,IAAe;AACnC,QAAM,UAAU,oBAAI,IAAO;AAC3B,QAAM,QAAa,CAAC;AACpB,QAAM,OAAiB,CAAC;AACxB,MAAI,QAAQ;AAEZ,WAAS,cAAc,GAAY;AACjC,aAAS,IAAI,GAAG,KAAK;AACrB,YAAQ,IAAI,GAAG,KAAK;AACpB;AACA,UAAM,KAAK,CAAC;AACZ,YAAQ,IAAI,CAAC;AAEb,eAAW,KAAK,WAAW,CAAC,GAAG;AAC7B,UAAI,CAAC,SAAS,IAAI,CAAC,GAAG;AACpB,sBAAc,CAAC;AACf,gBAAQ,IAAI,GAAG,KAAK,IAAI,QAAQ,IAAI,CAAC,GAAI,QAAQ,IAAI,CAAC,CAAE,CAAC;AAAA,MAC3D,WAAW,QAAQ,IAAI,CAAC,GAAG;AACzB,gBAAQ,IAAI,GAAG,KAAK,IAAI,QAAQ,IAAI,CAAC,GAAI,SAAS,IAAI,CAAC,CAAE,CAAC;AAAA,MAC5D;AAAA,IACF;AAEA,QAAI,QAAQ,IAAI,CAAC,MAAM,SAAS,IAAI,CAAC,GAAG;AACtC,YAAM,MAAM,oBAAI,IAAO;AACvB,UAAI;AACJ,SAAG;AACD,YAAI,MAAM,IAAI;AACd,gB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IAAM,8BAAN,MAAkC;AAAA,EACtB;AAAA,EACT,kBAAgC,aAAa,MAAM;AAAA,EAC1C,cAAc,oBAAI,IAAgB;AAAA,EAC3C,cAAc;AAAA,EACL,qBAAqB,oBAAI,IAA2B;AAAA,EAC7D,mBAA4C,OAAO;AAAA,EAE3D,YAAY,KAAe;AACzB,SAAK,MAAM;AAAA,EACb;AAAA,EAEA,eAAe,SAA6B;AAC1C,SAAK,kBAAkB;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,cAAc,QAA4B;AACxC,eAAW,KAAK,OAAQ,MAAK,YAAY,IAAI,CAAC;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,WAAW,KAAmB;AAC5B,SAAK,cAAc;AACnB,WAAO;AAAA,EACT;AAAA,EAEA,qBAAqB,QAAuC;AAC1D,eAAW,MAAM,OAAQ,MAAK,mBAAmB,IAAI,EAAE;AACvD,WAAO;AAAA,EACT;AAAA,EAEA,gBAAgB,MAAqC;AACnD,SAAK,mBAAmB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,QAA8B;AAC5B,QAAI,KAAK,YAAY,SAAS,GAAG;AAC/B,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC7D;AACA,WAAO,qBAAqB;AAAA,MAC1B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
package/dist/viewer/index.js
CHANGED
|
@@ -6358,7 +6358,7 @@ textContent??"").replace(/^cluster_/,"");Mn.classList.toggle("is-hidden",!N.has(
|
|
|
6358
6358
|
en",!bn.has(v))}if(!Q)for(let Mn of Array.from(P.querySelectorAll("g.node.petri-replica")))Mn.classList.add("is-hidden");let Sn=new Map;for(let Mn of Array.from(P.querySelectorAll("g.node"))){let v=Mn.getAttribute("data-id");v&&Sn.set(v,Mn)}for(let Mn of Array.from(P.querySelectorAll("g.edge"))){let v=Mn.getAttribute("data-src")??"",Vn=Mn.getAttribute("data-dst")??"",te=Sn.get(v)?.classList.contains(
|
|
6359
6359
|
"is-hidden")??!1,pe=Sn.get(Vn)?.classList.contains("is-hidden")??!1;Mn.classList.toggle("is-hidden",te||pe)}}var Pfe=["--lpv-bg","--lpv-header-bg","--lpv-border","--lpv-text","--lpv-muted","--lpv-cluster-bg","--lpv-cluster-bg-collapsed","--lpv-cluster-stroke-width","--lpv-cluster-stroke-dash","--lpv-cluster-fill-tint","--lpv-dim-opacity","--lpv-active-filter-outline","--lpv-legend-bg","--lpv-chip-bg","--lpv-chip-active-bg","--lpv-sidebar-bg","--lpv-sidebar-border","--lpv-sidebar-text","--lpv-sidebar-mute\
|
|
6360
6360
|
d","--lpv-sidebar-chip-bg","--lpv-sidebar-chip-hover-bg","--lpv-sidebar-chip-off-opacity","--lpv-shared-glyph-color","--lpv-replica-fill","--lpv-replica-stroke","--lpv-highlight-stroke","--lpv-highlight-glow","--lpv-neighbor-stroke","--lpv-faded-node-opacity","--lpv-faded-edge-opacity","--lpv-faded-cluster-opacity"];var zPe=/^\s*subgraph\s+cluster_[A-Za-z0-9_]+\s*\{\s*$/,KPe=/^\s*\}\s*$/;function Cfe(P){let O=P.split("\n"),N=[],Q=0;for(let bn of O){if(zPe.test(bn)){Q++;continue}if(Q>0){if(KPe.test(bn)){Q--;continue}(bn.includes("[")||bn.includes("->"))&&N.push(_fe(bn));continue}if(bn.includes("->")&&(bn.includes("ltail=")||bn.includes("lhead="))){N.push(_fe(bn));continue}N.push(bn)}return N.join("\n")}function _fe(P){
|
|
6361
|
-
return P.replace(/,\s*ltail="cluster_[^"]*"/g,"").replace(/,\s*lhead="cluster_[^"]*"/g,"").replace(/\[\s*ltail="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*lhead="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*ltail="cluster_[^"]*"\s*\]/g,"[]").replace(/\[\s*lhead="cluster_[^"]*"\s*\]/g,"[]")}var Ofe="
|
|
6361
|
+
return P.replace(/,\s*ltail="cluster_[^"]*"/g,"").replace(/,\s*lhead="cluster_[^"]*"/g,"").replace(/\[\s*ltail="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*lhead="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*ltail="cluster_[^"]*"\s*\]/g,"[]").replace(/\[\s*lhead="cluster_[^"]*"\s*\]/g,"[]")}var Ofe="5.0.0";async function ale(P,O,N={}){let Q=N.previousHandle??null,bn=Q?new Set(Q.collapsedPrefixes):new Set,Sn=Q?.activeFilter??null,Mn=N.subnets??Q?.subnets??"show";Q&&Q.dispose();let v=await Promise.resolve().then(()=>(lle(),fle)),Vn=(N.layout??"elk")==="elk",te=Mn==="hide"?Cfe(P):P,pe={clusterLayout:N.clusterLayout,leafPacking:N.leafPacking},$e=Vn?await v.renderDotToSvgWithElkLayout(te,pe):await v.renderDotToSvg(
|
|
6362
6362
|
te);O.innerHTML="",O.appendChild($e),O.classList.add("libpetri-viewer");let ft=mfe($e,N.panzoom),gt=z0n($e);Ffe(gt);let $t=N.layout??"elk";$t==="elk"&&(xfe($e),vz($e));let Be=new Set,dt=null,Ie=null,_t=!1,We=null,Pn=null,Bt=!0;function It(){if(!N.chrome||We&&We.parentNode===O)return;We=document.createElement("div"),We.className="libpetri-viewer-chrome",We.style.position="absolute",We.style.inset="\
|
|
6363
6363
|
0",We.style.pointerEvents="none";let Rt=document.createElement("div");Rt.className="diagram-controls",Rt.style.pointerEvents="auto";let or=document.createElement("button");or.type="button",or.className="diagram-btn btn-reset",or.title="Reset view",or.textContent="Reset",or.addEventListener("click",()=>Ir.fit());let ui=document.createElement("button");ui.type="button",ui.className="diagram-btn btn-\
|
|
6364
6364
|
fullscreen",ui.title="Toggle fullscreen",ui.textContent="Fullscreen",ui.addEventListener("click",()=>Yr(O,ui));let wr=document.createElement("button");wr.type="button",wr.className="diagram-btn btn-subnets",wr.title=Mn==="show"?"Hide subnet groupings":"Show subnet groupings",wr.textContent=Mn==="show"?"Flat view":"Subnets view",wr.addEventListener("click",()=>{Ir.toggleSubnets()}),Rt.appendChild(wr),
|