Merge lp:~tapaal-contributor/tapaal/cpn-tapn into lp:~tapaal-contributor/tapaal/cpn-gui-dev

Proposed by Kenneth Yrke Jørgensen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1577
Merged at revision: 1575
Proposed branch: lp:~tapaal-contributor/tapaal/cpn-tapn
Merge into: lp:~tapaal-contributor/tapaal/cpn-gui-dev
Diff against target: 1231 lines (+467/-282)
15 files modified
src/dk/aau/cs/verification/QueryResult.java (+37/-0)
src/dk/aau/cs/verification/VerificationResult.java (+30/-15)
src/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPN.java (+30/-24)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java (+50/-51)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNCTLOutputParser.java (+9/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOutputParser.java (+9/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPN.java (+93/-22)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java (+1/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java (+38/-6)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOutputParser.java (+21/-0)
src/net/tapaal/gui/petrinet/dialog/QueryDialog.java (+12/-12)
src/net/tapaal/gui/petrinet/verification/RunVerification.java (+120/-135)
src/net/tapaal/gui/petrinet/verification/RunVerificationBase.java (+13/-12)
src/net/tapaal/gui/petrinet/verification/Verifier.java (+3/-1)
src/net/tapaal/gui/petrinet/verification/VerifyTAPNEngineOptions.java (+1/-1)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/cpn-tapn
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+415171@code.launchpad.net

Description of the change

Needs new version of verifytapn from https://github.com/TAPAAL/verifytapn/pull/14

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote :

Tested and works. Engine is also merged to trunk now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dk/aau/cs/verification/QueryResult.java'
2--- src/dk/aau/cs/verification/QueryResult.java 2022-01-09 16:46:17 +0000
3+++ src/dk/aau/cs/verification/QueryResult.java 2022-02-07 08:12:13 +0000
4@@ -10,6 +10,43 @@
5 private final TAPNQuery query;
6 private final BoundednessAnalysisResult boundednessAnalysis;
7
8+ public boolean isSolvedUsingQuerySimplification() {
9+ return solvedUsingQuerySimplification;
10+ }
11+
12+ public void setSolvedUsingQuerySimplification(boolean solvedUsingQuerySimplification) {
13+ this.solvedUsingQuerySimplification = solvedUsingQuerySimplification;
14+ }
15+
16+ public boolean isSolvedUsingTraceAbstractRefinement() {
17+ return solvedUsingTraceAbstractRefinement;
18+ }
19+
20+ public void setSolvedUsingTraceAbstractRefinement(boolean solvedUsingTraceAbstractRefinement) {
21+ this.solvedUsingTraceAbstractRefinement = solvedUsingTraceAbstractRefinement;
22+ }
23+
24+ public boolean isSolvedUsingStateEquation() {
25+ return solvedUsingStateEquation;
26+ }
27+
28+ public void setSolvedUsingStateEquation(boolean solvedUsingStateEquation) {
29+ this.solvedUsingStateEquation = solvedUsingStateEquation;
30+ }
31+
32+ public boolean isSolvedUsingSiphonTrap() {
33+ return solvedUsingSiphonTrap;
34+ }
35+
36+ public void setSolvedUsingSiphonTrap(boolean solvedUsingSiphonTrap) {
37+ this.solvedUsingSiphonTrap = solvedUsingSiphonTrap;
38+ }
39+
40+ private boolean solvedUsingQuerySimplification;
41+ private boolean solvedUsingTraceAbstractRefinement;
42+ private boolean solvedUsingStateEquation;
43+ private boolean solvedUsingSiphonTrap;
44+
45 public boolean isCTL = false;
46 public QueryResult(boolean satisfied, BoundednessAnalysisResult boundednessAnalysis, TAPNQuery query, boolean discreteInclusion){
47 this.satisfied = satisfied;
48
49=== modified file 'src/dk/aau/cs/verification/VerificationResult.java'
50--- src/dk/aau/cs/verification/VerificationResult.java 2021-12-09 19:54:26 +0000
51+++ src/dk/aau/cs/verification/VerificationResult.java 2022-02-07 08:12:13 +0000
52@@ -18,10 +18,27 @@
53 private Stats stats;
54 private NameMapping nameMapping;
55 private TTrace secondaryTrace;
56- private boolean isSolvedUsingStateEquation = false;
57+
58 private Tuple<TimedArcPetriNet, NameMapping> unfoldedModel;
59-
60- public boolean isQuerySatisfied() {
61+ private boolean resolvedUsingSkeletonPreprocessor = false;
62+
63+ public boolean isSolvedUsingQuerySimplification() {
64+ return queryResult.isSolvedUsingQuerySimplification();
65+ }
66+
67+ public boolean isSolvedUsingTraceAbstractRefinement() {
68+ return queryResult.isSolvedUsingTraceAbstractRefinement();
69+ }
70+
71+ public boolean isSolvedUsingStateEquation() {
72+ return queryResult.isSolvedUsingStateEquation();
73+ }
74+
75+ public boolean isSolvedUsingSiphonTrap() {
76+ return queryResult.isSolvedUsingSiphonTrap();
77+ }
78+
79+ public boolean isQuerySatisfied() {
80 return queryResult.isQuerySatisfied();
81 }
82
83@@ -32,15 +49,10 @@
84 this.stats = stats;
85 this.rawOutput = rawOutput;
86 }
87-
88- public VerificationResult(QueryResult queryResult, TTrace trace, long verificationTime, Stats stats, boolean isSolvedUsingStateEquation){
89- this(queryResult, trace, verificationTime, stats, null);
90- this.isSolvedUsingStateEquation = isSolvedUsingStateEquation;
91- }
92
93 public VerificationResult(QueryResult queryResult, TTrace trace, long verificationTime, Stats stats, boolean isSolvedUsingStateEquation, String rawOutput, Tuple<TimedArcPetriNet, NameMapping> unfoldedModel){
94 this(queryResult, trace, verificationTime, stats, rawOutput);
95- this.isSolvedUsingStateEquation = isSolvedUsingStateEquation;
96+ //this.solvedUsingStateEquation = isSolvedUsingStateEquation; // This was the old value using for both state equation and untimed skeleton check
97 this.unfoldedModel = unfoldedModel;
98 }
99
100@@ -111,8 +123,15 @@
101 returnList.sort(new transitionTupleComparator());
102 return returnList;
103 }
104-
105- public static class transitionTupleComparator implements Comparator<Tuple<String,Integer>> {
106+
107+ public boolean isResolvedUsingSkeletonPreprocessor() {
108+ return resolvedUsingSkeletonPreprocessor;
109+ }
110+ public boolean setResolvedUsingSkeletonAnalysisPreprocessor(boolean b) {
111+ return this.resolvedUsingSkeletonPreprocessor = b;
112+ }
113+
114+ public static class transitionTupleComparator implements Comparator<Tuple<String,Integer>> {
115
116 public int compare(Tuple<String,Integer> tuple1,Tuple<String,Integer> tuple2) {
117 return tuple2.value2() - tuple1.value2();
118@@ -210,10 +229,6 @@
119 return m;
120 }
121
122- public boolean isSolvedUsingStateEquation(){
123- return isSolvedUsingStateEquation;
124- }
125-
126 public void addTime(long timeToAdd) {
127 verificationTime += timeToAdd;
128 }
129
130=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPN.java'
131--- src/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPN.java 2022-01-28 09:46:10 +0000
132+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPN.java 2022-02-07 08:12:13 +0000
133@@ -5,14 +5,33 @@
134 import dk.aau.cs.TCTL.TCTLAGNode;
135 import dk.aau.cs.TCTL.TCTLEFNode;
136 import dk.aau.cs.TCTL.TCTLEGNode;
137-import pipe.gui.petrinet.PetriNetTab;
138 import dk.aau.cs.io.LoadedModel;
139 import dk.aau.cs.io.TapnEngineXmlLoader;
140-import dk.aau.cs.model.tapn.*;
141+import dk.aau.cs.model.tapn.LocalTimedPlace;
142+import dk.aau.cs.model.tapn.TAPNQuery;
143+import dk.aau.cs.model.tapn.TimedArcPetriNet;
144+import dk.aau.cs.model.tapn.TimedPlace;
145 import dk.aau.cs.model.tapn.simulation.TimedArcPetriNetTrace;
146-import dk.aau.cs.util.*;
147+import dk.aau.cs.util.FormatException;
148+import dk.aau.cs.util.Tuple;
149+import dk.aau.cs.util.UnsupportedModelException;
150+import dk.aau.cs.util.UnsupportedQueryException;
151 import dk.aau.cs.verification.*;
152+import net.tapaal.Preferences;
153+import net.tapaal.TAPAAL;
154+import net.tapaal.gui.petrinet.verification.InclusionPlaces;
155+import net.tapaal.gui.petrinet.verification.InclusionPlaces.InclusionPlacesOption;
156+import net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption;
157+import net.tapaal.gui.petrinet.verification.TAPNQuery.WorkflowMode;
158+import net.tapaal.gui.petrinet.verification.UnfoldNet;
159+import pipe.gui.Constants;
160+import pipe.gui.FileFinder;
161+import pipe.gui.MessengerImpl;
162+import pipe.gui.TAPAALGUI;
163+import pipe.gui.petrinet.PetriNetTab;
164+import pipe.gui.petrinet.dataLayer.DataLayer;
165
166+import javax.swing.*;
167 import java.io.BufferedReader;
168 import java.io.File;
169 import java.io.IOException;
170@@ -20,18 +39,6 @@
171 import java.util.ArrayList;
172 import java.util.List;
173
174-import net.tapaal.Preferences;
175-import net.tapaal.TAPAAL;
176-import pipe.gui.petrinet.dataLayer.DataLayer;
177-import net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption;
178-import net.tapaal.gui.petrinet.verification.TAPNQuery.WorkflowMode;
179-import pipe.gui.*;
180-import net.tapaal.gui.petrinet.verification.UnfoldNet;
181-import net.tapaal.gui.petrinet.verification.InclusionPlaces;
182-import net.tapaal.gui.petrinet.verification.InclusionPlaces.InclusionPlacesOption;
183-
184-import javax.swing.*;
185-
186 public class VerifyDTAPN implements ModelChecker{
187
188 private static final String NEED_TO_LOCATE_VERIFYDTAPN_MSG = "TAPAAL needs to know the location of the file verifydtapn.\n\n"
189@@ -274,9 +281,13 @@
190
191 TimedArcPetriNetTrace tapnTrace = null;
192
193-
194 boolean isColored = (lens != null && lens.isColored() || model.value1().parentNetwork().isColored());
195- if(options.traceOption() != TraceOption.NONE && isColored && queryResult != null && queryResult.value1() != null && queryResult.value1().isQuerySatisfied()) {
196+ boolean showTrace = ((query.getProperty() instanceof TCTLEFNode && queryResult.value1().isQuerySatisfied()) ||
197+ (query.getProperty() instanceof TCTLAGNode && !queryResult.value1().isQuerySatisfied()) ||
198+ (query.getProperty() instanceof TCTLEGNode && queryResult.value1().isQuerySatisfied()) ||
199+ (query.getProperty() instanceof TCTLAFNode && !queryResult.value1().isQuerySatisfied()));
200+
201+ if(options.traceOption() != TraceOption.NONE && isColored && showTrace) {
202 TapnEngineXmlLoader tapnLoader = new TapnEngineXmlLoader();
203 File fileOut = new File(options.unfoldedModelPath());
204 File queriesOut = new File(options.unfoldedQueriesPath());
205@@ -291,11 +302,7 @@
206 tapnTrace = parseTrace(!errorOutput.contains("Trace:") ? errorOutput : (errorOutput.split("Trace:")[1]), options, model, exportedModel, query, queryResult.value1());
207 }
208
209- if(tapnTrace == null){
210- String message = "No trace could be generated.\n\n";
211- message += "Model checker output:\n" + standardOutput;
212- messenger.displayWrappedErrorMessage(message,"No trace found");
213- } else {
214+ if (tapnTrace != null) {
215 int dialogResult = JOptionPane.showConfirmDialog(null, "There is a trace that will be displayed in a new tab on the unfolded net/query.", "Open trace", JOptionPane.OK_CANCEL_OPTION);
216 if (dialogResult == JOptionPane.OK_OPTION) {
217 newTab = new PetriNetTab(loadedModel.network(), loadedModel.templates(), loadedModel.queries(), new PetriNetTab.TAPNLens(TAPAALGUI.getCurrentTab().getLens().isTimed(), TAPAALGUI.getCurrentTab().getLens().isGame(), false));
218@@ -312,6 +319,7 @@
219 options.setTraceOption(TraceOption.NONE);
220 }
221 }
222+
223 } catch (FormatException e) {
224 e.printStackTrace();
225 return null;
226@@ -352,8 +360,6 @@
227 (query.getProperty() instanceof TCTLEGNode && !queryResult.isQuerySatisfied()) ||
228 (query.getProperty() instanceof TCTLAFNode && queryResult.isQuerySatisfied())) {
229 return null;
230- } else {
231- messenger.displayErrorMessage("Verifydtapn cannot generate the requested trace for the model. Try another trace option.");
232 }
233 }
234 }
235
236=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java'
237--- src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java 2022-01-28 12:27:29 +0000
238+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java 2022-02-07 08:12:13 +0000
239@@ -287,50 +287,55 @@
240
241 Tuple<QueryResult, Stats> queryResult = parseQueryResult(standardOutput, model.value1().marking().size() + query.getExtraTokens(), query.getExtraTokens(), query);
242
243- boolean isColored = (lens != null && lens.isColored() || model.value1().parentNetwork().isColored());
244- if (options.traceOption() != TraceOption.NONE && isColored && queryResult != null && queryResult.value1() != null && queryResult.value1().isQuerySatisfied()) {
245- PNMLoader tapnLoader = new PNMLoader();
246- File fileOut = new File(options.unfoldedModelPath());
247- File queriesOut = new File(options.unfoldedQueriesPath());
248- PetriNetTab newTab;
249- LoadedModel loadedModel = null;
250- try {
251- loadedModel = tapnLoader.load(fileOut);
252- TAPNComposer newComposer = new TAPNComposer(new MessengerImpl(), true);
253- model = newComposer.transformModel(loadedModel.network());
254-
255- if (queryResult != null && queryResult.value1() != null) {
256- tapnTrace = parseTrace(errorOutput, options, model, exportedModel, query, queryResult.value1(), true);
257- }
258-
259- if (!(tapnTrace == null)) {
260- int dialogResult = JOptionPane.showConfirmDialog(null, "There is a trace that will be displayed in a new tab on the unfolded net/query.", "Open trace", JOptionPane.OK_CANCEL_OPTION);
261- if (dialogResult == JOptionPane.OK_OPTION) {
262- newTab = new PetriNetTab(loadedModel.network(), loadedModel.templates(), loadedModel.queries(), new PetriNetTab.TAPNLens(TAPAALGUI.getCurrentTab().getLens().isTimed(), TAPAALGUI.getCurrentTab().getLens().isGame(), false));
263-
264- //The query being verified should be the only query
265- for (net.tapaal.gui.petrinet.verification.TAPNQuery loadedQuery : UnfoldNet.getQueries(queriesOut, loadedModel.network())) {
266- newTab.setInitialName(loadedQuery.getName() + " - unfolded");
267- loadedQuery.copyOptions(dataLayerQuery);
268- newTab.addQuery(loadedQuery);
269- }
270- TAPAALGUI.openNewTabFromStream(newTab);
271- } else {
272- options.setTraceOption(TraceOption.NONE);
273- }
274- }
275- } catch (FormatException e) {
276- e.printStackTrace();
277- } catch (ThreadDeath d) {
278- return null;
279- }
280- }
281-
282 if (queryResult == null || queryResult.value1() == null) {
283 return new VerificationResult<TimedArcPetriNetTrace>(errorOutput + System.getProperty("line.separator") + standardOutput, runner.getRunningTime());
284 } else {
285+
286+ boolean isColored = (lens != null && lens.isColored() || model.value1().parentNetwork().isColored());
287+ boolean showTrace = ((query.getProperty() instanceof TCTLEFNode && queryResult.value1().isQuerySatisfied()) ||
288+ (query.getProperty() instanceof TCTLAGNode && !queryResult.value1().isQuerySatisfied()) ||
289+ (query.getProperty() instanceof TCTLEGNode && queryResult.value1().isQuerySatisfied()) ||
290+ (query.getProperty() instanceof TCTLAFNode && !queryResult.value1().isQuerySatisfied()));
291+
292+ if (options.traceOption() != TraceOption.NONE && isColored && showTrace) {
293+ PNMLoader tapnLoader = new PNMLoader();
294+ File fileOut = new File(options.unfoldedModelPath());
295+ File queriesOut = new File(options.unfoldedQueriesPath());
296+ PetriNetTab newTab;
297+ LoadedModel loadedModel = null;
298+ try {
299+ loadedModel = tapnLoader.load(fileOut);
300+ TAPNComposer newComposer = new TAPNComposer(new MessengerImpl(), true);
301+ model = newComposer.transformModel(loadedModel.network());
302+
303+ if (queryResult != null && queryResult.value1() != null) {
304+ tapnTrace = parseTrace(errorOutput, options, model, exportedModel, query, queryResult.value1());
305+ }
306+
307+ if (!(tapnTrace == null)) {
308+ int dialogResult = JOptionPane.showConfirmDialog(null, "There is a trace that will be displayed in a new tab on the unfolded net/query.", "Open trace", JOptionPane.OK_CANCEL_OPTION);
309+ if (dialogResult == JOptionPane.OK_OPTION) {
310+ newTab = new PetriNetTab(loadedModel.network(), loadedModel.templates(), loadedModel.queries(), new PetriNetTab.TAPNLens(TAPAALGUI.getCurrentTab().getLens().isTimed(), TAPAALGUI.getCurrentTab().getLens().isGame(), false));
311+
312+ //The query being verified should be the only query
313+ for (net.tapaal.gui.petrinet.verification.TAPNQuery loadedQuery : UnfoldNet.getQueries(queriesOut, loadedModel.network())) {
314+ newTab.setInitialName(loadedQuery.getName() + " - unfolded");
315+ loadedQuery.copyOptions(dataLayerQuery);
316+ newTab.addQuery(loadedQuery);
317+ }
318+ TAPAALGUI.openNewTabFromStream(newTab);
319+ } else {
320+ options.setTraceOption(TraceOption.NONE);
321+ }
322+ }
323+ } catch (FormatException e) {
324+ e.printStackTrace();
325+ } catch (ThreadDeath d) {
326+ return null;
327+ }
328+ }
329+
330 ctlOutput = queryResult.value1().isCTL;
331- boolean approximationResult = queryResult.value2().discoveredStates() == 0; // Result is from over-approximation
332
333 if (tapnTrace == null) {
334 if (!errorOutput.contains("Trace") && standardOutput.contains("<trace>")) {
335@@ -342,17 +347,16 @@
336 tapnTrace = parseTrace(errorOutput, options, model, exportedModel, query, queryResult.value1());
337 }
338 }
339- return new VerificationResult<TimedArcPetriNetTrace>(queryResult.value1(), tapnTrace, runner.getRunningTime(), queryResult.value2(), approximationResult, standardOutput, model);
340+ var result = new VerificationResult<TimedArcPetriNetTrace>(queryResult.value1(), tapnTrace, runner.getRunningTime(), queryResult.value2(), false, standardOutput, model);
341+ if (queryResult.value1().isSolvedUsingStateEquation()) {
342+
343+ }
344+ return result;
345 }
346 }
347 }
348
349 private TimedArcPetriNetTrace parseTrace(String output, VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model, ExportedVerifyTAPNModel exportedModel, TAPNQuery query, QueryResult queryResult) {
350- return parseTrace(output, options, model, exportedModel, query, queryResult, false);
351- }
352- //XXX: this noWarning thinks is a huge hack to avoid warning shown twice for color nets, the warning should not be shown
353- // in this methods in the first case
354- private TimedArcPetriNetTrace parseTrace(String output, VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model, ExportedVerifyTAPNModel exportedModel, TAPNQuery query, QueryResult queryResult, boolean noWarning) {
355 if (((VerifyTAPNOptions) options).trace() == TraceOption.NONE) return null;
356
357 VerifyTAPNTraceParser traceParser = new VerifyTAPNTraceParser(model.value1());
358@@ -367,11 +371,6 @@
359 (query.getProperty() instanceof TCTLEGNode && !queryResult.isQuerySatisfied()) ||
360 (query.getProperty() instanceof TCTLAFNode && queryResult.isQuerySatisfied())) {
361 return null;
362- } else {
363- if (!noWarning) {
364- String message = "No trace could be generated.\n\n";
365- messenger.displayWrappedErrorMessage(message, "No trace found");
366- }
367 }
368 }
369 }
370
371=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyPNCTLOutputParser.java'
372--- src/dk/aau/cs/verification/VerifyTAPN/VerifyPNCTLOutputParser.java 2020-07-13 14:30:00 +0000
373+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyPNCTLOutputParser.java 2022-02-07 08:12:13 +0000
374@@ -48,6 +48,8 @@
375 result = false;
376 foundResult = true;
377 } else {
378+ parseSolvedMethod(line);
379+
380 Matcher matcher = configurationsPattern.matcher(line);
381 if (matcher.find()) {
382 configurtations = Long.parseLong(matcher.group(1));
383@@ -86,7 +88,13 @@
384 if(!foundResult) return null;
385
386 BoundednessAnalysisResult boundedAnalysis = new BoundednessAnalysisResult(totalTokens, maxUsedTokens, extraTokens);
387- return new Tuple<QueryResult, Stats>(new QueryResult(result, boundedAnalysis, query, false), new Stats(configurtations, markings, edges, processedEdges, processedNEdges, exploredConfigurations));
388+ var qr = new QueryResult(result, boundedAnalysis, query, false);
389+ qr.setSolvedUsingQuerySimplification(solvedUsingQuerySimplification);
390+ qr.setSolvedUsingStateEquation(solvedUsingStateEquation);
391+ qr.setSolvedUsingTraceAbstractRefinement(solvedUsingTraceAbstractRefinement);
392+ qr.setSolvedUsingSiphonTrap(solvedUsingSiphonTrap);
393+
394+ return new Tuple<QueryResult, Stats>(qr, new Stats(configurtations, markings, edges, processedEdges, processedNEdges, exploredConfigurations));
395 } catch (Exception e) {
396 e.printStackTrace();
397 }
398
399=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOutputParser.java'
400--- src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOutputParser.java 2020-07-13 14:30:00 +0000
401+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOutputParser.java 2022-02-07 08:12:13 +0000
402@@ -90,6 +90,8 @@
403 result = false;
404 foundResult = true;
405 } else {
406+ parseSolvedMethod(line);
407+
408 matcher = discoveredPattern.matcher(line);
409 if(matcher.find()){
410 discovered = Integer.parseInt(matcher.group(1));
411@@ -172,7 +174,13 @@
412 if(!foundResult) return null;
413 BoundednessAnalysisResult boundedAnalysis = new BoundednessAnalysisResult(totalTokens, maxUsedTokens, extraTokens);
414 ReductionStats reductionStats = reductionUsed? new ReductionStats(removedTransitions, removedPlaces, ruleA, ruleB, ruleC, ruleD, ruleE, ruleF, ruleG, ruleH, ruleI) : null;
415- return new Tuple<QueryResult, Stats>(new QueryResult(result, boundedAnalysis, query, false), new Stats(discovered, explored, explored, transitionStats, placeBoundStats, reductionStats));
416+
417+ var qr = new QueryResult(result, boundedAnalysis, query, false);
418+ qr.setSolvedUsingQuerySimplification(solvedUsingQuerySimplification);
419+ qr.setSolvedUsingStateEquation(solvedUsingStateEquation);
420+ qr.setSolvedUsingTraceAbstractRefinement(solvedUsingTraceAbstractRefinement);
421+ qr.setSolvedUsingSiphonTrap(solvedUsingSiphonTrap);
422+ return new Tuple<QueryResult, Stats>(qr, new Stats(discovered, explored, explored, transitionStats, placeBoundStats, reductionStats));
423 } catch (Exception e) {
424 e.printStackTrace();
425 }
426
427=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPN.java'
428--- src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPN.java 2022-01-28 09:46:10 +0000
429+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPN.java 2022-02-07 08:12:13 +0000
430@@ -7,9 +7,14 @@
431 import java.util.ArrayList;
432 import java.util.List;
433
434+import dk.aau.cs.io.LoadedModel;
435+import dk.aau.cs.io.TapnEngineXmlLoader;
436+import dk.aau.cs.util.FormatException;
437 import dk.aau.cs.verification.*;
438 import net.tapaal.Preferences;
439 import net.tapaal.TAPAAL;
440+import net.tapaal.gui.petrinet.verification.UnfoldNet;
441+import pipe.gui.TAPAALGUI;
442 import pipe.gui.petrinet.PetriNetTab;
443 import pipe.gui.petrinet.dataLayer.DataLayer;
444 import net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption;
445@@ -32,6 +37,8 @@
446 import dk.aau.cs.util.UnsupportedModelException;
447 import dk.aau.cs.util.UnsupportedQueryException;
448
449+import javax.swing.*;
450+
451 public class VerifyTAPN implements ModelChecker {
452 private static final String NEED_TO_LOCATE_VERIFYTAPN_MSG = "TAPAAL needs to know the location of the file verifytapn.\n\n"
453 + "Verifytapn is a part of the TAPAAL distribution and it is\n"
454@@ -217,16 +224,21 @@
455 }
456
457 if(((VerifyTAPNOptions)options).discreteInclusion()) mapDiscreteInclusionPlacesToNewNames(options, model);
458-
459- VerifyTAPNExporter exporter = new VerifyTAPNExporter();
460-
461- ExportedVerifyTAPNModel exportedModel = exporter.export(model.value1(), query, null,model.value2(), guiModel, dataLayerQuery);
462-
463- if (exportedModel == null) {
464- messenger.displayErrorMessage("There was an error exporting the model");
465- }
466-
467- return verify(options, model, exportedModel, query);
468+
469+ ExportedVerifyTAPNModel exportedModel;
470+ if ((lens != null && lens.isColored() || model.value1().parentNetwork().isColored())) {
471+ VerifyTAPNExporter exporter = new VerifyTACPNExporter();
472+ exportedModel = exporter.export(model.value1(), query, TAPAALGUI.getCurrentTab().getLens(),model.value2(), guiModel, dataLayerQuery);
473+ } else {
474+ VerifyTAPNExporter exporter = new VerifyTAPNExporter();
475+ exportedModel = exporter.export(model.value1(), query, TAPAALGUI.getCurrentTab().getLens(),model.value2(), guiModel, dataLayerQuery);
476+ }
477+
478+ if (exportedModel == null) {
479+ messenger.displayErrorMessage("There was an error exporting the model");
480+ }
481+
482+ return verify(options, model, exportedModel, query, dataLayerQuery, lens);
483 }
484
485 protected void mapDiscreteInclusionPlacesToNewNames(VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model) {
486@@ -250,7 +262,7 @@
487 ((VerifyTAPNOptions)options).setInclusionPlaces(new InclusionPlaces(InclusionPlacesOption.UserSpecified, inclusionPlaces));
488 }
489
490- protected VerificationResult<TimedArcPetriNetTrace> verify(VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model, ExportedVerifyTAPNModel exportedModel, TAPNQuery query) {
491+ protected VerificationResult<TimedArcPetriNetTrace> verify(VerificationOptions options, Tuple<TimedArcPetriNet, NameMapping> model, ExportedVerifyTAPNModel exportedModel, TAPNQuery query, net.tapaal.gui.petrinet.verification.TAPNQuery dataLayerQuery, PetriNetTab.TAPNLens lens) {
492 ((VerifyTAPNOptions)options).setTokensInModel(model.value1().marking().size()); // TODO: get rid of me
493 runner = new ProcessRunner(verifytapnpath, createArgumentString(exportedModel.modelFile(), exportedModel.queryFile(), options));
494 runner.run();
495@@ -265,8 +277,65 @@
496 if (queryResult == null || queryResult.value1() == null) {
497 return new VerificationResult<TimedArcPetriNetTrace>(errorOutput + System.getProperty("line.separator") + standardOutput, runner.getRunningTime());
498 } else {
499- TimedArcPetriNetTrace tapnTrace = parseTrace(errorOutput, options, model, exportedModel, query, queryResult.value1());
500- return new VerificationResult<TimedArcPetriNetTrace>(queryResult.value1(), tapnTrace, runner.getRunningTime(), queryResult.value2(), standardOutput);
501+ TimedArcPetriNetTrace tapnTrace = null;
502+
503+
504+ boolean isColored = (lens != null && lens.isColored() || model.value1().parentNetwork().isColored());
505+ boolean showTrace = ((query.getProperty() instanceof TCTLEFNode && queryResult.value1().isQuerySatisfied()) ||
506+ (query.getProperty() instanceof TCTLAGNode && !queryResult.value1().isQuerySatisfied()) ||
507+ (query.getProperty() instanceof TCTLEGNode && queryResult.value1().isQuerySatisfied()) ||
508+ (query.getProperty() instanceof TCTLAFNode && !queryResult.value1().isQuerySatisfied()));
509+
510+ if(options.traceOption() != TraceOption.NONE && isColored && showTrace) {
511+ TapnEngineXmlLoader tapnLoader = new TapnEngineXmlLoader();
512+ File fileOut = new File(options.unfoldedModelPath());
513+ File queriesOut = new File(options.unfoldedQueriesPath());
514+ PetriNetTab newTab;
515+ LoadedModel loadedModel = null;
516+ try {
517+ loadedModel = tapnLoader.load(fileOut);
518+ TAPNComposer newComposer = new TAPNComposer(new MessengerImpl(), true);
519+ model = newComposer.transformModel(loadedModel.network());
520+
521+ if (queryResult != null && queryResult.value1() != null) {
522+ tapnTrace = parseTrace(!errorOutput.contains("Trace:") ? errorOutput : (errorOutput.split("Trace:")[1]), options, model, exportedModel, query, queryResult.value1());
523+ }
524+
525+ if (tapnTrace != null) {
526+ int dialogResult = JOptionPane.showConfirmDialog(null, "There is a trace that will be displayed in a new tab on the unfolded net/query.", "Open trace", JOptionPane.OK_CANCEL_OPTION);
527+ if (dialogResult == JOptionPane.OK_OPTION) {
528+ newTab = new PetriNetTab(loadedModel.network(), loadedModel.templates(), loadedModel.queries(), new PetriNetTab.TAPNLens(TAPAALGUI.getCurrentTab().getLens().isTimed(), TAPAALGUI.getCurrentTab().getLens().isGame(), false));
529+
530+ //The query being verified should be the only query
531+ for (net.tapaal.gui.petrinet.verification.TAPNQuery loadedQuery : UnfoldNet.getQueries(queriesOut, loadedModel.network())) {
532+ newTab.setInitialName(loadedQuery.getName() + " - unfolded");
533+ loadedQuery.copyOptions(dataLayerQuery);
534+ newTab.addQuery(loadedQuery);
535+ }
536+
537+ TAPAALGUI.openNewTabFromStream(newTab);
538+ } else {
539+ options.setTraceOption(TraceOption.NONE);
540+ }
541+ }
542+
543+ } catch (FormatException e) {
544+ e.printStackTrace();
545+ return null;
546+ } catch (ThreadDeath d) {
547+ d.printStackTrace();
548+ return null;
549+ } catch (Exception e) {
550+ e.printStackTrace();
551+ return null;
552+ }
553+ }
554+
555+ if (tapnTrace == null) {
556+ tapnTrace = parseTrace(errorOutput, options, model, exportedModel, query, queryResult.value1());
557+ }
558+ //return new VerificationResult<TimedArcPetriNetTrace>(queryResult.value1(), tapnTrace, runner.getRunningTime(), queryResult.value2(), standardOutput);
559+ return new VerificationResult<TimedArcPetriNetTrace>(queryResult.value1(), tapnTrace, null, runner.getRunningTime(), queryResult.value2(), false, standardOutput, model);
560 }
561 }
562 }
563@@ -276,15 +345,17 @@
564
565 VerifyTAPNTraceParser traceParser = new VerifyTAPNTraceParser(model.value1());
566 TimedArcPetriNetTrace trace = traceParser.parseTrace(new BufferedReader(new StringReader(output)));
567-
568- if (trace == null) {
569- if (((VerifyTAPNOptions) options).trace() != TraceOption.NONE) {
570- if((query.getProperty() instanceof TCTLEFNode && !queryResult.isQuerySatisfied()) || (query.getProperty() instanceof TCTLAGNode && queryResult.isQuerySatisfied()))
571- return null;
572- else
573- messenger.displayErrorMessage("Verifytapn cannot generate the requested trace for the model. Try another trace option.");
574- }
575- }
576+
577+ if (trace == null) {
578+ if (((VerifyTAPNOptions) options).trace() != TraceOption.NONE) {
579+ if ((query.getProperty() instanceof TCTLEFNode && !queryResult.isQuerySatisfied()) ||
580+ (query.getProperty() instanceof TCTLAGNode && queryResult.isQuerySatisfied()) ||
581+ (query.getProperty() instanceof TCTLEGNode && !queryResult.isQuerySatisfied()) ||
582+ (query.getProperty() instanceof TCTLAFNode && queryResult.isQuerySatisfied())) {
583+ return null;
584+ }
585+ }
586+ }
587 return trace;
588 }
589
590
591=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java'
592--- src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java 2022-01-14 19:03:21 +0000
593+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java 2022-02-07 08:12:13 +0000
594@@ -34,7 +34,7 @@
595 File modelFile = createTempFile(".xml");
596 File queryFile;
597 if (query.getCategory() == QueryCategory.CTL || query.getCategory() == QueryCategory.LTL || (lens != null && !lens.isGame() && lens.isColored())) {
598- queryFile = createTempFile(".xml");
599+ queryFile = createTempFile(".xml"); // TODO: Remeber to change this back to XML when verifytapn is updated
600 } else {
601 queryFile = createTempFile(".q");
602 }
603
604=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java'
605--- src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java 2022-01-23 12:36:41 +0000
606+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java 2022-02-07 08:12:13 +0000
607@@ -1,5 +1,7 @@
608 package dk.aau.cs.verification.VerifyTAPN;
609
610+import java.io.File;
611+import java.io.IOException;
612 import java.util.HashMap;
613 import java.util.Map;
614
615@@ -10,6 +12,7 @@
616 import dk.aau.cs.model.tapn.TimedPlace;
617 import dk.aau.cs.util.Require;
618 import dk.aau.cs.verification.VerificationOptions;
619+import pipe.gui.MessengerImpl;
620
621 public class VerifyTAPNOptions extends VerificationOptions{
622
623@@ -29,9 +32,29 @@
624 this(extraTokens,traceOption, search, symmetry, useStateequationCheck, discreteInclusion, new InclusionPlaces(), enableOverApproximation, enableUnderApproximation, approximationDenominator);
625 }
626
627+
628+
629+
630 public VerifyTAPNOptions(int extraTokens, TraceOption traceOption, SearchOption search, boolean symmetry, boolean useStateequationCheck, boolean discreteInclusion, InclusionPlaces inclusionPlaces, boolean enableOverApproximation, boolean enableUnderApproximation, int approximationDenominator) {
631 this(extraTokens,traceOption, search, symmetry, useStateequationCheck, discreteInclusion, new InclusionPlaces(), enableOverApproximation, enableUnderApproximation, approximationDenominator, false);
632 }
633+
634+
635+ public VerifyTAPNOptions(int extraTokens, TraceOption traceOption, SearchOption search, boolean symmetry, boolean useStateequationCheck, boolean discreteInclusion, InclusionPlaces inclusionPlaces, boolean enableOverApproximation, boolean enableUnderApproximation, int approximationDenominator, boolean tarOption, boolean isColor) {
636+ this(extraTokens,traceOption, search, symmetry, useStateequationCheck, discreteInclusion, new InclusionPlaces(), enableOverApproximation, enableUnderApproximation, approximationDenominator, tarOption);
637+
638+ if(isColor && trace() != TraceOption.NONE) // we only force unfolding when traces are involved
639+ {
640+ try {
641+ unfoldedModelPath = File.createTempFile("unfolded-", ".pnml").getAbsolutePath();
642+ unfoldedQueriesPath = File.createTempFile("unfoldedQueries-", ".xml").getAbsolutePath();
643+ } catch (IOException e) {
644+ new MessengerImpl().displayErrorMessage(e.getMessage(), "Error");
645+ }
646+ }
647+ }
648+
649+
650
651 public VerifyTAPNOptions(int extraTokens, TraceOption traceOption, SearchOption search, boolean symmetry, boolean useStateEquationCheck, boolean discreteInclusion, InclusionPlaces inclusionPlaces, boolean enableOverApproximation, boolean enableUnderApproximation, int approximationDenominator, boolean tarOption) {
652 this.extraTokens = extraTokens;
653@@ -75,6 +98,15 @@
654 public String toString() {
655 StringBuilder result = new StringBuilder();
656
657+ if(unfoldedModelPath != null && unfoldedQueriesPath != null)
658+ {
659+ result.append(" --write-unfolded-net ");
660+ result.append(unfoldedModelPath);
661+ result.append(" --write-unfolded-queries ");
662+ result.append(unfoldedQueriesPath);
663+ result.append(" ");
664+ }
665+
666 result.append(kBoundArg());
667 result.append(deadTokenArg());
668 result.append(traceMap.get(traceOption));
669@@ -106,8 +138,8 @@
670
671 public static Map<TraceOption, String> createTraceOptionsMap() {
672 HashMap<TraceOption, String> map = new HashMap<TraceOption, String>();
673- map.put(TraceOption.SOME, "--trace 1 --xml-trace");
674- map.put(TraceOption.FASTEST, "--trace 2 --xml-trace");
675+ map.put(TraceOption.SOME, "--trace 1 ");
676+ map.put(TraceOption.FASTEST, "--trace 2 ");
677 map.put(TraceOption.NONE, "");
678
679 return map;
680@@ -115,10 +147,10 @@
681
682 private static Map<SearchOption, String> createSearchOptionsMap() {
683 HashMap<SearchOption, String> map = new HashMap<SearchOption, String>();
684- map.put(SearchOption.BFS, "--search-type 0");
685- map.put(SearchOption.DFS, "--search-type 1");
686- map.put(SearchOption.RANDOM, "--search-type 2");
687- map.put(SearchOption.HEURISTIC, "--search-type 3");
688+ map.put(SearchOption.BFS, "--search-strategy BFS");
689+ map.put(SearchOption.DFS, "--search-strategy DFS");
690+ map.put(SearchOption.RANDOM, "--search-strategy RDFS");
691+ map.put(SearchOption.HEURISTIC, "--search-strategy MAX-COVER");
692 map.put(SearchOption.DEFAULT, "");
693 return map;
694 }
695
696=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOutputParser.java'
697--- src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOutputParser.java 2022-01-09 18:09:13 +0000
698+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOutputParser.java 2022-02-07 08:12:13 +0000
699@@ -33,6 +33,27 @@
700 this.extraTokens = extraTokens;
701 this.query = query;
702 }
703+
704+ private static final String SolvedUsingQuerySimplification_STRING = "Query solved by Query Simplification.";
705+ boolean solvedUsingQuerySimplification = false;
706+ private static final String solvedUsingTraceAbstractRefinement_STRING = "Solved using Trace Abstraction Refinement";
707+ boolean solvedUsingTraceAbstractRefinement = false;
708+ private static final String solvedUsingStateEquation_STRING = "Solved using Trace Abstraction Refinement";
709+ boolean solvedUsingStateEquation = false;
710+ private static final String solvedUsingSiphonTrap_STRING = "Solved using Siphon Trap";
711+ boolean solvedUsingSiphonTrap = false;
712+
713+ void parseSolvedMethod(String line) {
714+ if (line.contains(SolvedUsingQuerySimplification_STRING)) {
715+ solvedUsingQuerySimplification = true;
716+ } else if (line.contains(solvedUsingTraceAbstractRefinement_STRING)) {
717+ solvedUsingTraceAbstractRefinement = true;
718+ } else if (line.contains(solvedUsingStateEquation_STRING)) {
719+ solvedUsingStateEquation = true;
720+ } else if (line.contains(solvedUsingSiphonTrap_STRING)) {
721+ solvedUsingSiphonTrap = true;
722+ }
723+ }
724
725 public Tuple<QueryResult, Stats> parseOutput(String output) {
726 int discovered = 0;
727
728=== modified file 'src/net/tapaal/gui/petrinet/dialog/QueryDialog.java'
729--- src/net/tapaal/gui/petrinet/dialog/QueryDialog.java 2022-01-28 09:46:10 +0000
730+++ src/net/tapaal/gui/petrinet/dialog/QueryDialog.java 2022-02-07 08:12:13 +0000
731@@ -183,7 +183,7 @@
732 private JCheckBox useTimeDarts;
733 private JCheckBox usePTrie;
734 private JCheckBox useGCD;
735- private JCheckBox useOverApproximation;
736+ private JCheckBox skeletonAnalysis;
737 private JCheckBox useSiphonTrap;
738 private JCheckBox useQueryReduction;
739 private JCheckBox useReduction;
740@@ -423,7 +423,7 @@
741 boolean timeDarts = useTimeDarts.isSelected();
742 boolean pTrie = usePTrie.isSelected();
743 boolean gcd = useGCD.isSelected();
744- boolean overApproximation = useOverApproximation.isSelected();
745+ boolean overApproximation = skeletonAnalysis.isSelected();
746 boolean reduction = useReduction.isSelected();
747
748 TAPNQuery query = new TAPNQuery(
749@@ -1395,7 +1395,7 @@
750 usePTrie.setSelected(queryToCreateFrom.usePTrie());
751 useStubbornReduction.setSelected(queryToCreateFrom.isStubbornReductionEnabled());
752 useGCD.setSelected(queryToCreateFrom.useGCD());
753- useOverApproximation.setSelected(queryToCreateFrom.useOverApproximation());
754+ skeletonAnalysis.setSelected(queryToCreateFrom.useOverApproximation());
755 useReduction.setSelected(queryToCreateFrom.useReduction());
756 discreteInclusion.setSelected(queryToCreateFrom.discreteInclusion());
757
758@@ -3338,7 +3338,7 @@
759 useTimeDarts = new JCheckBox("Use Time Darts");
760 useGCD = new JCheckBox("Use GCD");
761 usePTrie = new JCheckBox("Use PTrie");
762- useOverApproximation = new JCheckBox("Use untimed state-equations check");
763+ skeletonAnalysis = new JCheckBox("Preprocess using skeleton analysis");
764 useTraceRefinement = new JCheckBox("Use trace abstraction refinement");
765 useTarjan = new JCheckBox("Use Tarjan");
766
767@@ -3352,7 +3352,7 @@
768 useTimeDarts.setSelected(false);
769 useGCD.setSelected(true);
770 usePTrie.setSelected(true);
771- useOverApproximation.setSelected(true);
772+ skeletonAnalysis.setSelected(true);
773 useTraceRefinement.setSelected(false);
774 useTarjan.setSelected(true);
775
776@@ -3366,7 +3366,7 @@
777 useTimeDarts.setToolTipText(TOOL_TIP_TIME_DARTS);
778 useGCD.setToolTipText(TOOL_TIP_GCD);
779 usePTrie.setToolTipText(TOOL_TIP_PTRIE);
780- useOverApproximation.setToolTipText(TOOL_TIP_OVERAPPROX);
781+ skeletonAnalysis.setToolTipText(TOOL_TIP_OVERAPPROX);
782 useTraceRefinement.setToolTipText(TOOL_TIP_USE_TRACE_REFINEMENT);
783 useTarjan.setToolTipText(TOOL_TIP_USE_TARJAN);
784
785@@ -3408,7 +3408,7 @@
786 reductionOptionsPanel.add(useStubbornReduction, gbc);
787 gbc.gridx = 0;
788 gbc.gridy = 3;
789- reductionOptionsPanel.add(useOverApproximation, gbc);
790+ reductionOptionsPanel.add(skeletonAnalysis, gbc);
791 gbc.gridx = 2;
792 gbc.gridy = 1;
793 reductionOptionsPanel.add(selectInclusionPlacesButton, gbc);
794@@ -3582,13 +3582,13 @@
795
796 private void refreshOverApproximationOption() {
797 if (queryHasDeadlock() || newProperty.toString().contains("EG") || newProperty.toString().contains("AF")){
798- useOverApproximation.setSelected(false);
799- useOverApproximation.setEnabled(false);
800+ skeletonAnalysis.setSelected(false);
801+ skeletonAnalysis.setEnabled(false);
802 } else {
803- if(!useOverApproximation.isEnabled()){
804- useOverApproximation.setSelected(true);
805+ if(!skeletonAnalysis.isEnabled()){
806+ skeletonAnalysis.setSelected(true);
807 }
808- useOverApproximation.setEnabled(true);
809+ skeletonAnalysis.setEnabled(true);
810 }
811
812 if (lens.isGame()) {
813
814=== modified file 'src/net/tapaal/gui/petrinet/verification/RunVerification.java'
815--- src/net/tapaal/gui/petrinet/verification/RunVerification.java 2022-01-09 19:10:28 +0000
816+++ src/net/tapaal/gui/petrinet/verification/RunVerification.java 2022-02-07 08:12:13 +0000
817@@ -1,38 +1,34 @@
818 package net.tapaal.gui.petrinet.verification;
819
820-import java.awt.Dialog;
821-import java.awt.Dimension;
822-import java.awt.GridBagConstraints;
823-import java.awt.GridBagLayout;
824-import java.awt.Insets;
825-import java.awt.Window;
826-import java.awt.event.ActionEvent;
827-import java.awt.event.ActionListener;
828-import java.awt.event.HierarchyEvent;
829-import java.awt.event.HierarchyListener;
830-import java.io.File;
831-import java.util.Comparator;
832-import java.util.HashMap;
833-import java.util.List;
834-
835-import javax.swing.*;
836-import javax.swing.table.DefaultTableModel;
837-import javax.swing.table.TableModel;
838-import javax.swing.table.TableRowSorter;
839-import pipe.gui.petrinet.PetriNetTab;
840 import dk.aau.cs.Messenger;
841+import dk.aau.cs.TCTL.TCTLAFNode;
842+import dk.aau.cs.TCTL.TCTLAGNode;
843+import dk.aau.cs.TCTL.TCTLEFNode;
844+import dk.aau.cs.TCTL.TCTLEGNode;
845 import dk.aau.cs.model.tapn.TimedArcPetriNet;
846 import dk.aau.cs.model.tapn.simulation.TAPNNetworkTrace;
847 import dk.aau.cs.util.MemoryMonitor;
848 import dk.aau.cs.util.Tuple;
849 import dk.aau.cs.util.VerificationCallback;
850-import dk.aau.cs.verification.IconSelector;
851-import dk.aau.cs.verification.ModelChecker;
852-import dk.aau.cs.verification.QueryResult;
853-import dk.aau.cs.verification.QueryType;
854-import dk.aau.cs.verification.VerificationResult;
855+import dk.aau.cs.verification.*;
856+import net.tapaal.swinghelpers.GridBagHelper;
857+import pipe.gui.TAPAALGUI;
858+import pipe.gui.petrinet.PetriNetTab;
859 import pipe.gui.petrinet.dataLayer.DataLayer;
860-import pipe.gui.TAPAALGUI;
861+
862+import javax.swing.*;
863+import javax.swing.table.DefaultTableModel;
864+import javax.swing.table.TableModel;
865+import javax.swing.table.TableRowSorter;
866+import java.awt.*;
867+import java.awt.event.HierarchyEvent;
868+import java.awt.event.HierarchyListener;
869+import java.io.File;
870+import java.util.Comparator;
871+import java.util.HashMap;
872+import java.util.List;
873+
874+import static net.tapaal.swinghelpers.GridBagHelper.Anchor.WEST;
875
876 public class RunVerification extends RunVerificationBase {
877 private final IconSelector iconSelector;
878@@ -76,10 +72,23 @@
879 JOptionPane.INFORMATION_MESSAGE,
880 iconSelector.getIconFor(result)
881 );
882-
883- if (!reducedNetOpened && result.getTrace() != null) {
884- TAPAALGUI.getAnimator().setTrace(result.getTrace());
885- }
886+
887+ if (options.traceOption() != TAPNQuery.TraceOption.NONE &&
888+ ((query.getProperty() instanceof TCTLEFNode && result.isQuerySatisfied()) ||
889+ (query.getProperty() instanceof TCTLAGNode && !result.isQuerySatisfied()) ||
890+ (query.getProperty() instanceof TCTLEGNode && result.isQuerySatisfied()) ||
891+ (query.getProperty() instanceof TCTLAFNode && !result.isQuerySatisfied()))) {
892+ // We have a trace to show)
893+
894+ if (!reducedNetOpened && result.getTrace() != null) {
895+ TAPAALGUI.getAnimator().setTrace(result.getTrace());
896+ } else {
897+ String message = "A trace exists but could not be generated by the engine.\n\n";
898+ messenger.displayWrappedErrorMessage(message, "No trace generated");
899+ }
900+ }
901+
902+
903 }
904 } else {
905 //Check if the is something like
906@@ -121,19 +130,16 @@
907 "<html>" + string.replace(System.getProperty("line.separator"), "<br/>") + "</html>";
908 }
909
910- private void displayStats(JPanel panel, String stats, String[] explanations){
911+ private int displayStats(JPanel panel, String stats, String[] explanations, int startOffset){
912 String[] statsStrings = stats.split(System.getProperty("line.separator"));
913+
914 for (int i = 0; i < statsStrings.length; i++) {
915- GridBagConstraints gbc = new GridBagConstraints();
916- gbc.gridx = 0;
917- gbc.gridy = i+1;
918- gbc.insets = new Insets(0,0,0,0);
919- gbc.anchor = GridBagConstraints.WEST;
920+ GridBagConstraints gbc = GridBagHelper.as(0, i+startOffset, WEST, new Insets(0,0,0,0));
921 JLabel statLabel = new JLabel(statsStrings[i]);
922 statLabel.setToolTipText(explanations[i]);
923 panel.add(statLabel, gbc);
924 }
925-
926+ return startOffset+statsStrings.length;
927 }
928
929 private JPanel createStatisticsPanel(final VerificationResult<TAPNNetworkTrace> result, boolean transitionPanel) {
930@@ -304,142 +310,121 @@
931
932 // TODO remove this when the engine outputs statistics
933 boolean isCTLQuery = result.getQueryResult().isCTL;
934+ int rowOffset = 1;
935+ if(modelChecker.supportsStats() && !result.isSolvedUsingQuerySimplification() && !isCTLQuery){
936+ rowOffset = displayStats(panel, result.getStatsAsString(), modelChecker.getStatsExplanations(), 1);
937
938- if(modelChecker.supportsStats() && !result.isSolvedUsingStateEquation() && !isCTLQuery){
939- displayStats(panel, result.getStatsAsString(), modelChecker.getStatsExplanations());
940 if(!result.getTransitionStatistics().isEmpty()) {
941 if (!result.getTransitionStatistics().isEmpty()) {
942 JButton transitionStatsButton = new JButton("Transition Statistics");
943 transitionStatsButton.addActionListener(arg0 -> JOptionPane.showMessageDialog(panel, createStatisticsPanel(result, true), "Transition Statistics", JOptionPane.INFORMATION_MESSAGE));
944- gbc = new GridBagConstraints();
945- gbc.gridx = 0;
946- gbc.gridy = 4;
947- gbc.insets = new Insets(10, 0, 10, 0);
948- gbc.anchor = GridBagConstraints.WEST;
949+ gbc = GridBagHelper.as(0,4, WEST, new Insets(10, 0, 10, 0));
950 panel.add(transitionStatsButton, gbc);
951 }
952 if (!result.getPlaceBoundStatistics().isEmpty()) {
953 JButton placeStatsButton = new JButton("Place-Bound Statistics");
954 placeStatsButton.addActionListener(arg0 -> JOptionPane.showMessageDialog(panel, createStatisticsPanel(result, false), "Place-Bound Statistics", JOptionPane.INFORMATION_MESSAGE));
955- gbc = new GridBagConstraints();
956- gbc.gridx = 1;
957- gbc.gridy = 4;
958- gbc.insets = new Insets(10, 0, 10, 0);
959- gbc.anchor = GridBagConstraints.WEST;
960+ gbc = GridBagHelper.as(1,4, WEST, new Insets(10, 0, 10, 0));
961 panel.add(placeStatsButton, gbc);
962 }
963 }
964 if(!result.getReductionResultAsString().isEmpty()){
965- JLabel reductionStatsLabel = new JLabel(toHTML(result.getReductionResultAsString()));
966- gbc = new GridBagConstraints();
967- gbc.gridx = 0;
968- gbc.gridy = 6;
969- gbc.insets = new Insets(0,0,20,-90);
970- gbc.anchor = GridBagConstraints.WEST;
971
972+ JLabel reductionStatsLabel = new JLabel(toHTML(result.getReductionResultAsString()));
973+ gbc = GridBagHelper.as(0,6, WEST, new Insets(0,0,20,-90));
974 panel.add(reductionStatsLabel, gbc);
975
976 if(result.reductionRulesApplied()){
977 JButton openReducedButton = new JButton("Open reduced net");
978- openReducedButton.addActionListener(new ActionListener() {
979- public void actionPerformed(ActionEvent e) {
980- openReducedButton.setEnabled(false);
981- reducedNetOpened = true;
982-
983- File reducedNetFile = new File(reducedNetFilePath);
984-
985- if(reducedNetFile.exists() && reducedNetFile.isFile() && reducedNetFile.canRead()){
986- try {
987- PetriNetTab reducedNetTab = PetriNetTab.createNewTabFromPNMLFile(reducedNetFile);
988- //Ensure that a net was created by the query reduction
989- if(reducedNetTab.currentTemplate().guiModel().getPlaces().length > 0
990- || reducedNetTab.currentTemplate().guiModel().getTransitions().length > 0){
991- reducedNetTab.setInitialName("reduced-" + TAPAALGUI.getAppGui().getCurrentTabName());
992- TAPNQuery convertedQuery = dataLayerQuery.convertPropertyForReducedNet(reducedNetTab.currentTemplate().toString());
993- reducedNetTab.addQuery(convertedQuery);
994- TAPAALGUI.openNewTabFromStream(reducedNetTab);
995- }
996- } catch (Exception e1){
997- JOptionPane.showMessageDialog(TAPAALGUI.getApp(),
998- e1.getMessage(),
999- "Error loading reduced net file",
1000- JOptionPane.ERROR_MESSAGE);
1001+ openReducedButton.addActionListener(e -> {
1002+ openReducedButton.setEnabled(false);
1003+ reducedNetOpened = true;
1004+
1005+ File reducedNetFile = new File(reducedNetFilePath);
1006+
1007+ if(reducedNetFile.exists() && reducedNetFile.isFile() && reducedNetFile.canRead()){
1008+ try {
1009+ PetriNetTab reducedNetTab = PetriNetTab.createNewTabFromPNMLFile(reducedNetFile);
1010+ //Ensure that a net was created by the query reduction
1011+ if(reducedNetTab.currentTemplate().guiModel().getPlaces().length > 0
1012+ || reducedNetTab.currentTemplate().guiModel().getTransitions().length > 0){
1013+ reducedNetTab.setInitialName("reduced-" + TAPAALGUI.getAppGui().getCurrentTabName());
1014+ TAPNQuery convertedQuery = dataLayerQuery.convertPropertyForReducedNet(reducedNetTab.currentTemplate().toString());
1015+ reducedNetTab.addQuery(convertedQuery);
1016+ TAPAALGUI.openNewTabFromStream(reducedNetTab);
1017 }
1018+ } catch (Exception e1){
1019+ JOptionPane.showMessageDialog(TAPAALGUI.getApp(),
1020+ e1.getMessage(),
1021+ "Error loading reduced net file",
1022+ JOptionPane.ERROR_MESSAGE);
1023 }
1024 }
1025 });
1026
1027- gbc = new GridBagConstraints();
1028- gbc.gridx = 0;
1029- gbc.gridy = 5;
1030- gbc.insets = new Insets(0,0,10,0);
1031- gbc.anchor = GridBagConstraints.WEST;
1032+ gbc = GridBagHelper.as(0,5, WEST, new Insets(0,0,10,0));
1033 panel.add(openReducedButton, gbc);
1034 }
1035 if (!result.getPlaceBoundStatistics().isEmpty()) {
1036 JButton placeStatsButton = new JButton("Place-Bound Statistics");
1037 placeStatsButton.addActionListener(arg0 -> JOptionPane.showMessageDialog(panel, createStatisticsPanel(result, false), "Place-Bound Statistics", JOptionPane.INFORMATION_MESSAGE));
1038- gbc = new GridBagConstraints();
1039- gbc.gridx = 1;
1040- gbc.gridy = 4;
1041- gbc.insets = new Insets(10, 0, 10, 0);
1042- gbc.anchor = GridBagConstraints.WEST;
1043+
1044+ gbc = GridBagHelper.as(1,4, WEST, new Insets(10, 0, 10, 0));
1045 panel.add(placeStatsButton, gbc);
1046 }
1047 }
1048-
1049- if (result.getRawOutput() != null) {
1050- JButton showRawQueryButton = new JButton("Show raw query results");
1051- showRawQueryButton.addActionListener(arg0 -> JOptionPane.showMessageDialog(panel, createRawQueryPanel(result.getRawOutput()), "Raw query results", JOptionPane.INFORMATION_MESSAGE));
1052- gbc = new GridBagConstraints();
1053- gbc.gridx = 1;
1054- gbc.gridy = 5;
1055- gbc.insets = new Insets(0,0,10,0);
1056- gbc.anchor = GridBagConstraints.WEST;
1057- panel.add(showRawQueryButton, gbc);
1058- }
1059- } else if (modelChecker.supportsStats() && !result.isSolvedUsingStateEquation() && isCTLQuery){
1060- displayStats(panel, result.getCTLStatsAsString(), modelChecker.getStatsExplanations());
1061-
1062- }
1063-
1064- if(result.isSolvedUsingStateEquation()){
1065- gbc = new GridBagConstraints();
1066- gbc.gridx = 0;
1067- gbc.gridy = 6;
1068- gbc.insets = new Insets(0,0,15,0);
1069- gbc.anchor = GridBagConstraints.WEST;
1070- panel.add(new JLabel(toHTML("The query was resolved using state equations.")), gbc);
1071- }
1072+ rowOffset = 6;
1073+
1074+ } else if (modelChecker.supportsStats() && !result.isSolvedUsingQuerySimplification() && isCTLQuery){
1075+ rowOffset = displayStats(panel, result.getCTLStatsAsString(), modelChecker.getStatsExplanations(), 1);
1076+ }
1077+
1078+ if (result.getRawOutput() != null) {
1079+ JButton showRawQueryButton = new JButton("Show raw query results");
1080+ showRawQueryButton.addActionListener(arg0 -> JOptionPane.showMessageDialog(panel, createRawQueryPanel(result.getRawOutput()), "Raw query results", JOptionPane.INFORMATION_MESSAGE));
1081+ gbc = GridBagHelper.as(1, 5, WEST, new Insets(0,0,10,0));
1082+ panel.add(showRawQueryButton, gbc);
1083+ }
1084+
1085+ if (result.isResolvedUsingSkeletonPreprocessor()) {
1086+ gbc = GridBagHelper.as(0, rowOffset+1, GridBagHelper.Anchor.WEST, new Insets(0,0,15,0));
1087+ gbc.gridwidth = 2;
1088+ panel.add(new JLabel(toHTML("The query was resolved using Skeleton Analysis preprocessing")), gbc);
1089+ }
1090+
1091+
1092+ gbc = GridBagHelper.as(0, rowOffset+2, WEST, new Insets(0,0,15,0));
1093+ gbc.gridwidth = 2;
1094+ if(result.isSolvedUsingQuerySimplification()){
1095+ panel.add(new JLabel(toHTML("The query was resolved using Query Simplification.")), gbc);
1096+ } else if (result.isSolvedUsingTraceAbstractRefinement()){
1097+ panel.add(new JLabel(toHTML("The query was not resolved using Trace Abstraction Refinement.")), gbc);
1098+ } else if (result.isSolvedUsingStateEquation()) {
1099+ panel.add(new JLabel(toHTML("The query was resolved using state equations.")), gbc);
1100+ } else if (result.isSolvedUsingSiphonTrap()) {
1101+ panel.add(new JLabel(toHTML("The query was resolved using Siphon Trap.")), gbc);
1102+ }
1103
1104- gbc = new GridBagConstraints();
1105- gbc.gridx = 0;
1106- gbc.gridy = 7;
1107- gbc.gridwidth = 2;
1108- gbc.anchor = GridBagConstraints.WEST;
1109+ gbc = GridBagHelper.as(0, rowOffset+3, WEST);
1110+ gbc.gridwidth = 2;
1111 panel.add(new JLabel(result.getVerificationTimeString()), gbc);
1112-
1113- gbc = new GridBagConstraints();
1114- gbc.gridx = 0;
1115- gbc.gridy = 8;
1116- gbc.gridwidth = 2;
1117- gbc.anchor = GridBagConstraints.WEST;
1118+
1119+ gbc = GridBagHelper.as(0, rowOffset+4, WEST);
1120+ gbc.gridwidth = 2;
1121 panel.add(new JLabel("Estimated memory usage: "+MemoryMonitor.getPeakMemory()), gbc);
1122
1123 //Show discrete semantics warning if needed
1124 QueryResult queryResult = result.getQueryResult();
1125- if(((queryResult.hasDeadlock() && queryResult.queryType() == QueryType.EF && !queryResult.isQuerySatisfied()) ||
1126- (queryResult.hasDeadlock() && queryResult.queryType() == QueryType.AG && queryResult.isQuerySatisfied()) ||
1127- (queryResult.queryType() == QueryType.EG && !queryResult.isQuerySatisfied()) ||
1128- (queryResult.queryType() == QueryType.AF && queryResult.isQuerySatisfied()))
1129- && modelChecker.useDiscreteSemantics()){
1130- gbc = new GridBagConstraints();
1131- gbc.gridx = 0;
1132- gbc.gridy = 11;
1133- gbc.gridwidth = 2;
1134- gbc.anchor = GridBagConstraints.WEST;
1135- panel.add(new JLabel("<html><font color=red>The verification answer is guaranteed for<br/>the discrete semantics only (integer delays).</font></html>"), gbc);
1136- }
1137+ if (((queryResult.hasDeadlock() && queryResult.queryType() == QueryType.EF && !queryResult.isQuerySatisfied()) ||
1138+ (queryResult.hasDeadlock() && queryResult.queryType() == QueryType.AG && queryResult.isQuerySatisfied()) ||
1139+ (queryResult.queryType() == QueryType.EG && !queryResult.isQuerySatisfied()) ||
1140+ (queryResult.queryType() == QueryType.AF && queryResult.isQuerySatisfied()))
1141+ && modelChecker.useDiscreteSemantics()) {
1142+
1143+ gbc = GridBagHelper.as(0, rowOffset+7, WEST);
1144+ gbc.gridwidth = 2;
1145+ panel.add(new JLabel("<html><font color=red>The verification answer is guaranteed for<br/>the discrete semantics only (integer delays).</font></html>"), gbc);
1146+ }
1147
1148 return panel;
1149 }
1150
1151=== modified file 'src/net/tapaal/gui/petrinet/verification/RunVerificationBase.java'
1152--- src/net/tapaal/gui/petrinet/verification/RunVerificationBase.java 2022-01-28 13:29:38 +0000
1153+++ src/net/tapaal/gui/petrinet/verification/RunVerificationBase.java 2022-02-07 08:12:13 +0000
1154@@ -107,9 +107,9 @@
1155 if (!verifypn.setup()) {
1156 messenger.displayInfoMessage("Over-approximation check is skipped because VerifyPN is not available.", "VerifyPN unavailable");
1157 } else {
1158- VerificationResult<TimedArcPetriNetTrace> overapprox_result = null;
1159+ VerificationResult<TimedArcPetriNetTrace> skeletonAnalysisResult = null;
1160 if (dataLayerQuery != null) {
1161- overapprox_result = verifypn.verify(
1162+ skeletonAnalysisResult = verifypn.verify(
1163 new VerifyPNOptions(
1164 options.extraTokens(),
1165 net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption.NONE,
1166@@ -139,7 +139,7 @@
1167 dataLayerQuery,
1168 null);
1169 } else { // TODO: FIX! If datalayer is null then we can't check datalayer's values...
1170- overapprox_result = verifypn.verify(
1171+ skeletonAnalysisResult = verifypn.verify(
1172 new VerifyPNOptions(
1173 options.extraTokens(),
1174 net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption.NONE,
1175@@ -170,18 +170,19 @@
1176 null);
1177 }
1178
1179- if (overapprox_result.getQueryResult() != null) {
1180- if (!overapprox_result.error() && model.isUntimed() || (
1181- (query.queryType() == QueryType.EF && !overapprox_result.getQueryResult().isQuerySatisfied()) ||
1182- (query.queryType() == QueryType.AG && overapprox_result.getQueryResult().isQuerySatisfied()))
1183+ if (skeletonAnalysisResult.getQueryResult() != null) {
1184+ if (!skeletonAnalysisResult.error() && model.isUntimed() || (
1185+ (query.queryType() == QueryType.EF && !skeletonAnalysisResult.getQueryResult().isQuerySatisfied()) ||
1186+ (query.queryType() == QueryType.AG && skeletonAnalysisResult.getQueryResult().isQuerySatisfied()))
1187 ) {
1188 VerificationResult<TAPNNetworkTrace> value = new VerificationResult<TAPNNetworkTrace>(
1189- overapprox_result.getQueryResult(),
1190- decomposeTrace(overapprox_result.getTrace(), transformedModel.value2()),
1191- overapprox_result.verificationTime(),
1192- overapprox_result.stats(),
1193- true
1194+ skeletonAnalysisResult.getQueryResult(),
1195+ decomposeTrace(skeletonAnalysisResult.getTrace(), transformedModel.value2()),
1196+ skeletonAnalysisResult.verificationTime(),
1197+ skeletonAnalysisResult.stats(),
1198+ skeletonAnalysisResult.getRawOutput()
1199 );
1200+ value.setResolvedUsingSkeletonAnalysisPreprocessor(true);
1201 value.setNameMapping(transformedModel.value2());
1202 return value;
1203 }
1204
1205=== modified file 'src/net/tapaal/gui/petrinet/verification/Verifier.java'
1206--- src/net/tapaal/gui/petrinet/verification/Verifier.java 2022-01-28 13:29:38 +0000
1207+++ src/net/tapaal/gui/petrinet/verification/Verifier.java 2022-02-07 08:12:13 +0000
1208@@ -240,7 +240,9 @@
1209 query.inclusionPlaces(),
1210 query.isOverApproximationEnabled(),
1211 query.isUnderApproximationEnabled(),
1212- query.approximationDenominator()
1213+ query.approximationDenominator(),
1214+ false,
1215+ isColored
1216 );
1217 }
1218
1219
1220=== modified file 'src/net/tapaal/gui/petrinet/verification/VerifyTAPNEngineOptions.java'
1221--- src/net/tapaal/gui/petrinet/verification/VerifyTAPNEngineOptions.java 2022-01-07 16:58:59 +0000
1222+++ src/net/tapaal/gui/petrinet/verification/VerifyTAPNEngineOptions.java 2022-02-07 08:12:13 +0000
1223@@ -19,7 +19,7 @@
1224 false, //support games
1225 false, //support EG or AF with net degree > 2
1226 false, //support for nested quantification
1227- false
1228+ true
1229 );
1230 }
1231 }

Subscribers

People subscribed via source and target branches

to all changes: