Merge lp:~tapaal-contributor/tapaal/LTL-dialog into lp:tapaal

Proposed by Lena Ernstsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1198
Merged at revision: 1153
Proposed branch: lp:~tapaal-contributor/tapaal/LTL-dialog
Merge into: lp:tapaal
Diff against target: 4473 lines (+2964/-278)
42 files modified
build.gradle (+7/-1)
src/dk/aau/cs/TCTL/CTLParsing/TAPAALCTLQueryParser.jj (+9/-11)
src/dk/aau/cs/TCTL/LTLANode.java (+107/-0)
src/dk/aau/cs/TCTL/LTLENode.java (+107/-0)
src/dk/aau/cs/TCTL/LTLFNode.java (+107/-0)
src/dk/aau/cs/TCTL/LTLGNode.java (+106/-0)
src/dk/aau/cs/TCTL/LTLParsing/TAPAALLTLQueryParser.jj (+294/-0)
src/dk/aau/cs/TCTL/LTLUNode.java (+137/-0)
src/dk/aau/cs/TCTL/LTLXNode.java (+107/-0)
src/dk/aau/cs/TCTL/TCTLAGNode.java (+6/-6)
src/dk/aau/cs/TCTL/TCTLAbstractProperty.java (+2/-1)
src/dk/aau/cs/TCTL/XMLParsing/XMLLTLQueryParser.java (+526/-0)
src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java (+30/-0)
src/dk/aau/cs/TCTL/visitors/ITCTLVisitor.java (+13/-25)
src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java (+233/-0)
src/dk/aau/cs/TCTL/visitors/VisitorBase.java (+10/-28)
src/dk/aau/cs/gui/BatchProcessingDialog.java (+4/-0)
src/dk/aau/cs/gui/TabContent.java (+24/-19)
src/dk/aau/cs/gui/components/TransitionFiringComponent.java (+169/-0)
src/dk/aau/cs/io/TapnXmlLoader.java (+4/-2)
src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java (+47/-4)
src/dk/aau/cs/io/queries/QueryLoader.java (+1/-0)
src/dk/aau/cs/io/queries/TAPNQueryLoader.java (+72/-57)
src/dk/aau/cs/io/queries/XMLQueryLoader.java (+99/-7)
src/dk/aau/cs/verification/ReductionStats.java (+1/-1)
src/dk/aau/cs/verification/VerificationResult.java (+1/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java (+12/-4)
src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOptions.java (+12/-4)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java (+6/-1)
src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java (+2/-2)
src/dk/aau/cs/verification/batchProcessing/BatchProcessingWorker.java (+4/-2)
src/pipe/dataLayer/TAPNQuery.java (+11/-2)
src/pipe/gui/AnimationSettingsDialog.java (+1/-1)
src/pipe/gui/Animator.java (+23/-16)
src/pipe/gui/Export.java (+18/-7)
src/pipe/gui/KBoundAnalyzer.java (+1/-1)
src/pipe/gui/RunVerification.java (+13/-4)
src/pipe/gui/RunVerificationBase.java (+5/-3)
src/pipe/gui/SimulationControl.java (+3/-3)
src/pipe/gui/Verifier.java (+18/-38)
src/pipe/gui/graphicElements/Transition.java (+1/-1)
src/pipe/gui/widgets/QueryDialog.java (+611/-26)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/LTL-dialog
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Kenneth Yrke Jørgensen code Approve
Review via email: mp+406855@code.launchpad.net

This proposal supersedes a proposal from 2021-08-04.

Commit message

Added ability to make LTL queries

Description of the change

LTL query are available when the net is untimed and no game. It can be accessed by changing the query category through a drop down menu at the top of the query dialog.
It is possible to convert a CTL dialog to an LTL dialog and vice versa.

When the ltl category is chosen 'A' will always be in the beginning of the query property, and it should not be possible to delete it.

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

Three comments:

1. If the Tarjan is selected (please spell it with capital letter), the switch should be -ltl
   but if it is not selected, it should be -ltl ndfs so that it does not call Tarjan.

2. Please, rename the mouseover tooltips to "Globally" for G, "Next" for X, "Eventually" for F, and "Until" for U.

3. The supported search strategies are Heuristic, DFS and Random Search. Please, allow to choose between all three of them, the Heuristic should be the default option.

review: Needs Fixing
Revision history for this message
Jiri Srba (srba) wrote : Posted in a previous version of this proposal

Conversion between CTL and LTL does not work. Make a simple LTL formula like F true and then change it to CTL (in dropdown menu). The formula still says F but this is not a valid CTL formula (this one has to have EF or AF - I would suggest by default to convert all operators to universal ones A - also for Until and neXt and G).

review: Needs Fixing
Revision history for this message
Jiri Srba (srba) wrote : Posted in a previous version of this proposal

Also, manual parsing of LTL queries does not work. Write e.g. manually

true U true

and after parsing it only picks it up as

true.

review: Needs Fixing
1157. By Lena Ernstsen

Added the 'A' node file

1158. By Lena Ernstsen

Fixed incorrect ltl parser

1159. By Lena Ernstsen

Merged lp:tapaal

1160. By Kenneth Yrke Jørgensen

Updated Gradle to run javacc on compile

Updated gradle to run javacc on compile and removed old generated file from source tree.
This makes sure that manual changes does happen to generated files and forces changes to be done in the *.jj files.

1161. By Kenneth Yrke Jørgensen

Merged with upstream

1162. By Lena Ernstsen

Not possible to parse deadlock in manual edit of ltl query

1163. By Lena Ernstsen

Not possible to negate ltl selection if it starts with 'A'

1164. By Lena Ernstsen

deadlock button is not visible in ltl query

1165. By Lena Ernstsen

Fixes to using 'A' quantifier correctly

1166. By Lena Ernstsen

Fixed changing category for a negation query

1167. By Lena Ernstsen

Conversion between ltl and ctl should work correctly

1168. By Lena Ernstsen

When importing xml queries, we attempt to detect the category

1169. By Lena Ernstsen

Fixed wrong parsing of ltl imported queries and possible to choose all imported queries as one category

1170. By Lena Ernstsen

Fixed ltl/ctl import logic

1171. By Lena Ernstsen

Added additional checks to query category for pnml import

1172. By Lena Ernstsen

Added category checks when opening tapn files

1173. By Lena Ernstsen

Merged lp:tapaal

1174. By Lena Ernstsen

Fixed stackoverflow when parsing xml queries

1175. By Lena Ernstsen

Made null-pointer check and changed message

1176. By <email address hidden>

merged trunk to branch

1177. By Lena Ernstsen

Fixed run issues

1178. By Lena Ernstsen

Merged trunk

Revision history for this message
Kenneth Yrke Jørgensen (yrke) :
review: Approve (code)
Revision history for this message
Jiri Srba (srba) wrote :

If you verify an LTL query and ask to open the reduced net (in the query answer dialog), it will fail. See this bug report:

https://bugs.launchpad.net/tapaal/+bug/1945318

review: Needs Fixing
Revision history for this message
Jiri Srba (srba) wrote :

Another problem with saving LTL options in .tapn is reported here:

https://bugs.launchpad.net/tapaal/+bug/1945320

review: Needs Fixing
1179. By Lena Ernstsen

Fixed tarjan not being loaded from file

1180. By Kenneth Yrke Jørgensen

Synced with main

1181. By Jiri Srba <email address hidden>

merged in trunk

1182. By Jiri Srba

merged with trunk

1183. By Lena Ernstsen

--write-reduced is not ignored with ltl anymore

1184. By Lena Ernstsen

Fixed problem with ! and AU when manually parsing

1185. By Jiri Srba

merged with trunk

1186. By Lena Ernstsen

Added 'E' to the ltl dialog

1187. By Lena Ernstsen

Added ltl files

1188. By Jiri Srba

merged with trunk

1189. By Lena Ernstsen

'Open reduced net' uses the same options when called from query dialog and verification dialog

1190. By Lena Ernstsen

Added missing 'exists-path' in xml parser

1191. By Lena Ernstsen

Changed the ltl button functionality

1192. By Lena Ernstsen

Changed when ltl buttons are enabled. DeleteSelection does not automatically add A node to query when ltl

1193. By Lena Ernstsen

Added error message when trace failed to open

1194. By Lena Ernstsen

Corrected spelling mistakes

1195. By Lena Ernstsen

Updated enabledness of ltl buttons

1196. By Lena Ernstsen

updated addPredicate button for ltl queries

1197. By <email address hidden>

merged with trunk

1198. By <email address hidden>

merged with trunk

Revision history for this message
Jiri Srba (srba) wrote :

Tested and works, merging 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 'build.gradle'
2--- build.gradle 2020-07-20 11:56:08 +0000
3+++ build.gradle 2021-10-17 18:45:24 +0000
4@@ -2,6 +2,7 @@
5 id 'java'
6 id 'application'
7 id 'org.jetbrains.kotlin.jvm' version '1.3.71'
8+ id "ca.coglinc.javacc" version "2.4.0"
9 }
10
11 group 'net.tapaal'
12@@ -16,11 +17,16 @@
13 mavenCentral()
14 }
15
16+compileJavacc {
17+ inputDirectory = file('src/')
18+ //outputDirectory = file(project.buildDir.absolutePath + '/generated/javacc')
19+}
20+
21 //Set the soruce and resource dir
22 sourceSets {
23 main {
24 java {
25- srcDirs = ['src/']
26+ srcDirs = ['src/', compileJavacc.outputDirectory]
27 exclude("resources/")
28 }
29 resources {
30
31=== removed file 'src/dk/aau/cs/TCTL/CTLParsing/ParseException.java'
32=== removed file 'src/dk/aau/cs/TCTL/CTLParsing/SimpleCharStream.java'
33=== removed file 'src/dk/aau/cs/TCTL/CTLParsing/TAPAALCTLQueryParser.java'
34=== renamed file 'src/resources/TCTLParser/TAPAALCTLQueryParser.jj' => 'src/dk/aau/cs/TCTL/CTLParsing/TAPAALCTLQueryParser.jj'
35--- src/resources/TCTLParser/TAPAALCTLQueryParser.jj 2021-09-14 20:13:01 +0000
36+++ src/dk/aau/cs/TCTL/CTLParsing/TAPAALCTLQueryParser.jj 2021-10-17 18:45:24 +0000
37@@ -147,17 +147,15 @@
38 TCTLAbstractStateProperty child2 = null;
39 }
40 {
41- (
42- <EF> child = OrExpr() {return new TCTLEFNode(child); }
43- | <EG> child = OrExpr() {return new TCTLEGNode(child); }
44- | <EX> child = OrExpr() {return new TCTLEXNode(child); }
45- | <E> "(" child = OrExpr() <U> child2 = OrExpr() ")" {return new TCTLEUNode(child, child2); }
46- | <AF> child = OrExpr() {return new TCTLAFNode(child); }
47- | <AG> child = OrExpr() {return new TCTLAGNode(child); }
48- | <A> "(" child = OrExpr() <U> child2 = OrExpr() ")" {return new TCTLAUNode(child, child2); }
49- | <AX> child = OrExpr() {return new TCTLAXNode(child); }
50- | child = OrExpr() { return new TCTLStateToPathConverter(child); }
51- )
52+ <EF> child = OrExpr() {return new TCTLEFNode(child); }
53+ | <EG> child = OrExpr() {return new TCTLEGNode(child); }
54+ | <EX> child = OrExpr() {return new TCTLEXNode(child); }
55+ | <E> "(" child = OrExpr() <U> child2 = OrExpr() ")" {return new TCTLEUNode(child, child2); }
56+ | <AF> child = OrExpr() {return new TCTLAFNode(child); }
57+ | <AG> child = OrExpr() {return new TCTLAGNode(child); }
58+ | <A> "(" child = OrExpr() <U> child2 = OrExpr() ")" {return new TCTLAUNode(child, child2); }
59+ | <AX> child = OrExpr() {return new TCTLAXNode(child); }
60+ | child = OrExpr() { return new TCTLStateToPathConverter(child); }
61 }
62
63 TCTLAbstractStateProperty OrExpr() :
64
65=== removed file 'src/dk/aau/cs/TCTL/CTLParsing/TAPAALCTLQueryParserConstants.java'
66=== removed file 'src/dk/aau/cs/TCTL/CTLParsing/TAPAALCTLQueryParserTokenManager.java'
67=== removed file 'src/dk/aau/cs/TCTL/CTLParsing/Token.java'
68=== removed file 'src/dk/aau/cs/TCTL/CTLParsing/TokenMgrError.java'
69=== added file 'src/dk/aau/cs/TCTL/LTLANode.java'
70--- src/dk/aau/cs/TCTL/LTLANode.java 1970-01-01 00:00:00 +0000
71+++ src/dk/aau/cs/TCTL/LTLANode.java 2021-10-17 18:45:24 +0000
72@@ -0,0 +1,107 @@
73+package dk.aau.cs.TCTL;
74+
75+import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
76+
77+public class LTLANode extends TCTLAbstractPathProperty {
78+ TCTLAbstractStateProperty property;
79+
80+ public void setProperty(TCTLAbstractStateProperty property) {
81+ this.property = property;
82+ this.property.setParent(this);
83+ }
84+
85+ public TCTLAbstractStateProperty getProperty() {
86+ return property;
87+ }
88+
89+ public LTLANode(TCTLAbstractStateProperty property) {
90+ this.property = property;
91+ this.property.setParent(this);
92+ }
93+
94+ public LTLANode() {
95+ this.property = new TCTLStatePlaceHolder();
96+ this.property.setParent(this);
97+ }
98+
99+ @Override
100+ public String toString() {
101+ String s = property.isSimpleProperty() ? property.toString() : "("
102+ + property.toString() + ")";
103+ return "A " + s;
104+ }
105+
106+ @Override
107+ public boolean isSimpleProperty() {
108+ return false;
109+ }
110+
111+ @Override
112+ public StringPosition[] getChildren() {
113+ int start = property.isSimpleProperty() ? 0 : 1;
114+ start = start + 2;
115+ int end = start + property.toString().length();
116+ StringPosition position = new StringPosition(start, end, property);
117+
118+ StringPosition[] children = { position };
119+ return children;
120+ }
121+
122+ @Override
123+ public TCTLAbstractPathProperty replace(TCTLAbstractProperty object1,
124+ TCTLAbstractProperty object2) {
125+ if (this == object1 && object2 instanceof TCTLAbstractPathProperty) {
126+ return (TCTLAbstractPathProperty) object2;
127+ } else {
128+ property = property.replace(object1, object2);
129+ return this;
130+ }
131+ }
132+
133+ @Override
134+ public boolean containsPlaceHolder() {
135+ return property.containsPlaceHolder();
136+ }
137+
138+ @Override
139+ public void convertForReducedNet(String templateName) {
140+ property.convertForReducedNet(templateName);
141+ }
142+
143+ @Override
144+ public boolean equals(Object o) {
145+ if (o instanceof LTLANode) {
146+ LTLANode node = (LTLANode) o;
147+ return property.equals(node.getProperty());
148+ }
149+ return false;
150+ }
151+
152+ @Override
153+ public TCTLAbstractPathProperty copy() {
154+ return new LTLANode(property.copy());
155+ }
156+
157+ @Override
158+ public boolean hasNestedPathQuantifiers() {
159+ return property instanceof TCTLPathToStateConverter || property.hasNestedPathQuantifiers();
160+ }
161+
162+ public boolean containsAtomicPropositionWithSpecificPlaceInTemplate(String templateName, String placeName) {
163+ return property.containsAtomicPropositionWithSpecificPlaceInTemplate(templateName, placeName);
164+ }
165+
166+ public boolean containsAtomicPropositionWithSpecificTransitionInTemplate(String templateName, String transitionName) {
167+ return property.containsAtomicPropositionWithSpecificTransitionInTemplate(templateName, transitionName);
168+ }
169+
170+ @Override
171+ public TCTLAbstractProperty findFirstPlaceHolder() {
172+ return property.findFirstPlaceHolder();
173+ }
174+
175+ @Override
176+ public void accept(ITCTLVisitor visitor, Object context) {
177+ visitor.visit(this, context);
178+ }
179+}
180
181=== added file 'src/dk/aau/cs/TCTL/LTLENode.java'
182--- src/dk/aau/cs/TCTL/LTLENode.java 1970-01-01 00:00:00 +0000
183+++ src/dk/aau/cs/TCTL/LTLENode.java 2021-10-17 18:45:24 +0000
184@@ -0,0 +1,107 @@
185+package dk.aau.cs.TCTL;
186+
187+import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
188+
189+public class LTLENode extends TCTLAbstractPathProperty {
190+ TCTLAbstractStateProperty property;
191+
192+ public void setProperty(TCTLAbstractStateProperty property) {
193+ this.property = property;
194+ this.property.setParent(this);
195+ }
196+
197+ public TCTLAbstractStateProperty getProperty() {
198+ return property;
199+ }
200+
201+ public LTLENode(TCTLAbstractStateProperty property) {
202+ this.property = property;
203+ this.property.setParent(this);
204+ }
205+
206+ public LTLENode() {
207+ this.property = new TCTLStatePlaceHolder();
208+ this.property.setParent(this);
209+ }
210+
211+ @Override
212+ public String toString() {
213+ String s = property.isSimpleProperty() ? property.toString() : "("
214+ + property.toString() + ")";
215+ return "E " + s;
216+ }
217+
218+ @Override
219+ public boolean isSimpleProperty() {
220+ return false;
221+ }
222+
223+ @Override
224+ public StringPosition[] getChildren() {
225+ int start = property.isSimpleProperty() ? 0 : 1;
226+ start = start + 2;
227+ int end = start + property.toString().length();
228+ StringPosition position = new StringPosition(start, end, property);
229+
230+ StringPosition[] children = { position };
231+ return children;
232+ }
233+
234+ @Override
235+ public TCTLAbstractPathProperty replace(TCTLAbstractProperty object1,
236+ TCTLAbstractProperty object2) {
237+ if (this == object1 && object2 instanceof TCTLAbstractPathProperty) {
238+ return (TCTLAbstractPathProperty) object2;
239+ } else {
240+ property = property.replace(object1, object2);
241+ return this;
242+ }
243+ }
244+
245+ @Override
246+ public boolean containsPlaceHolder() {
247+ return property.containsPlaceHolder();
248+ }
249+
250+ @Override
251+ public void convertForReducedNet(String templateName) {
252+ property.convertForReducedNet(templateName);
253+ }
254+
255+ @Override
256+ public boolean equals(Object o) {
257+ if (o instanceof LTLENode) {
258+ LTLENode node = (LTLENode) o;
259+ return property.equals(node.getProperty());
260+ }
261+ return false;
262+ }
263+
264+ @Override
265+ public TCTLAbstractPathProperty copy() {
266+ return new LTLENode(property.copy());
267+ }
268+
269+ @Override
270+ public boolean hasNestedPathQuantifiers() {
271+ return property instanceof TCTLPathToStateConverter || property.hasNestedPathQuantifiers();
272+ }
273+
274+ public boolean containsAtomicPropositionWithSpecificPlaceInTemplate(String templateName, String placeName) {
275+ return property.containsAtomicPropositionWithSpecificPlaceInTemplate(templateName, placeName);
276+ }
277+
278+ public boolean containsAtomicPropositionWithSpecificTransitionInTemplate(String templateName, String transitionName) {
279+ return property.containsAtomicPropositionWithSpecificTransitionInTemplate(templateName, transitionName);
280+ }
281+
282+ @Override
283+ public TCTLAbstractProperty findFirstPlaceHolder() {
284+ return property.findFirstPlaceHolder();
285+ }
286+
287+ @Override
288+ public void accept(ITCTLVisitor visitor, Object context) {
289+ visitor.visit(this, context);
290+ }
291+}
292
293=== added file 'src/dk/aau/cs/TCTL/LTLFNode.java'
294--- src/dk/aau/cs/TCTL/LTLFNode.java 1970-01-01 00:00:00 +0000
295+++ src/dk/aau/cs/TCTL/LTLFNode.java 2021-10-17 18:45:24 +0000
296@@ -0,0 +1,107 @@
297+package dk.aau.cs.TCTL;
298+
299+import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
300+
301+public class LTLFNode extends TCTLAbstractPathProperty {
302+ TCTLAbstractStateProperty property;
303+
304+ public void setProperty(TCTLAbstractStateProperty property) {
305+ this.property = property;
306+ this.property.setParent(this);
307+ }
308+
309+ public TCTLAbstractStateProperty getProperty() {
310+ return property;
311+ }
312+
313+ public LTLFNode(TCTLAbstractStateProperty property) {
314+ this.property = property;
315+ this.property.setParent(this);
316+ }
317+
318+ public LTLFNode() {
319+ this.property = new TCTLStatePlaceHolder();
320+ this.property.setParent(this);
321+ }
322+
323+ @Override
324+ public String toString() {
325+ String s = property.isSimpleProperty() ? property.toString() : "("
326+ + property.toString() + ")";
327+ return "F " + s;
328+ }
329+
330+ @Override
331+ public boolean isSimpleProperty() {
332+ return false;
333+ }
334+
335+ @Override
336+ public StringPosition[] getChildren() {
337+ int start = property.isSimpleProperty() ? 0 : 1;
338+ start = start + 2;
339+ int end = start + property.toString().length();
340+ StringPosition position = new StringPosition(start, end, property);
341+
342+ StringPosition[] children = { position };
343+ return children;
344+ }
345+
346+ @Override
347+ public TCTLAbstractPathProperty replace(TCTLAbstractProperty object1,
348+ TCTLAbstractProperty object2) {
349+ if (this == object1 && object2 instanceof TCTLAbstractPathProperty) {
350+ return (TCTLAbstractPathProperty) object2;
351+ } else {
352+ property = property.replace(object1, object2);
353+ return this;
354+ }
355+ }
356+
357+ @Override
358+ public boolean containsPlaceHolder() {
359+ return property.containsPlaceHolder();
360+ }
361+
362+ @Override
363+ public void convertForReducedNet(String templateName) {
364+ property.convertForReducedNet(templateName);
365+ }
366+
367+ @Override
368+ public boolean equals(Object o) {
369+ if (o instanceof LTLFNode) {
370+ LTLFNode node = (LTLFNode) o;
371+ return property.equals(node.getProperty());
372+ }
373+ return false;
374+ }
375+
376+ @Override
377+ public TCTLAbstractPathProperty copy() {
378+ return new LTLFNode(property.copy());
379+ }
380+
381+ @Override
382+ public boolean hasNestedPathQuantifiers() {
383+ return property instanceof TCTLPathToStateConverter || property.hasNestedPathQuantifiers();
384+ }
385+
386+ public boolean containsAtomicPropositionWithSpecificPlaceInTemplate(String templateName, String placeName) {
387+ return property.containsAtomicPropositionWithSpecificPlaceInTemplate(templateName, placeName);
388+ }
389+
390+ public boolean containsAtomicPropositionWithSpecificTransitionInTemplate(String templateName, String transitionName) {
391+ return property.containsAtomicPropositionWithSpecificTransitionInTemplate(templateName, transitionName);
392+ }
393+
394+ @Override
395+ public TCTLAbstractProperty findFirstPlaceHolder() {
396+ return property.findFirstPlaceHolder();
397+ }
398+
399+ @Override
400+ public void accept(ITCTLVisitor visitor, Object context) {
401+ visitor.visit(this, context);
402+ }
403+}
404
405=== added file 'src/dk/aau/cs/TCTL/LTLGNode.java'
406--- src/dk/aau/cs/TCTL/LTLGNode.java 1970-01-01 00:00:00 +0000
407+++ src/dk/aau/cs/TCTL/LTLGNode.java 2021-10-17 18:45:24 +0000
408@@ -0,0 +1,106 @@
409+package dk.aau.cs.TCTL;
410+
411+import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
412+
413+public class LTLGNode extends TCTLAbstractPathProperty {
414+ TCTLAbstractStateProperty property;
415+
416+ public void setProperty(TCTLAbstractStateProperty property) {
417+ this.property = property;
418+ this.property.setParent(this);
419+ }
420+
421+ public TCTLAbstractStateProperty getProperty() {
422+ return property;
423+ }
424+
425+ public LTLGNode(TCTLAbstractStateProperty property) {
426+ this.property = property;
427+ this.property.setParent(this);
428+ }
429+
430+ public LTLGNode() {
431+ this.property = new TCTLStatePlaceHolder();;
432+ this.property.setParent(this);
433+ }
434+
435+ @Override
436+ public String toString() {
437+ String s = property.isSimpleProperty() ? property.toString() : "("
438+ + property.toString() + ")";
439+ return "G " + s;
440+ }
441+
442+ @Override
443+ public StringPosition[] getChildren() {
444+ int start = property.isSimpleProperty() ? 0 : 1;
445+ start = start + 2;
446+ int end = start + property.toString().length();
447+ StringPosition position = new StringPosition(start, end, property);
448+
449+ StringPosition[] children = { position };
450+ return children;
451+ }
452+
453+ @Override
454+ public boolean isSimpleProperty() {
455+ return false;
456+ }
457+
458+ @Override
459+ public void convertForReducedNet(String templateName) {
460+ property.convertForReducedNet(templateName);
461+ }
462+
463+ @Override
464+ public boolean equals(Object o) {
465+ if (o instanceof LTLGNode) {
466+ LTLGNode node = (LTLGNode) o;
467+ return property.equals(node.getProperty());
468+ }
469+ return false;
470+ }
471+
472+ @Override
473+ public TCTLAbstractPathProperty replace(TCTLAbstractProperty object1,
474+ TCTLAbstractProperty object2) {
475+ if (this == object1 && object2 instanceof TCTLAbstractPathProperty) {
476+ return (TCTLAbstractPathProperty) object2;
477+ } else {
478+ property = property.replace(object1, object2);
479+ return this;
480+ }
481+ }
482+
483+ @Override
484+ public TCTLAbstractPathProperty copy() {
485+ return new LTLGNode(property.copy());
486+ }
487+
488+ @Override
489+ public boolean containsPlaceHolder() {
490+ return property.containsPlaceHolder();
491+ }
492+ @Override
493+ public boolean hasNestedPathQuantifiers() {
494+ return property instanceof TCTLPathToStateConverter || property.hasNestedPathQuantifiers();
495+ }
496+
497+ public boolean containsAtomicPropositionWithSpecificPlaceInTemplate(String templateName, String placeName) {
498+ return property.containsAtomicPropositionWithSpecificPlaceInTemplate(templateName, placeName);
499+ }
500+
501+ public boolean containsAtomicPropositionWithSpecificTransitionInTemplate(String templateName, String transitionName) {
502+ return property.containsAtomicPropositionWithSpecificTransitionInTemplate(templateName, transitionName);
503+ }
504+
505+ @Override
506+ public TCTLAbstractProperty findFirstPlaceHolder() {
507+ return property.findFirstPlaceHolder();
508+ }
509+
510+ @Override
511+ public void accept(ITCTLVisitor visitor, Object context) {
512+ visitor.visit(this, context);
513+ }
514+}
515
516=== added directory 'src/dk/aau/cs/TCTL/LTLParsing'
517=== added file 'src/dk/aau/cs/TCTL/LTLParsing/TAPAALLTLQueryParser.jj'
518--- src/dk/aau/cs/TCTL/LTLParsing/TAPAALLTLQueryParser.jj 1970-01-01 00:00:00 +0000
519+++ src/dk/aau/cs/TCTL/LTLParsing/TAPAALLTLQueryParser.jj 2021-10-17 18:45:24 +0000
520@@ -0,0 +1,294 @@
521+options {
522+ LOOKAHEAD = 1;
523+ CHOICE_AMBIGUITY_CHECK = 2;
524+ OTHER_AMBIGUITY_CHECK = 1;
525+ STATIC = false;
526+ DEBUG_PARSER = false;
527+ DEBUG_LOOKAHEAD = false;
528+ DEBUG_TOKEN_MANAGER = false;
529+ ERROR_REPORTING = true;
530+ JAVA_UNICODE_ESCAPE = false;
531+ UNICODE_INPUT = false;
532+ IGNORE_CASE = false;
533+ USER_TOKEN_MANAGER = false;
534+ USER_CHAR_STREAM = false;
535+ BUILD_PARSER = true;
536+ BUILD_TOKEN_MANAGER = true;
537+ SANITY_CHECK = true;
538+ }
539+
540+ PARSER_BEGIN(TAPAALLTLQueryParser)
541+
542+ package dk.aau.cs.TCTL.LTLParsing;
543+
544+import java.io.StringReader;
545+import java.util.ArrayList;
546+
547+import dk.aau.cs.TCTL.*;
548+
549+public class TAPAALLTLQueryParser {
550+
551+ private static final String ERROR_PARSING_QUERY_MESSAGE = "TAPAAL countered an error trying to parse the query";
552+
553+ public static TCTLAbstractPathProperty parse(String query) throws ParseException {
554+ TAPAALLTLQueryParser parser = new TAPAALLTLQueryParser(new StringReader(query));
555+ return parser.Start();
556+ }
557+}
558+
559+ PARSER_END(TAPAALLTLQueryParser)
560+
561+TOKEN :
562+ {
563+<TRUE: "true" | "TRUE">
564+ |
565+<FALSE: "false" | "FALSE">
566+ }
567+
568+ TOKEN :
569+ {
570+<A: "A">
571+ |
572+<E: "E">
573+ |
574+<U: "U">
575+ |
576+<F: "F">
577+ |
578+<G: "G">
579+ |
580+<X: "X">
581+ }
582+
583+ TOKEN :
584+ {
585+<OR: "or" | "||">
586+ |
587+<AND: "and" | "&&">
588+ |
589+<NOT: "not" | "!">
590+ }
591+
592+ TOKEN :
593+ {
594+<PLUS: "+">
595+ |
596+<MINUS: "-">
597+ |
598+<MULT: "*">
599+ }
600+
601+ TOKEN :
602+ {
603+< NUM: ("-")? ( ["0"-"9"] )+ >
604+ |
605+<IDENT: ["a"-"z","A"-"Z","_"] ( ["a"-"z","A"-"Z","_","0"-"9"] )* >
606+ }
607+
608+ TOKEN :
609+ {
610+<OP: "<" | "!=" | "<=" | ">" | "=" | "==" | ">=" | ">" >
611+ }
612+
613+ SKIP :
614+ {
615+ " "
616+ | "\t"
617+ | "\n"
618+ | "\r"
619+ }
620+
621+/** Root production. */
622+TCTLAbstractPathProperty Start() :
623+{
624+ TCTLAbstractPathProperty child = null;
625+}
626+{
627+ child = AbstractPathProperty() <EOF> {return child; }
628+}
629+
630+TCTLAbstractPathProperty AbstractPathProperty() :
631+{
632+ TCTLAbstractPathProperty pathChild = null;
633+ TCTLAbstractStateProperty stateChild = null;
634+}
635+{
636+ <A> pathChild = ParanthesesExpr() {return new LTLANode(new TCTLPathToStateConverter(pathChild)); }
637+ | <E> pathChild = ParanthesesExpr() {return new LTLENode(new TCTLPathToStateConverter(pathChild)); }
638+}
639+
640+TCTLAbstractPathProperty ParanthesesExpr() :
641+{
642+ TCTLAbstractPathProperty pathChild = null;
643+ TCTLAbstractStateProperty stateChild = null;
644+}
645+{
646+ "(" pathChild = QuantifierExpr() ")" {return pathChild;}
647+ | stateChild = OrExpr() {return new TCTLStateToPathConverter(stateChild); }
648+}
649+
650+TCTLAbstractPathProperty QuantifierExpr() :
651+{
652+ TCTLAbstractStateProperty child = null;
653+ TCTLAbstractStateProperty child2 = null;
654+}
655+{
656+ <F> child = OrExpr() {return new LTLFNode(child); }
657+ | <G> child = OrExpr() {return new LTLGNode(child); }
658+ | child = OrExpr() <U> child2 = OrExpr() {return new LTLUNode(child, child2); }
659+ | <X> child = OrExpr() {return new LTLXNode(child); }
660+}
661+
662+TCTLAbstractStateProperty OrExpr() :
663+{
664+ TCTLAbstractStateProperty currentChild;
665+ ArrayList<TCTLAbstractStateProperty> disjunctions = new ArrayList<TCTLAbstractStateProperty>();
666+}
667+{
668+ currentChild = AndExpr()
669+ { disjunctions.add(currentChild); }
670+ (
671+ <OR> currentChild = AndExpr()
672+ { disjunctions.add(currentChild); }
673+ )*
674+ { return disjunctions.size() == 1 ? currentChild : new TCTLOrListNode(disjunctions); }
675+}
676+
677+TCTLAbstractStateProperty AndExpr() :
678+{
679+ TCTLAbstractStateProperty currentChild;
680+ ArrayList<TCTLAbstractStateProperty> conjunctions = new ArrayList<TCTLAbstractStateProperty>();
681+}
682+{
683+ currentChild = NotExpr()
684+ { conjunctions.add(currentChild); }
685+ (
686+ <AND> currentChild = NotExpr()
687+ { conjunctions.add(currentChild); }
688+ )*
689+ { return conjunctions.size() == 1 ? currentChild : new TCTLAndListNode(conjunctions); }
690+}
691+
692+ TCTLAbstractStateProperty NotExpr() :
693+ {
694+ TCTLAbstractStateProperty child;
695+ TCTLAbstractStateProperty child2 = null;
696+ TCTLAbstractPathProperty childConverter;
697+ }
698+ {
699+ <NOT> "(" child = OrExpr() [LOOKAHEAD(2) <U> child2 = OrExpr()] ")" { return new TCTLNotNode(child2 == null ? child : new TCTLPathToStateConverter(new LTLUNode(child, child2))); }
700+ | child = Factor() { return child; }
701+ | "(" childConverter = QuantifierExpr() ")" { return new TCTLPathToStateConverter(childConverter); }
702+ }
703+
704+ TCTLAbstractStateProperty Factor() :
705+ {
706+ TCTLAbstractStateProperty thisProp;
707+ Token temp = null;
708+ Token transition;
709+ }
710+ {
711+ (
712+<TRUE> {thisProp = new TCTLTrueNode(); }
713+ | <FALSE> {thisProp = new TCTLFalseNode(); }
714+ | LOOKAHEAD(AtomicProposition())
715+ thisProp = AtomicProposition()
716+ | [ LOOKAHEAD(2) temp = <IDENT> "." ] transition = <IDENT> {
717+ thisProp = new TCTLTransitionNode(temp == null ? "" : temp.image, transition.image); }
718+ | "(" thisProp = OrExpr() ")"
719+ | LOOKAHEAD(ParanthesesExpr()) {
720+ thisProp = new TCTLPathToStateConverter(QuantifierExpr()); }
721+
722+ )
723+ { return thisProp; }
724+ }
725+
726+ TCTLAbstractStateProperty AtomicProposition() :
727+ {
728+ TCTLAbstractStateProperty left;
729+ TCTLAbstractStateProperty right;
730+ Token op;
731+ }
732+ {
733+ (
734+ left = AritmeticExpr() op = <OP> right = AritmeticExpr()
735+ )
736+ {
737+ return new TCTLAtomicPropositionNode(left, op.image, right);
738+ }
739+ }
740+
741+ TCTLAbstractStateProperty AritmeticExpr() :
742+ {
743+ TCTLAbstractStateProperty currentChild;
744+ ArrayList<TCTLAbstractStateProperty> terms = new ArrayList<TCTLAbstractStateProperty>();
745+ Token op;
746+ }
747+ {
748+ currentChild = AritmeticMinusExpr()
749+ { terms.add(currentChild); }
750+ (
751+ op = <PLUS> currentChild = AritmeticMinusExpr()
752+ {
753+ terms.add(new AritmeticOperator(op.image));
754+ terms.add(currentChild);
755+ }
756+ )*
757+ { return terms.size() == 1 ? currentChild : new TCTLTermListNode(terms); }
758+ }
759+
760+ TCTLAbstractStateProperty AritmeticMinusExpr() :
761+ {
762+ TCTLAbstractStateProperty currentChild;
763+ ArrayList<TCTLAbstractStateProperty> terms = new ArrayList<TCTLAbstractStateProperty>();
764+ Token op;
765+ }
766+ {
767+ currentChild = AritmeticTerm()
768+ { terms.add(currentChild); }
769+ (
770+ op = <MINUS> currentChild = AritmeticTerm()
771+ {
772+ terms.add(new AritmeticOperator(op.image));
773+ terms.add(currentChild);
774+ }
775+ )*
776+ { return terms.size() == 1 ? currentChild : new TCTLTermListNode(terms); }
777+ }
778+
779+ TCTLAbstractStateProperty AritmeticTerm() :
780+ {
781+ TCTLAbstractStateProperty currentChild;
782+ ArrayList<TCTLAbstractStateProperty> factors = new ArrayList<TCTLAbstractStateProperty>();
783+ Token op;
784+ }
785+ {
786+ currentChild = AritmeticFactor()
787+ { factors.add(currentChild); }
788+ (
789+ op = <MULT> currentChild = AritmeticFactor()
790+ {
791+ factors.add(new AritmeticOperator(op.image));
792+ factors.add(currentChild);
793+ }
794+ )*
795+ { return factors.size() == 1 ? currentChild : new TCTLTermListNode(factors); }
796+ }
797+
798+ TCTLAbstractStateProperty AritmeticFactor() :
799+ {
800+ TCTLAbstractStateProperty thisProp;
801+ Token temp = null;
802+ Token place;
803+ Token op;
804+ Token num;
805+ }
806+ {
807+ (
808+ [ LOOKAHEAD(2) temp = <IDENT> "." ] place = <IDENT> { thisProp = new TCTLPlaceNode(temp == null ? "" : temp.image, place.image); }
809+ | num = <NUM> { thisProp = new TCTLConstNode(Integer.parseInt(num.image)); }
810+ | "(" thisProp = AritmeticExpr() ")"
811+ )
812+
813+ { return thisProp; }
814+ }
815
816=== added file 'src/dk/aau/cs/TCTL/LTLUNode.java'
817--- src/dk/aau/cs/TCTL/LTLUNode.java 1970-01-01 00:00:00 +0000
818+++ src/dk/aau/cs/TCTL/LTLUNode.java 2021-10-17 18:45:24 +0000
819@@ -0,0 +1,137 @@
820+package dk.aau.cs.TCTL;
821+
822+import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
823+
824+public class LTLUNode extends TCTLAbstractPathProperty {
825+ private TCTLAbstractStateProperty left;
826+ private TCTLAbstractStateProperty right;
827+
828+ public TCTLAbstractStateProperty getLeft() {
829+ return this.left;
830+ }
831+
832+ public void setLeft(TCTLAbstractStateProperty left) {
833+ this.left = left;
834+ }
835+
836+ public TCTLAbstractStateProperty getRight() {
837+ return this.right;
838+ }
839+
840+ public void setRight(TCTLAbstractStateProperty right) {
841+ this.right = right;
842+ }
843+
844+ public LTLUNode(TCTLAbstractStateProperty left, TCTLAbstractStateProperty right) {
845+ this.left = left;
846+ this.right = right;
847+ this.left.setParent(this);
848+ this.right.setParent(this);
849+ }
850+
851+ public LTLUNode() {
852+ left = new TCTLStatePlaceHolder();
853+ right = new TCTLStatePlaceHolder();
854+ left.setParent(this);
855+ right.setParent(this);
856+ }
857+
858+ @Override
859+ public String toString() {
860+ String leftString = left.isSimpleProperty() ? left.toString() : "("
861+ + left.toString() + ")";
862+ String rightString = right.isSimpleProperty() ? right.toString() : "("
863+ + right.toString() + ")";
864+
865+ return leftString + " U " + rightString;
866+ }
867+
868+ @Override
869+ public StringPosition[] getChildren() {
870+ int leftStart = left.isSimpleProperty() ? 0 : 1;
871+ leftStart += 0;
872+ int leftEnd = leftStart + left.toString().length();
873+ StringPosition leftPos = new StringPosition(leftStart, leftEnd, left);
874+
875+ int rightStart = right.isSimpleProperty() ? 0 : 1;
876+ rightStart += leftEnd + 3 + + (left.isSimpleProperty() ? 0 : 1);
877+ int rightEnd = rightStart + right.toString().length();
878+ StringPosition rightPos = new StringPosition(rightStart, rightEnd, right);
879+
880+ StringPosition[] children = { leftPos, rightPos };
881+ return children;
882+ }
883+
884+ @Override
885+ public TCTLAbstractPathProperty replace(TCTLAbstractProperty object1,
886+ TCTLAbstractProperty object2) {
887+ if (this == object1 && object2 instanceof TCTLAbstractPathProperty) {
888+ return (TCTLAbstractPathProperty) object2;
889+ } else {
890+ left = left.replace(object1, object2);
891+ right = right.replace(object1, object2);
892+ return this;
893+ }
894+ }
895+
896+ @Override
897+ public void convertForReducedNet(String templateName) {
898+ left.convertForReducedNet(templateName);
899+ right.convertForReducedNet(templateName);
900+ }
901+
902+ @Override
903+ public boolean isSimpleProperty() {
904+ return false;
905+ }
906+
907+ @Override
908+ public boolean containsPlaceHolder() {
909+ return left.containsPlaceHolder() || right.containsPlaceHolder();
910+ }
911+
912+ @Override
913+ public boolean equals(Object o) {
914+ if (o instanceof LTLUNode) {
915+ LTLUNode node = (LTLUNode) o;
916+ return this.left.equals(node.getLeft())
917+ && this.right.equals(node.getRight());
918+ }
919+ return false;
920+ }
921+
922+ @Override
923+ public TCTLAbstractPathProperty copy() {
924+ return new LTLUNode(left.copy(), right.copy());
925+ }
926+
927+ @Override
928+ public boolean hasNestedPathQuantifiers() {
929+ return left instanceof TCTLPathToStateConverter || right instanceof TCTLPathToStateConverter
930+ || left.hasNestedPathQuantifiers() || right.hasNestedPathQuantifiers();
931+ }
932+
933+ public boolean containsAtomicPropositionWithSpecificPlaceInTemplate(String templateName, String placeName) {
934+ return left.containsAtomicPropositionWithSpecificPlaceInTemplate(templateName, placeName)
935+ || right.containsAtomicPropositionWithSpecificPlaceInTemplate(templateName, placeName);
936+ }
937+
938+ public boolean containsAtomicPropositionWithSpecificTransitionInTemplate(String templateName, String transitionName) {
939+ return right.containsAtomicPropositionWithSpecificTransitionInTemplate(templateName, transitionName) ||
940+ left.containsAtomicPropositionWithSpecificTransitionInTemplate(templateName, transitionName);
941+ }
942+
943+ @Override
944+ public TCTLAbstractProperty findFirstPlaceHolder() {
945+ TCTLAbstractProperty result = left.findFirstPlaceHolder();
946+ if (result == null){
947+ return right.findFirstPlaceHolder();
948+ }
949+ return result;
950+ }
951+
952+ @Override
953+ public void accept(ITCTLVisitor visitor, Object context) {
954+ visitor.visit(this, context);
955+ }
956+}
957
958=== added file 'src/dk/aau/cs/TCTL/LTLXNode.java'
959--- src/dk/aau/cs/TCTL/LTLXNode.java 1970-01-01 00:00:00 +0000
960+++ src/dk/aau/cs/TCTL/LTLXNode.java 2021-10-17 18:45:24 +0000
961@@ -0,0 +1,107 @@
962+package dk.aau.cs.TCTL;
963+
964+import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
965+
966+public class LTLXNode extends TCTLAbstractPathProperty {
967+ TCTLAbstractStateProperty property;
968+
969+ public void setProperty(TCTLAbstractStateProperty property) {
970+ this.property = property;
971+ this.property.setParent(this);
972+ }
973+
974+ public TCTLAbstractStateProperty getProperty() {
975+ return property;
976+ }
977+
978+ public LTLXNode(TCTLAbstractStateProperty property) {
979+ this.property = property;
980+ this.property.setParent(this);
981+ }
982+
983+ public LTLXNode() {
984+ this.property = new TCTLStatePlaceHolder();
985+ this.property.setParent(this);
986+ }
987+
988+ @Override
989+ public String toString() {
990+ String s = property.isSimpleProperty() ? property.toString() : "("
991+ + property.toString() + ")";
992+ return "X " + s;
993+ }
994+
995+ @Override
996+ public StringPosition[] getChildren() {
997+ int start = property.isSimpleProperty() ? 0 : 1;
998+ start = start + 2;
999+ int end = start + property.toString().length();
1000+ StringPosition position = new StringPosition(start, end, property);
1001+
1002+ StringPosition[] children = { position };
1003+ return children;
1004+ }
1005+
1006+ @Override
1007+ public TCTLAbstractPathProperty replace(TCTLAbstractProperty object1,
1008+ TCTLAbstractProperty object2) {
1009+ if (this == object1 && object2 instanceof TCTLAbstractPathProperty) {
1010+ return (TCTLAbstractPathProperty) object2;
1011+ } else {
1012+ property = property.replace(object1, object2);
1013+ return this;
1014+ }
1015+ }
1016+
1017+ @Override
1018+ public boolean isSimpleProperty() {
1019+ return false;
1020+ }
1021+
1022+ @Override
1023+ public boolean containsPlaceHolder() {
1024+ return property.containsPlaceHolder();
1025+ }
1026+
1027+ @Override
1028+ public void convertForReducedNet(String templateName) {
1029+ property.convertForReducedNet(templateName);
1030+ }
1031+
1032+ @Override
1033+ public boolean equals(Object o) {
1034+ if (o instanceof LTLXNode) {
1035+ LTLXNode node = (LTLXNode) o;
1036+ return property.equals(node.getProperty());
1037+ }
1038+ return false;
1039+ }
1040+
1041+ @Override
1042+ public TCTLAbstractPathProperty copy() {
1043+ return new LTLXNode(property.copy());
1044+ }
1045+
1046+ @Override
1047+ public boolean hasNestedPathQuantifiers() {
1048+ return property instanceof TCTLPathToStateConverter || property.hasNestedPathQuantifiers();
1049+ }
1050+
1051+ public boolean containsAtomicPropositionWithSpecificPlaceInTemplate(String templateName, String placeName) {
1052+ return property.containsAtomicPropositionWithSpecificPlaceInTemplate(templateName, placeName);
1053+ }
1054+
1055+ public boolean containsAtomicPropositionWithSpecificTransitionInTemplate(String templateName, String transitionName) {
1056+ return property.containsAtomicPropositionWithSpecificTransitionInTemplate(templateName, transitionName);
1057+ }
1058+
1059+ @Override
1060+ public TCTLAbstractProperty findFirstPlaceHolder() {
1061+ return property.findFirstPlaceHolder();
1062+ }
1063+
1064+ @Override
1065+ public void accept(ITCTLVisitor visitor, Object context) {
1066+ visitor.visit(this, context);
1067+ }
1068+}
1069
1070=== removed file 'src/dk/aau/cs/TCTL/Parsing/ParseException.java'
1071=== removed file 'src/dk/aau/cs/TCTL/Parsing/SimpleCharStream.java'
1072=== removed file 'src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParser.java'
1073=== renamed file 'src/resources/TCTLParser/TAPAALQueryParser.jj' => 'src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParser.jj'
1074=== removed file 'src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParserConstants.java'
1075=== removed file 'src/dk/aau/cs/TCTL/Parsing/TAPAALQueryParserTokenManager.java'
1076=== removed file 'src/dk/aau/cs/TCTL/Parsing/Token.java'
1077=== removed file 'src/dk/aau/cs/TCTL/Parsing/TokenMgrError.java'
1078=== removed file 'src/dk/aau/cs/TCTL/SUMOParsing/ParseException.java'
1079=== renamed file 'src/resources/SUMOParser/SUMOParser.jj' => 'src/dk/aau/cs/TCTL/SUMOParsing/SUMOParser.jj'
1080=== removed file 'src/dk/aau/cs/TCTL/SUMOParsing/SUMOQueryParser.java'
1081=== removed file 'src/dk/aau/cs/TCTL/SUMOParsing/SUMOQueryParserConstants.java'
1082=== removed file 'src/dk/aau/cs/TCTL/SUMOParsing/SUMOQueryParserTokenManager.java'
1083=== removed file 'src/dk/aau/cs/TCTL/SUMOParsing/SimpleCharStream.java'
1084=== removed file 'src/dk/aau/cs/TCTL/SUMOParsing/Token.java'
1085=== removed file 'src/dk/aau/cs/TCTL/SUMOParsing/TokenMgrError.java'
1086=== modified file 'src/dk/aau/cs/TCTL/TCTLAGNode.java'
1087--- src/dk/aau/cs/TCTL/TCTLAGNode.java 2020-11-06 19:41:50 +0000
1088+++ src/dk/aau/cs/TCTL/TCTLAGNode.java 2021-10-17 18:45:24 +0000
1089@@ -4,12 +4,12 @@
1090
1091 public class TCTLAGNode extends TCTLAbstractPathProperty {
1092
1093- private TCTLAbstractStateProperty property;
1094+ private TCTLAbstractStateProperty property;
1095
1096- public void setProperty(TCTLAbstractStateProperty property) {
1097- this.property = property;
1098- this.property.setParent(this);
1099- }
1100+ public void setProperty(TCTLAbstractStateProperty property) {
1101+ this.property = property;
1102+ this.property.setParent(this);
1103+ }
1104
1105 public TCTLAbstractStateProperty getProperty() {
1106 return property;
1107@@ -64,7 +64,7 @@
1108
1109 @Override
1110 public TCTLAbstractPathProperty copy() {
1111- return new TCTLAGNode(property.copy());
1112+ return new TCTLAGNode(property.copy());
1113 }
1114
1115 @Override
1116
1117=== modified file 'src/dk/aau/cs/TCTL/TCTLAbstractProperty.java'
1118--- src/dk/aau/cs/TCTL/TCTLAbstractProperty.java 2020-11-06 19:41:50 +0000
1119+++ src/dk/aau/cs/TCTL/TCTLAbstractProperty.java 2021-10-17 18:45:24 +0000
1120@@ -2,6 +2,8 @@
1121
1122 import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
1123
1124+import java.util.Locale;
1125+
1126 public abstract class TCTLAbstractProperty {
1127
1128 // used to determine whether to put parenthesis around the property
1129@@ -62,7 +64,6 @@
1130 public abstract boolean hasNestedPathQuantifiers();
1131 // This method assumes that a place holder exists in the current query
1132 public abstract TCTLAbstractProperty findFirstPlaceHolder();
1133-
1134
1135
1136 }
1137
1138=== added file 'src/dk/aau/cs/TCTL/XMLParsing/XMLLTLQueryParser.java'
1139--- src/dk/aau/cs/TCTL/XMLParsing/XMLLTLQueryParser.java 1970-01-01 00:00:00 +0000
1140+++ src/dk/aau/cs/TCTL/XMLParsing/XMLLTLQueryParser.java 2021-10-17 18:45:24 +0000
1141@@ -0,0 +1,526 @@
1142+package dk.aau.cs.TCTL.XMLParsing;
1143+
1144+import java.util.ArrayList;
1145+import java.util.Iterator;
1146+import java.lang.NumberFormatException;
1147+
1148+import dk.aau.cs.TCTL.*;
1149+import dk.aau.cs.debug.Logger;
1150+
1151+import org.w3c.dom.NodeList;
1152+import org.w3c.dom.Node;
1153+
1154+public class XMLLTLQueryParser {
1155+
1156+ private Node property;
1157+ private QueryWrapper queryWrapper;
1158+ private static final String ERROR_MESSAGE = "Could not parse XML tag: ";
1159+
1160+ public static boolean parse(Node prop, QueryWrapper queryWrapper){
1161+
1162+ XMLLTLQueryParser parser = new XMLLTLQueryParser(prop, queryWrapper);
1163+ queryWrapper.setName(parser.parsePropertyName());
1164+
1165+ try{
1166+ queryWrapper.setProp(parser.AbstractProperty());
1167+ } catch (XMLQueryParseException e){
1168+ queryWrapper.setException(e);
1169+ Logger.log(e);
1170+ return false;
1171+ }
1172+
1173+ return true;
1174+ }
1175+
1176+ public static TCTLAbstractProperty parse(Node prop) throws XMLQueryParseException{
1177+ XMLLTLQueryParser parser = new XMLLTLQueryParser(prop);
1178+
1179+ return parser.AbstractProperty();
1180+ }
1181+
1182+ final public TCTLAbstractProperty AbstractProperty() throws XMLQueryParseException{
1183+ Node formula;
1184+
1185+ if((formula = findSubNode("formula", property)) != null){
1186+ return parseFormula(getFirstChildNode(formula));
1187+ } else{
1188+ throw new XMLQueryParseException(ERROR_MESSAGE + property.getNodeName());
1189+ }
1190+ }
1191+
1192+ private String parsePropertyName(){
1193+ Node idNode;
1194+ String result;
1195+
1196+ // Find <id> tag and get property name
1197+ if(((idNode = XMLLTLQueryParser.findSubNode("id", this.property)) == null) ||
1198+ ((result = XMLLTLQueryParser.getText(idNode)) == null)){
1199+
1200+ // If no name was found, set generic name
1201+ result = "Query Comment/Name Here";
1202+ }
1203+
1204+ return result;
1205+ }
1206+
1207+ private TCTLAbstractProperty parseFormula(Node property)
1208+ throws XMLQueryParseException{
1209+
1210+ TCTLAbstractProperty childProperty;
1211+ Node child = getFirstChildNode(property);
1212+ String nodeName = property.getNodeName();
1213+
1214+ ArrayList<Node> children;
1215+
1216+ if(nodeName.equals("invariant")){
1217+ childProperty = parseFormula(getFirstChildNode(property));
1218+ this.queryWrapper.negateQuery();
1219+ if(childProperty instanceof TCTLAbstractPathProperty){
1220+ childProperty = new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty);
1221+ }
1222+ return new TCTLEFNode(new TCTLNotNode((TCTLAbstractStateProperty)childProperty));
1223+ } else if(nodeName.equals("impossibility")){
1224+ childProperty = parseFormula(getFirstChildNode(property));
1225+ this.queryWrapper.negateQuery();
1226+ if(childProperty instanceof TCTLAbstractPathProperty){
1227+ childProperty = new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty);
1228+ }
1229+ return new TCTLEFNode((TCTLAbstractStateProperty)childProperty);
1230+ } else if(nodeName.equals("possibility")){
1231+ childProperty = parseFormula(getFirstChildNode(property));
1232+ if(childProperty instanceof TCTLAbstractPathProperty){
1233+ childProperty = new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty);
1234+ }
1235+ return new TCTLEFNode((TCTLAbstractStateProperty)childProperty);
1236+ } else if(nodeName.equals("all-paths")){
1237+ childProperty = parseFormula(child);
1238+ if(childProperty instanceof TCTLAbstractPathProperty){
1239+ return new LTLANode(new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty));
1240+ } else{
1241+ return new LTLANode((TCTLAbstractStateProperty)childProperty);
1242+ }
1243+ } else if(nodeName.equals("exists-path")){
1244+ childProperty = parseFormula(child);
1245+ if(childProperty instanceof TCTLAbstractPathProperty){
1246+ return new LTLENode(new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty));
1247+ } else{
1248+ return new LTLENode((TCTLAbstractStateProperty)childProperty);
1249+ }
1250+ } else if (nodeName.equals("finally")){
1251+ childProperty = parseFormula(child);
1252+ if(childProperty instanceof TCTLAbstractPathProperty){
1253+ return new LTLFNode(new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty));
1254+ } else{
1255+ return new LTLFNode((TCTLAbstractStateProperty)childProperty);
1256+ }
1257+ } else if (nodeName.equals("globally")){
1258+ childProperty = parseFormula(child);
1259+ if(childProperty instanceof TCTLAbstractPathProperty){
1260+ return new LTLGNode(new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty));
1261+ } else{
1262+ return new LTLGNode((TCTLAbstractStateProperty)childProperty);
1263+ }
1264+ } else if (nodeName.equals("next")){
1265+ childProperty = parseFormula(child);
1266+ if(childProperty instanceof TCTLAbstractPathProperty){
1267+ return new LTLXNode(new TCTLPathToStateConverter((TCTLAbstractPathProperty)childProperty));
1268+ } else{
1269+ return new LTLXNode((TCTLAbstractStateProperty)childProperty);
1270+ }
1271+ } else if (nodeName.equals("until")){
1272+ children = getAllChildren(property);
1273+ if(children.size() != 2){
1274+ Logger.log("ERROR");
1275+ }
1276+
1277+ TCTLAbstractProperty before = parseFormula(getFirstChildNode(children.get(0)));
1278+ TCTLAbstractProperty reach = parseFormula(getFirstChildNode(children.get(1)));
1279+
1280+ if(before instanceof TCTLAbstractPathProperty){
1281+ before = new TCTLPathToStateConverter((TCTLAbstractPathProperty)before);
1282+ }
1283+ if(reach instanceof TCTLAbstractPathProperty){
1284+ reach = new TCTLPathToStateConverter((TCTLAbstractPathProperty)reach);
1285+ }
1286+
1287+ return new LTLUNode((TCTLAbstractStateProperty)before, (TCTLAbstractStateProperty)reach);
1288+ } else if(nodeName.equals("true")){
1289+ return new TCTLTrueNode();
1290+ } else if(nodeName.equals("false")){
1291+ return new TCTLFalseNode();
1292+ } else if(nodeName.equals("negation")){
1293+ children = getAllChildren(property);
1294+
1295+ if(children.size() != 1){
1296+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1297+ }
1298+
1299+ TCTLAbstractProperty booleanFormulaChild =
1300+ parseFormula(getFirstChildNode(property));
1301+ if(booleanFormulaChild instanceof TCTLAbstractPathProperty){
1302+ booleanFormulaChild = new TCTLPathToStateConverter((TCTLAbstractPathProperty)booleanFormulaChild);
1303+ }
1304+ return new TCTLNotNode((TCTLAbstractStateProperty)booleanFormulaChild);
1305+ } else if(nodeName.equals("conjunction") || nodeName.equals("disjunction")){
1306+ children = getAllChildren(property);
1307+
1308+ if(children.size() < 2){
1309+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1310+ }
1311+
1312+ ArrayList<TCTLAbstractStateProperty> boolExpList =
1313+ new ArrayList<TCTLAbstractStateProperty>();
1314+
1315+ for (Node n : children){
1316+ TCTLAbstractProperty p = parseFormula(n);
1317+ if(p instanceof TCTLAbstractPathProperty){
1318+ p = new TCTLPathToStateConverter((TCTLAbstractPathProperty)p);
1319+ }
1320+ boolExpList.add((TCTLAbstractStateProperty)p);
1321+ }
1322+
1323+ if(nodeName == "conjunction"){
1324+ return new TCTLAndListNode(boolExpList);
1325+ } else{
1326+ return new TCTLOrListNode(boolExpList);
1327+ }
1328+ } else if(nodeName.equals("exclusive-disjunction")){
1329+ children = getAllChildren(property);
1330+
1331+ if(children.size() != 2){
1332+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1333+ }
1334+
1335+ ArrayList<TCTLAbstractStateProperty> boolExpList =
1336+ new ArrayList<TCTLAbstractStateProperty>();
1337+
1338+ TCTLAbstractProperty left = parseFormula(children.get(0));
1339+ TCTLAbstractProperty right = parseFormula(children.get(1));
1340+
1341+ if(left instanceof TCTLAbstractPathProperty){
1342+ left = new TCTLPathToStateConverter((TCTLAbstractPathProperty)left);
1343+ }
1344+ if(right instanceof TCTLAbstractPathProperty){
1345+ right = new TCTLPathToStateConverter((TCTLAbstractPathProperty)right);
1346+ }
1347+
1348+ // Parse boolean expressions
1349+ boolExpList.add((TCTLAbstractStateProperty)left);
1350+ boolExpList.add((TCTLAbstractStateProperty)right);
1351+
1352+ // Build left sub tree
1353+ TCTLAndListNode leftSubFormula =
1354+ new TCTLAndListNode(boolExpList.get(0), new TCTLNotNode(boolExpList.get(1)));
1355+
1356+ // Build right sub tree
1357+ TCTLAndListNode rightSubFormula =
1358+ new TCTLAndListNode(new TCTLNotNode(boolExpList.get(0)), boolExpList.get(1));
1359+
1360+ return new TCTLOrListNode(leftSubFormula, rightSubFormula);
1361+
1362+ } else if(nodeName.equals("implication")){
1363+ children = getAllChildren(property);
1364+
1365+ if(children.size() != 2){
1366+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1367+ }
1368+
1369+ ArrayList<TCTLAbstractStateProperty> boolExpList =
1370+ new ArrayList<TCTLAbstractStateProperty>();
1371+
1372+ TCTLAbstractProperty left = parseFormula(children.get(0));
1373+ TCTLAbstractProperty right = parseFormula(children.get(1));
1374+
1375+ if(left instanceof TCTLAbstractPathProperty){
1376+ left = new TCTLPathToStateConverter((TCTLAbstractPathProperty)left);
1377+ }
1378+ if(right instanceof TCTLAbstractPathProperty){
1379+ right = new TCTLPathToStateConverter((TCTLAbstractPathProperty)right);
1380+ }
1381+
1382+ // Parse boolean expressions
1383+ boolExpList.add((TCTLAbstractStateProperty)left);
1384+ boolExpList.add((TCTLAbstractStateProperty)right);
1385+
1386+ return new TCTLOrListNode(new TCTLNotNode(boolExpList.get(0)), boolExpList.get(1));
1387+ } else if(nodeName.equals("equivalence")){
1388+ children = getAllChildren(property);
1389+
1390+ if(children.size() != 2){
1391+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1392+ }
1393+
1394+ ArrayList<TCTLAbstractStateProperty> boolExpList =
1395+ new ArrayList<TCTLAbstractStateProperty>();
1396+
1397+ TCTLAbstractProperty left = parseFormula(children.get(0));
1398+ TCTLAbstractProperty right = parseFormula(children.get(1));
1399+
1400+ if(left instanceof TCTLAbstractPathProperty){
1401+ left = new TCTLPathToStateConverter((TCTLAbstractPathProperty)left);
1402+ }
1403+ if(right instanceof TCTLAbstractPathProperty){
1404+ right = new TCTLPathToStateConverter((TCTLAbstractPathProperty)right);
1405+ }
1406+
1407+ // Parse boolean expressions
1408+ boolExpList.add((TCTLAbstractStateProperty)left);
1409+ boolExpList.add((TCTLAbstractStateProperty)right);
1410+
1411+ // Build left sub tree
1412+ TCTLAndListNode leftSubFormula =
1413+ new TCTLAndListNode(boolExpList.get(0), boolExpList.get(1));
1414+
1415+ // Build right sub tree
1416+ TCTLAndListNode rightSubFormula =
1417+ new TCTLAndListNode(new TCTLNotNode(boolExpList.get(0)), new TCTLNotNode(boolExpList.get(1)));
1418+
1419+ return new TCTLOrListNode(leftSubFormula, rightSubFormula);
1420+ } else if(nodeName.equals("integer-eq") || nodeName.equals("integer-ne") ||
1421+ nodeName.equals("integer-lt") || nodeName.equals("integer-le") ||
1422+ nodeName.equals("integer-gt") || nodeName.equals("integer-ge")){
1423+
1424+ children = getAllChildren(property);
1425+
1426+ if(children.size() != 2){
1427+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1428+ }
1429+
1430+ TCTLAbstractStateProperty subformula1 = parseIntegerExpression(children.get(0));
1431+ TCTLAbstractStateProperty subformula2 = parseIntegerExpression(children.get(1));
1432+
1433+ if(nodeName.equals("integer-eq")){
1434+ return new TCTLAtomicPropositionNode(subformula1, "=", subformula2);
1435+ } else if(nodeName.equals("integer-ne")){
1436+ return new TCTLAtomicPropositionNode(subformula1, "!=", subformula2);
1437+ } else if(nodeName.equals("integer-lt")){
1438+ return new TCTLAtomicPropositionNode(subformula1, "<", subformula2);
1439+ } else if(nodeName.equals("integer-le")){
1440+ return new TCTLAtomicPropositionNode(subformula1, "<=", subformula2);
1441+ } else if(nodeName.equals("integer-gt")){
1442+ return new TCTLAtomicPropositionNode(subformula1, ">", subformula2);
1443+ } else if(nodeName.equals("integer-ge")){
1444+ return new TCTLAtomicPropositionNode(subformula1, ">=", subformula2);
1445+ }
1446+ } else if (nodeName.equals("is-fireable")){
1447+ // Construct a nested disjunction of transitions.
1448+
1449+ children = getAllChildren(property);
1450+
1451+ if(children.isEmpty()){
1452+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1453+ } else if(children.size() == 1) {
1454+ String[] splits = getText(children.get(0)).replace("\n", "").split("\\.");
1455+
1456+ // Check if transition contains a template name
1457+ if(splits.length > 1){
1458+ return new TCTLTransitionNode(splits[0], splits[1]);
1459+ } else {
1460+ return new TCTLTransitionNode(splits[0]);
1461+ }
1462+ } else {
1463+ ArrayList<TCTLAbstractStateProperty> transitions = new ArrayList<TCTLAbstractStateProperty>();
1464+
1465+ for(Node n : children) {
1466+ String[] splits = getText(n).replace("\n", "").split("\\.");
1467+
1468+ // Check if transition contains a template name
1469+ if(splits.length > 1){
1470+ transitions.add(new TCTLTransitionNode(splits[0], splits[1]));
1471+ } else {
1472+ transitions.add(new TCTLTransitionNode(splits[0]));
1473+ }
1474+ }
1475+ return new TCTLOrListNode(transitions);
1476+ }
1477+ } else{
1478+ parseFormula(property);
1479+ }
1480+
1481+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1482+ }
1483+
1484+ private TCTLAbstractStateProperty parseIntegerExpression(Node integerExpression)
1485+ throws XMLQueryParseException{
1486+
1487+ ArrayList<Node> children;
1488+ String nodeName = integerExpression.getNodeName();
1489+
1490+ if(nodeName.equals("integer-constant")){
1491+ String value;
1492+ int result;
1493+
1494+ if((value = getText(integerExpression)) == null){
1495+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1496+ }
1497+
1498+ value = value.replace("\n", "");
1499+
1500+ try{
1501+ result = Integer.parseInt(value);
1502+ } catch (NumberFormatException e){
1503+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1504+ }
1505+
1506+ return new TCTLConstNode(result);
1507+ } else if(nodeName.equals("tokens-count")){
1508+ children = getAllChildren(integerExpression);
1509+
1510+ if(children.size() < 1){
1511+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1512+ } else if (children.size() == 1) {
1513+ String[] splits = getText(children.get(0)).replace("\n", "").split("\\.");
1514+ // Check if place contains a template name
1515+ if(splits.length > 1){
1516+ return new TCTLPlaceNode(splits[0], splits[1]);
1517+ } else {
1518+ return new TCTLPlaceNode(splits[0]);
1519+ }
1520+ }
1521+
1522+ ArrayList<TCTLAbstractStateProperty> terms = new ArrayList<TCTLAbstractStateProperty>();
1523+ Iterator<Node> itr = children.iterator();
1524+
1525+ while(itr.hasNext()){
1526+ Node n = itr.next();
1527+ String[] splits = getText(n).replace("\n", "").split("\\.");
1528+
1529+ // Check if place contains a template name
1530+ if(splits.length > 1){
1531+ terms.add(new TCTLPlaceNode(splits[0], splits[1]));
1532+ } else {
1533+ terms.add(new TCTLPlaceNode(splits[0]));
1534+ }
1535+
1536+ if(itr.hasNext()){
1537+ terms.add(new AritmeticOperator("+"));
1538+ }
1539+ }
1540+
1541+ return new TCTLTermListNode(terms);
1542+ } else if(nodeName.equals("integer-sum") || nodeName.equals("integer-product") || nodeName.equals("integer-difference")){
1543+
1544+ children = getAllChildren(integerExpression);
1545+ Iterator<Node> itr = children.iterator();
1546+
1547+ if(children.size() < 2){
1548+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1549+ }
1550+
1551+ ArrayList<TCTLAbstractStateProperty> intExpList =
1552+ new ArrayList<TCTLAbstractStateProperty>();
1553+
1554+ while(itr.hasNext()){
1555+ Node n = itr.next();
1556+ intExpList.add(parseIntegerExpression(n));
1557+
1558+ if(itr.hasNext()){
1559+ if(nodeName.equals("integer-sum")){
1560+ intExpList.add(new AritmeticOperator("+"));
1561+ } else if(nodeName.equals("integer-product")){
1562+ intExpList.add(new AritmeticOperator("*"));
1563+ } else{
1564+ intExpList.add(new AritmeticOperator("-"));
1565+ }
1566+ }
1567+ }
1568+
1569+ return new TCTLTermListNode(intExpList);
1570+ }
1571+
1572+ throw new XMLQueryParseException(ERROR_MESSAGE + nodeName);
1573+ }
1574+
1575+ public static Node findSubNode(String name, Node node){
1576+ if (node.getNodeType() != Node.ELEMENT_NODE) {
1577+ return null;
1578+ }
1579+
1580+ if (!node.hasChildNodes()){
1581+ return null;
1582+ }
1583+
1584+ NodeList children = node.getChildNodes();
1585+
1586+ for (int i = 0; i < children.getLength(); i++){
1587+ Node subNode = children.item(i);
1588+ if (subNode.getNodeType() == Node.ELEMENT_NODE) {
1589+ if (subNode.getNodeName().equals(name))
1590+ return subNode;
1591+ }
1592+ }
1593+
1594+ return null;
1595+ }
1596+
1597+ private ArrayList<Node> getAllChildren(Node parentNode) {
1598+ NodeList children = parentNode.getChildNodes();
1599+ ArrayList<Node> elementNodes = new ArrayList<Node>();
1600+
1601+ for (int i = 0; i < children.getLength(); i++) {
1602+ Node node = children.item(i);
1603+ if (node.getNodeType() == Node.ELEMENT_NODE) {
1604+ elementNodes.add(node);
1605+ }
1606+ }
1607+
1608+ return elementNodes;
1609+ }
1610+
1611+ public static String getText(Node node){
1612+ String result = null;
1613+
1614+ if (!node.hasChildNodes()){
1615+ return null;
1616+ }
1617+
1618+ NodeList children = node.getChildNodes();
1619+
1620+ for (int i = 0; i < children.getLength(); i++){
1621+ Node subNode = children.item(i);
1622+ if (subNode.getNodeType() == Node.TEXT_NODE) {
1623+ result = subNode.getNodeValue();
1624+ }
1625+ }
1626+
1627+ return result;
1628+ }
1629+
1630+ public int getChildCount(Node node){
1631+ int result = 0;
1632+
1633+ if (!node.hasChildNodes()){
1634+ return result;
1635+ }
1636+
1637+ NodeList children = node.getChildNodes();
1638+
1639+ for (int i = 0; i < children.getLength(); i++){
1640+ Node subNode = children.item(i);
1641+ if (subNode.getNodeType() == Node.ELEMENT_NODE) {
1642+ result++;
1643+ }
1644+ }
1645+
1646+ return result;
1647+ }
1648+
1649+ private Node getFirstChildNode(Node parent){
1650+ Node child = parent.getFirstChild();
1651+
1652+ while (child != null && child.getNodeType() != Node.ELEMENT_NODE){
1653+ child = child.getNextSibling();
1654+ }
1655+
1656+ return child;
1657+ }
1658+
1659+ public XMLLTLQueryParser(Node prop, QueryWrapper qw){
1660+ this.property = prop;
1661+ this.queryWrapper = qw;
1662+ }
1663+
1664+ public XMLLTLQueryParser(Node prop){
1665+ this.property = prop;
1666+ }
1667+}
1668
1669=== modified file 'src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java'
1670--- src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java 2019-03-22 10:13:18 +0000
1671+++ src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java 2021-10-17 18:45:24 +0000
1672@@ -63,6 +63,10 @@
1673 XMLFormatter formatter = new XMLFormatter();
1674 return formatter.format(getStartTag() + XMLQuery.toString() + getEndTag());
1675 }
1676+
1677+ public StringBuffer getXMLQuery() {
1678+ return XMLQuery;
1679+ }
1680
1681 public String getStartTag(){
1682 return startTag(XML_PROPSET + " " + XML_NS) + "\n";
1683@@ -128,6 +132,32 @@
1684 euNode.getRight().accept(this, context);
1685 XMLQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_EXISTSPATH));
1686 }
1687+
1688+ public void visit(LTLFNode afNode, Object context) {
1689+ XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_FINALLY));
1690+ afNode.getProperty().accept(this, context);
1691+ XMLQuery.append(endTag(XML_FINALLY) + endTag(XML_ALLPATHS));
1692+ }
1693+
1694+ public void visit(LTLGNode agNode, Object context) {
1695+ XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_GLOBALLY));
1696+ agNode.getProperty().accept(this, context);
1697+ XMLQuery.append(endTag(XML_GLOBALLY) + endTag(XML_ALLPATHS));
1698+ }
1699+
1700+ public void visit(LTLXNode axNode, Object context) {
1701+ XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_NEXT));
1702+ axNode.getProperty().accept(this, context);
1703+ XMLQuery.append(endTag(XML_NEXT) + endTag(XML_ALLPATHS));
1704+ }
1705+
1706+ public void visit(LTLUNode auNode, Object context) {
1707+ XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_UNTIL) + startTag(XML_BEFORE));
1708+ auNode.getLeft().accept(this, context);
1709+ XMLQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH));
1710+ auNode.getRight().accept(this, context);
1711+ XMLQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_ALLPATHS));
1712+ }
1713
1714 public void visit(TCTLPathToStateConverter pathConverter, Object context) {
1715 pathConverter.getProperty().accept(this, context);
1716
1717=== modified file 'src/dk/aau/cs/TCTL/visitors/ITCTLVisitor.java'
1718--- src/dk/aau/cs/TCTL/visitors/ITCTLVisitor.java 2016-05-02 09:06:57 +0000
1719+++ src/dk/aau/cs/TCTL/visitors/ITCTLVisitor.java 2021-10-17 18:45:24 +0000
1720@@ -1,30 +1,6 @@
1721 package dk.aau.cs.TCTL.visitors;
1722
1723-import dk.aau.cs.TCTL.AritmeticOperator;
1724-import dk.aau.cs.TCTL.TCTLAFNode;
1725-import dk.aau.cs.TCTL.TCTLAGNode;
1726-import dk.aau.cs.TCTL.TCTLAXNode;
1727-import dk.aau.cs.TCTL.TCTLAUNode;
1728-import dk.aau.cs.TCTL.TCTLAndListNode;
1729-import dk.aau.cs.TCTL.TCTLAtomicPropositionNode;
1730-import dk.aau.cs.TCTL.TCTLConstNode;
1731-import dk.aau.cs.TCTL.TCTLDeadlockNode;
1732-import dk.aau.cs.TCTL.TCTLEFNode;
1733-import dk.aau.cs.TCTL.TCTLEGNode;
1734-import dk.aau.cs.TCTL.TCTLEXNode;
1735-import dk.aau.cs.TCTL.TCTLEUNode;
1736-import dk.aau.cs.TCTL.TCTLFalseNode;
1737-import dk.aau.cs.TCTL.TCTLNotNode;
1738-import dk.aau.cs.TCTL.TCTLOrListNode;
1739-import dk.aau.cs.TCTL.TCTLPathPlaceHolder;
1740-import dk.aau.cs.TCTL.TCTLPathToStateConverter;
1741-import dk.aau.cs.TCTL.TCTLPlaceNode;
1742-import dk.aau.cs.TCTL.TCTLPlusListNode;
1743-import dk.aau.cs.TCTL.TCTLStatePlaceHolder;
1744-import dk.aau.cs.TCTL.TCTLStateToPathConverter;
1745-import dk.aau.cs.TCTL.TCTLTermListNode;
1746-import dk.aau.cs.TCTL.TCTLTransitionNode;
1747-import dk.aau.cs.TCTL.TCTLTrueNode;
1748+import dk.aau.cs.TCTL.*;
1749
1750 public interface ITCTLVisitor {
1751 void visit(TCTLAFNode afNode, Object context);
1752@@ -35,6 +11,14 @@
1753
1754 void visit(TCTLAUNode auNode, Object context);
1755
1756+ void visit(LTLFNode afNode, Object context);
1757+
1758+ void visit(LTLGNode agNode, Object context);
1759+
1760+ void visit(LTLXNode axNode, Object context);
1761+
1762+ void visit(LTLUNode auNode, Object context);
1763+
1764 void visit(TCTLEFNode efNode, Object context);
1765
1766 void visit(TCTLEGNode egNode, Object context);
1767@@ -74,4 +58,8 @@
1768 void visit(TCTLConstNode tctlConstNode, Object context);
1769
1770 void visit(TCTLTermListNode tctlTermListNode, Object context);
1771+
1772+ void visit(LTLANode ltlaNode, Object context);
1773+
1774+ void visit(LTLENode ltleNode, Object context);
1775 }
1776
1777=== added file 'src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java'
1778--- src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java 1970-01-01 00:00:00 +0000
1779+++ src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java 2021-10-17 18:45:24 +0000
1780@@ -0,0 +1,233 @@
1781+package dk.aau.cs.TCTL.visitors;
1782+
1783+import java.util.List;
1784+
1785+import dk.aau.cs.TCTL.*;
1786+import dk.aau.cs.io.XMLFormatter;
1787+
1788+public class LTLQueryVisitor extends VisitorBase {
1789+
1790+ private static final String XML_NS = "xmlns=\"http://tapaal.net/\"";
1791+ private static final String XML_PROPSET = "property-set";
1792+ private static final String XML_PROP = "property";
1793+ private static final String XML_PROPID = "id";
1794+ private static final String XML_PROPDESC = "description";
1795+ private static final String XML_FORMULA = "formula";
1796+ private static final String XML_ALLPATHS = "all-paths";
1797+ private static final String XML_EXISTSPATH = "exists-path";
1798+ private static final String XML_NEGATION = "negation";
1799+ private static final String XML_CONJUNCTION = "conjunction";
1800+ private static final String XML_DISJUNCTION = "disjunction";
1801+ private static final String XML_GLOBALLY = "globally";
1802+ private static final String XML_FINALLY = "finally";
1803+ private static final String XML_NEXT = "next";
1804+ private static final String XML_UNTIL = "until";
1805+ private static final String XML_BEFORE = "before";
1806+ private static final String XML_REACH = "reach";
1807+ private static final String XML_DEADLOCK = "deadlock";
1808+ private static final String XML_TRUE = "true";
1809+ private static final String XML_FALSE = "false";
1810+ private static final String XML_INTEGERLT = "integer-lt";
1811+ private static final String XML_INTEGERLE = "integer-le";
1812+ private static final String XML_INTEGEREQ = "integer-eq";
1813+ private static final String XML_INTEGERNE = "integer-ne";
1814+ private static final String XML_INTEGERGT = "integer-gt";
1815+ private static final String XML_INTEGERGE = "integer-ge";
1816+ private static final String XML_ISFIREABLE = "is-fireable";
1817+ private static final String XML_INTEGERCONSTANT = "integer-constant";
1818+ private static final String XML_TOKENSCOUNT = "tokens-count";
1819+ private static final String XML_PLACE = "place";
1820+ private static final String XML_TRANSITION = "transition";
1821+ private static final String XML_INTEGERSUM = "integer-sum";
1822+ private static final String XML_INTEGERPRODUCT = "integer-product";
1823+ private static final String XML_INTEGERDIFFERENCE = "integer-difference";
1824+
1825+ private StringBuffer XMLQuery;
1826+
1827+ public LTLQueryVisitor() {
1828+ this.XMLQuery = new StringBuffer();
1829+ }
1830+
1831+ public String getXMLQueryFor(TCTLAbstractProperty property, String queryName) {
1832+ buildXMLQuery(property, queryName);
1833+ return getFormatted();
1834+ }
1835+
1836+ public void buildXMLQuery(TCTLAbstractProperty property, String queryName) {
1837+ XMLQuery.append(startTag(XML_PROP) + queryInfo(queryName) + startTag(XML_FORMULA));
1838+ property.accept(this, null);
1839+ XMLQuery.append(endTag(XML_FORMULA) + endTag(XML_PROP));
1840+ }
1841+
1842+ public String getFormatted() {
1843+ XMLFormatter formatter = new XMLFormatter();
1844+ return formatter.format(getStartTag() + XMLQuery.toString() + getEndTag());
1845+ }
1846+
1847+ public String getFormatted(StringBuffer CTLQueries) {
1848+ XMLFormatter formatter = new XMLFormatter();
1849+ XMLQuery.append(CTLQueries);
1850+ return formatter.format(getStartTag() + XMLQuery.toString() + getEndTag());
1851+ }
1852+
1853+ public String getStartTag(){
1854+ return startTag(XML_PROPSET + " " + XML_NS) + "\n";
1855+ }
1856+
1857+ public String getEndTag(){
1858+ return endTag(XML_PROPSET) + "\n";
1859+ }
1860+
1861+ private String queryInfo(String queryName){
1862+ String nameToPrint = (queryName == null) ? "Query Comment/Name Here" : queryName;
1863+ return wrapInTag(nameToPrint, XML_PROPID) + wrapInTag(nameToPrint, XML_PROPDESC);
1864+ }
1865+
1866+ public void visit(LTLANode aNode, Object context) {
1867+ XMLQuery.append(startTag(XML_ALLPATHS));
1868+ aNode.getProperty().accept(this, context);
1869+ XMLQuery.append(endTag(XML_ALLPATHS));
1870+ }
1871+
1872+ public void visit(LTLENode eNode, Object context) {
1873+ XMLQuery.append(startTag(XML_EXISTSPATH));
1874+ eNode.getProperty().accept(this, context);
1875+ XMLQuery.append(endTag(XML_EXISTSPATH));
1876+ }
1877+
1878+ public void visit(LTLFNode afNode, Object context) {
1879+ XMLQuery.append(startTag(XML_FINALLY));
1880+ afNode.getProperty().accept(this, context);
1881+ XMLQuery.append(endTag(XML_FINALLY));
1882+ }
1883+
1884+ public void visit(LTLGNode agNode, Object context) {
1885+ XMLQuery.append(startTag(XML_GLOBALLY));
1886+ agNode.getProperty().accept(this, context);
1887+ XMLQuery.append(endTag(XML_GLOBALLY));
1888+ }
1889+
1890+ public void visit(LTLXNode axNode, Object context) {
1891+ XMLQuery.append(startTag(XML_NEXT));
1892+ axNode.getProperty().accept(this, context);
1893+ XMLQuery.append(endTag(XML_NEXT));
1894+ }
1895+
1896+ public void visit(LTLUNode auNode, Object context) {
1897+ XMLQuery.append(startTag(XML_UNTIL) + startTag(XML_BEFORE));
1898+ auNode.getLeft().accept(this, context);
1899+ XMLQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH));
1900+ auNode.getRight().accept(this, context);
1901+ XMLQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL));
1902+ }
1903+
1904+ public void visit(TCTLPathToStateConverter pathConverter, Object context) {
1905+ pathConverter.getProperty().accept(this, context);
1906+ }
1907+
1908+ public void visit(TCTLAndListNode andListNode, Object context) {
1909+ createList(andListNode.getProperties(), context, XML_CONJUNCTION);
1910+ }
1911+
1912+ public void visit(TCTLOrListNode orListNode, Object context) {
1913+ createList(orListNode.getProperties(), context, XML_DISJUNCTION);
1914+ }
1915+
1916+ public void visit(TCTLTermListNode termListNode, Object context) {
1917+ assert termListNode.getProperties().get(1) instanceof AritmeticOperator;
1918+ AritmeticOperator operator = (AritmeticOperator)termListNode.getProperties().get(1);
1919+ String op = operator.toString();
1920+ if (op.equals("+")) {
1921+ createList(termListNode.getProperties(), context, XML_INTEGERSUM);
1922+ } else if (op.equals("*")) {
1923+ createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT);
1924+ } else if (op.equals("-")) {
1925+ createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE);
1926+ }
1927+ }
1928+
1929+ private void createList(List<TCTLAbstractStateProperty> properties, Object context, String seperator) {
1930+ XMLQuery.append(startTag(seperator));
1931+
1932+ for (TCTLAbstractStateProperty p : properties) {
1933+ p.accept(this, context);
1934+ }
1935+
1936+ XMLQuery.append(endTag(seperator));
1937+ }
1938+
1939+ public void visit(TCTLNotNode notNode, Object context) {
1940+ XMLQuery.append(startTag(XML_NEGATION));
1941+ notNode.getProperty().accept(this, context);
1942+ XMLQuery.append(endTag(XML_NEGATION));
1943+ }
1944+
1945+ public void visit(TCTLTrueNode tctlTrueNode, Object context) {
1946+ XMLQuery.append(emptyElement(XML_TRUE));
1947+ }
1948+
1949+ public void visit(TCTLFalseNode tctlFalseNode, Object context) {
1950+ XMLQuery.append(emptyElement(XML_FALSE));
1951+ }
1952+
1953+ public void visit(TCTLDeadlockNode tctlDeadLockNode, Object context) {
1954+ XMLQuery.append(emptyElement(XML_DEADLOCK));
1955+ }
1956+
1957+ public void visit(TCTLConstNode tctlConstNode, Object context){
1958+ XMLQuery.append(wrapInTag(String.valueOf(tctlConstNode.getConstant()) + "", XML_INTEGERCONSTANT));
1959+ }
1960+
1961+ public void visit(TCTLPlaceNode tctlPlaceNode, Object context){
1962+ XMLQuery.append(startTag(XML_TOKENSCOUNT));
1963+ XMLQuery.append(wrapInTag(tctlPlaceNode.toString() + "", XML_PLACE));
1964+ XMLQuery.append(endTag(XML_TOKENSCOUNT));
1965+ }
1966+
1967+ public void visit(TCTLTransitionNode tctlTransitionNode, Object context){
1968+ XMLQuery.append(startTag(XML_ISFIREABLE));
1969+ XMLQuery.append(wrapInTag(tctlTransitionNode.toString() + "", XML_TRANSITION));
1970+ XMLQuery.append(endTag(XML_ISFIREABLE));
1971+ }
1972+
1973+ @Override
1974+ public void visit(TCTLAtomicPropositionNode atomicPropositionNode,
1975+ Object context) {
1976+ String opTest = atomicPropositionNode.getOp();
1977+ String op = new String();
1978+
1979+ if (opTest.equals("<")){
1980+ op = XML_INTEGERLT;
1981+ } else if(opTest.equals("<=")){
1982+ op = XML_INTEGERLE;
1983+ } else if(opTest.equals("=")){
1984+ op = XML_INTEGEREQ;
1985+ } else if(opTest.equals("!=")){
1986+ op = XML_INTEGERNE;
1987+ } else if(opTest.equals(">")){
1988+ op = XML_INTEGERGT;
1989+ } else if(opTest.equals(">=")){
1990+ op = XML_INTEGERGE;
1991+ } else {
1992+ op = "MISSING_OPERATOR";
1993+ }
1994+
1995+ XMLQuery.append(startTag(op));
1996+ atomicPropositionNode.getLeft().accept(this, context);
1997+ atomicPropositionNode.getRight().accept(this, context);
1998+ XMLQuery.append(endTag(op));
1999+ }
2000+
2001+ private String wrapInTag(String str, String tag){
2002+ return startTag(tag) + str + endTag(tag);
2003+ }
2004+ private String startTag(String tag){
2005+ return "<" + tag + ">";
2006+ }
2007+ private String endTag(String tag){
2008+ return "</" + tag + ">";
2009+ }
2010+ private String emptyElement(String tag){
2011+ return startTag(tag + "/");
2012+ }
2013+}
2014
2015=== modified file 'src/dk/aau/cs/TCTL/visitors/VisitorBase.java'
2016--- src/dk/aau/cs/TCTL/visitors/VisitorBase.java 2016-05-02 09:06:57 +0000
2017+++ src/dk/aau/cs/TCTL/visitors/VisitorBase.java 2021-10-17 18:45:24 +0000
2018@@ -1,31 +1,6 @@
2019 package dk.aau.cs.TCTL.visitors;
2020
2021-import dk.aau.cs.TCTL.AritmeticOperator;
2022-import dk.aau.cs.TCTL.TCTLAFNode;
2023-import dk.aau.cs.TCTL.TCTLAGNode;
2024-import dk.aau.cs.TCTL.TCTLAXNode;
2025-import dk.aau.cs.TCTL.TCTLAUNode;
2026-import dk.aau.cs.TCTL.TCTLAbstractStateProperty;
2027-import dk.aau.cs.TCTL.TCTLAndListNode;
2028-import dk.aau.cs.TCTL.TCTLAtomicPropositionNode;
2029-import dk.aau.cs.TCTL.TCTLConstNode;
2030-import dk.aau.cs.TCTL.TCTLDeadlockNode;
2031-import dk.aau.cs.TCTL.TCTLEFNode;
2032-import dk.aau.cs.TCTL.TCTLEGNode;
2033-import dk.aau.cs.TCTL.TCTLEXNode;
2034-import dk.aau.cs.TCTL.TCTLEUNode;
2035-import dk.aau.cs.TCTL.TCTLFalseNode;
2036-import dk.aau.cs.TCTL.TCTLNotNode;
2037-import dk.aau.cs.TCTL.TCTLOrListNode;
2038-import dk.aau.cs.TCTL.TCTLPathPlaceHolder;
2039-import dk.aau.cs.TCTL.TCTLPathToStateConverter;
2040-import dk.aau.cs.TCTL.TCTLPlaceNode;
2041-import dk.aau.cs.TCTL.TCTLPlusListNode;
2042-import dk.aau.cs.TCTL.TCTLStatePlaceHolder;
2043-import dk.aau.cs.TCTL.TCTLStateToPathConverter;
2044-import dk.aau.cs.TCTL.TCTLTermListNode;
2045-import dk.aau.cs.TCTL.TCTLTransitionNode;
2046-import dk.aau.cs.TCTL.TCTLTrueNode;
2047+import dk.aau.cs.TCTL.*;
2048
2049 public abstract class VisitorBase implements ITCTLVisitor {
2050
2051@@ -33,8 +8,15 @@
2052 atomicPropositionNode.getLeft().accept(this, context);
2053 atomicPropositionNode.getRight().accept(this, context);
2054 }
2055-
2056- public void visit(TCTLAFNode afNode, Object context) { afNode.getProperty().accept(this, context); }
2057+
2058+ public void visit(LTLANode aNode, Object context) { aNode.getProperty().accept(this, context); }
2059+ public void visit(LTLENode eNode, Object context) { eNode.getProperty().accept(this, context); }
2060+ public void visit(LTLFNode afNode, Object context) { afNode.getProperty().accept(this, context); }
2061+ public void visit(LTLGNode agNode, Object context) { agNode.getProperty().accept(this, context); }
2062+ public void visit(LTLXNode axNode, Object context) { axNode.getProperty().accept(this, context); }
2063+ public void visit(LTLUNode auNode, Object context) { auNode.getLeft().accept(this, context);
2064+ auNode.getRight().accept(this, context); }
2065+ public void visit(TCTLAFNode afNode, Object context) { afNode.getProperty().accept(this, context); }
2066 public void visit(TCTLAGNode agNode, Object context) { agNode.getProperty().accept(this, context); }
2067 public void visit(TCTLAXNode axNode, Object context) { axNode.getProperty().accept(this, context); }
2068 public void visit(TCTLAUNode auNode, Object context) { auNode.getLeft().accept(this, context);
2069
2070=== modified file 'src/dk/aau/cs/gui/BatchProcessingDialog.java'
2071--- src/dk/aau/cs/gui/BatchProcessingDialog.java 2021-03-02 16:02:35 +0000
2072+++ src/dk/aau/cs/gui/BatchProcessingDialog.java 2021-10-17 18:45:24 +0000
2073@@ -1581,6 +1581,10 @@
2074 s.append("Trace Abstract Refinement: ");
2075 s.append(query.isTarOptionEnabled() ? "Yes\n\n" : "No\n\n");
2076
2077+ s.append("\n\n");
2078+ s.append("USe Tarjan: ");
2079+ s.append(query.isTarjan() ? "Yes\n\n" : "No\n\n");
2080+
2081 s.append("Query Property:\n");
2082 s.append(query.getProperty().toString());
2083
2084
2085=== modified file 'src/dk/aau/cs/gui/TabContent.java'
2086--- src/dk/aau/cs/gui/TabContent.java 2021-09-29 10:00:54 +0000
2087+++ src/dk/aau/cs/gui/TabContent.java 2021-10-17 18:45:24 +0000
2088@@ -19,7 +19,7 @@
2089 import dk.aau.cs.gui.components.BugHandledJXMultisplitPane;
2090 import dk.aau.cs.gui.components.NameVisibilityPanel;
2091 import dk.aau.cs.gui.components.StatisticsPanel;
2092-import dk.aau.cs.gui.components.TransitionFireingComponent;
2093+import dk.aau.cs.gui.components.TransitionFiringComponent;
2094 import dk.aau.cs.gui.undo.*;
2095 import dk.aau.cs.io.*;
2096 import dk.aau.cs.io.queries.SUMOQueryLoader;
2097@@ -691,6 +691,11 @@
2098 q.setReductionOption(ReductionOption.VerifyPN);
2099 q.setUseOverApproximationEnabled(false);
2100 q.setUseUnderApproximationEnabled(false);
2101+ } else {
2102+ if (q.getCategory() == TAPNQuery.QueryCategory.LTL) {
2103+ queriesToRemove.add(q);
2104+ tab.removeQuery(q);
2105+ }
2106 }
2107 }
2108 String message = "";
2109@@ -836,9 +841,9 @@
2110 private JScrollPane animationControllerScrollPane;
2111 private AnimationHistoryList abstractAnimationPane = null;
2112 private JPanel animationControlsPanel;
2113- private TransitionFireingComponent transitionFireing;
2114+ private TransitionFiringComponent transitionFiring;
2115
2116- private static final String transitionFireingName = "enabledTransitions";
2117+ private static final String transitionFiringName = "enabledTransitions";
2118 private static final String animControlName = "animControl";
2119
2120 private JSplitPane animationHistorySplitter;
2121@@ -1126,14 +1131,14 @@
2122 if (animControlerBox == null) {
2123 createAnimationControlSidePanel();
2124 }
2125- if (transitionFireing == null) {
2126- createTransitionFireing();
2127+ if (transitionFiring == null) {
2128+ createTransitionFiring();
2129 }
2130
2131 boolean floatingDividers = false;
2132 if(simulatorModelRoot == null){
2133 Leaf templateExplorerLeaf = new Leaf(templateExplorerName);
2134- Leaf enabledTransitionsListLeaf = new Leaf(transitionFireingName);
2135+ Leaf enabledTransitionsListLeaf = new Leaf(transitionFiringName);
2136 Leaf animControlLeaf = new Leaf(animControlName);
2137
2138 templateExplorerLeaf.setWeight(0.25);
2139@@ -1181,10 +1186,10 @@
2140 animationControlsPanel.getMinimumSize().height
2141 )
2142 );
2143- transitionFireing.setPreferredSize(
2144+ transitionFiring.setPreferredSize(
2145 new Dimension(
2146- transitionFireing.getPreferredSize().width,
2147- transitionFireing.getMinimumSize().height
2148+ transitionFiring.getPreferredSize().width,
2149+ transitionFiring.getMinimumSize().height
2150 )
2151 );
2152
2153@@ -1194,7 +1199,7 @@
2154 animatorSplitPane.add(new JPanel(), templateExplorerName);
2155
2156 animatorSplitPane.add(animationControlsPanel, animControlName);
2157- animatorSplitPane.add(transitionFireing, transitionFireingName);
2158+ animatorSplitPane.add(transitionFiring, transitionFiringName);
2159
2160 animatorSplitPaneScroller = createLeftScrollPane(animatorSplitPane);
2161 animatorSplitPane.repaint();
2162@@ -1265,7 +1270,7 @@
2163 }
2164
2165 public DelayEnabledTransitionControl getDelayEnabledTransitionControl(){
2166- return transitionFireing.getDelayEnabledTransitionControl();
2167+ return transitionFiring.getDelayEnabledTransitionControl();
2168 }
2169
2170 public void addAbstractAnimationPane() {
2171@@ -1322,12 +1327,12 @@
2172 return animationHistorySidePanel.getAnimationHistoryList();
2173 }
2174
2175- private void createTransitionFireing() {
2176- transitionFireing = new TransitionFireingComponent(CreateGui.getApp().isShowingDelayEnabledTransitions(), lens);
2177+ private void createTransitionFiring() {
2178+ transitionFiring = new TransitionFiringComponent(CreateGui.getApp().isShowingDelayEnabledTransitions(), lens);
2179 }
2180
2181- public TransitionFireingComponent getTransitionFireingComponent() {
2182- return transitionFireing;
2183+ public TransitionFiringComponent getTransitionFiringComponent() {
2184+ return transitionFiring;
2185 }
2186
2187 public TimedArcPetriNetNetwork network() {
2188@@ -1498,13 +1503,13 @@
2189 public void showEnabledTransitionsList(boolean enable) {
2190 //displayNode fires and relayout, so we check of value is changed
2191 // else elements will be set to default size.
2192- if (transitionFireing.isVisible() != enable) {
2193- animatorSplitPane.getMultiSplitLayout().displayNode(transitionFireingName, enable);
2194+ if (transitionFiring.isVisible() != enable) {
2195+ animatorSplitPane.getMultiSplitLayout().displayNode(transitionFiringName, enable);
2196 }
2197 }
2198
2199 public void showDelayEnabledTransitions(boolean enable){
2200- transitionFireing.showDelayEnabledTransitions(enable);
2201+ transitionFiring.showDelayEnabledTransitions(enable);
2202 drawingSurface.repaint();
2203
2204 CreateGui.getAnimator().updateFireableTransitions();
2205@@ -2064,7 +2069,7 @@
2206
2207 @Override
2208 public void delayAndFire() {
2209- getTransitionFireingComponent().fireSelectedTransition();
2210+ getTransitionFiringComponent().fireSelectedTransition();
2211 }
2212
2213 @Override
2214
2215=== removed file 'src/dk/aau/cs/gui/components/TransitionFireingComponent.java'
2216=== added file 'src/dk/aau/cs/gui/components/TransitionFiringComponent.java'
2217--- src/dk/aau/cs/gui/components/TransitionFiringComponent.java 1970-01-01 00:00:00 +0000
2218+++ src/dk/aau/cs/gui/components/TransitionFiringComponent.java 2021-10-17 18:45:24 +0000
2219@@ -0,0 +1,169 @@
2220+package dk.aau.cs.gui.components;
2221+
2222+import java.awt.Dimension;
2223+import java.awt.GridBagConstraints;
2224+import java.awt.GridBagLayout;
2225+import java.awt.event.KeyAdapter;
2226+import java.awt.event.KeyEvent;
2227+
2228+import javax.swing.BorderFactory;
2229+import javax.swing.JButton;
2230+import javax.swing.JPanel;
2231+
2232+import dk.aau.cs.gui.TabContent;
2233+import pipe.dataLayer.Template;
2234+import pipe.gui.AnimationSettingsDialog;
2235+import pipe.gui.DelayEnabledTransitionControl;
2236+import pipe.gui.CreateGui;
2237+import pipe.gui.SimulationControl;
2238+import pipe.gui.graphicElements.Transition;
2239+
2240+public class TransitionFiringComponent extends JPanel {
2241+
2242+ private final EnabledTransitionsList enabledTransitionsList;
2243+ private final JButton fireButton;
2244+ private final JButton settingsButton;
2245+ private final TabContent.TAPNLens lens;
2246+
2247+ public TransitionFiringComponent(boolean showDelayEnabledTransitions, TabContent.TAPNLens lens) {
2248+ super(new GridBagLayout());
2249+ enabledTransitionsList = new EnabledTransitionsList();
2250+ this.lens = lens;
2251+ this.setBorder(
2252+ BorderFactory.createCompoundBorder(
2253+ BorderFactory.createTitledBorder("Enabled Transitions"),
2254+ BorderFactory.createEmptyBorder(3, 3, 3, 3)
2255+ )
2256+ );
2257+ this.setToolTipText("List of currently enabled transitions (double click a transition to fire it)");
2258+ enabledTransitionsList.setPreferredSize(
2259+ new Dimension(
2260+ enabledTransitionsList.getPreferredSize().width,
2261+ enabledTransitionsList.getMinimumSize().height
2262+ )
2263+ );
2264+
2265+ settingsButton = new JButton("Settings");
2266+ settingsButton.setPreferredSize(new Dimension(0, settingsButton.getPreferredSize().height)); //Make the two buttons equal in size
2267+ settingsButton.addActionListener(e -> AnimationSettingsDialog.showAnimationSettings(lens));
2268+
2269+ fireButton = new JButton("Delay & Fire");
2270+ fireButton.setPreferredSize(new Dimension(0, fireButton.getPreferredSize().height)); //Make the two buttons equal in size
2271+ fireButton.addActionListener(e -> {
2272+ if(SimulationControl.getInstance().randomSimulation() && CreateGui.getApp().isShowingDelayEnabledTransitions()){
2273+ SimulationControl.startSimulation();
2274+ } else {
2275+ fireSelectedTransition();
2276+ }
2277+ });
2278+
2279+ fireButton.addKeyListener(new KeyAdapter() {
2280+ @Override
2281+ public void keyPressed(KeyEvent e) {
2282+ if(e.getKeyCode() == KeyEvent.VK_ENTER){
2283+ if(SimulationControl.getInstance().randomSimulation()){
2284+ SimulationControl.startSimulation();
2285+ } else {
2286+ fireSelectedTransition();
2287+ }
2288+ }
2289+ }
2290+ });
2291+
2292+ GridBagConstraints gbc = new GridBagConstraints();
2293+ gbc.gridx = 0;
2294+ gbc.gridy = 0;
2295+ gbc.fill = GridBagConstraints.BOTH;
2296+ gbc.gridwidth = 2;
2297+ gbc.weightx = 1;
2298+ gbc.weighty = 1;
2299+ gbc.anchor = GridBagConstraints.NORTHWEST;
2300+ this.add(enabledTransitionsList, gbc);
2301+
2302+ gbc = new GridBagConstraints();
2303+ gbc.gridx = 0;
2304+ gbc.gridy = 1;
2305+ gbc.weightx = 1;
2306+ gbc.fill = GridBagConstraints.HORIZONTAL;
2307+ gbc.anchor = GridBagConstraints.SOUTHWEST;
2308+ this.add(settingsButton, gbc);
2309+
2310+ gbc = new GridBagConstraints();
2311+ gbc.gridx = 1;
2312+ gbc.gridy = 1;
2313+ gbc.weightx = 1;
2314+ gbc.fill = GridBagConstraints.HORIZONTAL;
2315+ gbc.anchor = GridBagConstraints.SOUTHWEST;
2316+ this.add(fireButton, gbc);
2317+
2318+ showDelayEnabledTransitions(showDelayEnabledTransitions);
2319+ }
2320+
2321+ public static final String FIRE_BUTTON_DEACTIVATED_TOOL_TIP = "No transitions are enabled";
2322+ public static final String FIRE_BUTTON_ENABLED_TOOL_TIP = "Press to fire the selected transition";
2323+ public static final String SIMULATE_DEACTIVATED_TOOL_TIP = "Not able to simulate from this marking, no transitions are enabled";
2324+ public static final String SIMULATE_ACTIVATED_TOOL_TIP = "Do a random simulation of the net";
2325+
2326+ public void updateFireButton(){
2327+ //If the simulation is running deactivate the firebutton.
2328+ if(SimulationControl.getInstance().isRunning()){
2329+ fireButton.setEnabled(false);
2330+ return;
2331+ }
2332+
2333+ //Make sure the firebutton is enabled
2334+ fireButton.setEnabled(true);
2335+
2336+ //If random simulation is enabled
2337+ if(CreateGui.getApp().isShowingDelayEnabledTransitions() && SimulationControl.getInstance().randomSimulation()){
2338+ fireButton.setText("Simulate");
2339+
2340+ if(enabledTransitionsList.getNumberOfTransitions() == 0){
2341+ fireButton.setEnabled(false);
2342+ fireButton.setToolTipText(SIMULATE_DEACTIVATED_TOOL_TIP);
2343+ } else {
2344+ fireButton.setEnabled(true);
2345+ fireButton.setToolTipText(SIMULATE_ACTIVATED_TOOL_TIP);
2346+ }
2347+ } else { //If random simulation is not enabled.
2348+ fireButton.setText(CreateGui.getApp().isShowingDelayEnabledTransitions() ? "Delay & Fire" : "Fire");
2349+ if(!lens.isTimed()){
2350+ fireButton.setText("Fire");
2351+ }
2352+
2353+ if(enabledTransitionsList.getNumberOfTransitions() == 0){
2354+ fireButton.setEnabled(false);
2355+ fireButton.setToolTipText(FIRE_BUTTON_DEACTIVATED_TOOL_TIP);
2356+ } else {
2357+ fireButton.setEnabled(true);
2358+ fireButton.setToolTipText(FIRE_BUTTON_ENABLED_TOOL_TIP);
2359+ }
2360+ }
2361+ }
2362+
2363+ public void addTransition(Template template, Transition transition){
2364+ enabledTransitionsList.addTransition(template, transition);
2365+ }
2366+
2367+ public void startReInit(){
2368+ enabledTransitionsList.startReInit();
2369+ }
2370+
2371+ public void reInitDone(){
2372+ updateFireButton();
2373+ enabledTransitionsList.reInitDone();
2374+ }
2375+
2376+ public DelayEnabledTransitionControl getDelayEnabledTransitionControl() {
2377+ return DelayEnabledTransitionControl.getInstance();
2378+ }
2379+
2380+ public void showDelayEnabledTransitions(boolean enable) {
2381+ settingsButton.setVisible(enable);
2382+ updateFireButton();
2383+ }
2384+
2385+ public void fireSelectedTransition(){
2386+ enabledTransitionsList.fireSelectedTransition();
2387+ }
2388+}
2389
2390=== modified file 'src/dk/aau/cs/io/TapnXmlLoader.java'
2391--- src/dk/aau/cs/io/TapnXmlLoader.java 2021-09-29 10:04:23 +0000
2392+++ src/dk/aau/cs/io/TapnXmlLoader.java 2021-10-17 18:45:24 +0000
2393@@ -140,8 +140,10 @@
2394 Collection<Template> templates = parseTemplates(doc, network, constants);
2395 LoadedQueries loadedQueries = new TAPNQueryLoader(doc, network).parseQueries();
2396
2397- for(String message : loadedQueries.getMessages()){
2398- messages.add(message);
2399+ if (loadedQueries != null) {
2400+ for (String message : loadedQueries.getMessages()) {
2401+ messages.add(message);
2402+ }
2403 }
2404 network.buildConstraints();
2405
2406
2407=== modified file 'src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java'
2408--- src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2021-03-02 16:05:51 +0000
2409+++ src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2021-10-17 18:45:24 +0000
2410@@ -17,6 +17,7 @@
2411 import javax.xml.transform.dom.DOMSource;
2412 import javax.xml.transform.stream.StreamResult;
2413
2414+import dk.aau.cs.TCTL.visitors.LTLQueryVisitor;
2415 import dk.aau.cs.gui.TabContent;
2416 import org.w3c.dom.Attr;
2417 import org.w3c.dom.DOMException;
2418@@ -287,7 +288,9 @@
2419 Element newQuery;
2420 if (query.getCategory() == QueryCategory.CTL){
2421 newQuery = createCTLQueryElement(query, document);
2422- } else {
2423+ } else if (query.getCategory() == QueryCategory.LTL){
2424+ newQuery = createLTLQueryElement(query, document);
2425+ }else {
2426 newQuery = createQueryElement(query, document);
2427 }
2428 root.appendChild(newQuery);
2429@@ -336,7 +339,7 @@
2430 queryElement.appendChild(document.importNode(queryFormula, true));
2431
2432 queryElement.setAttribute("name", query.getName());
2433- queryElement.setAttribute("type", "CTL");
2434+ queryElement.setAttribute("type", query.getCategory().toString());
2435 queryElement.setAttribute("capacity", "" + query.getCapacity());
2436 queryElement.setAttribute("traceOption", "" + query.getTraceOption());
2437 queryElement.setAttribute("searchOption", "" + query.getSearchOption());
2438@@ -360,9 +363,49 @@
2439 queryElement.setAttribute("useQueryReduction", "" + query.isQueryReductionEnabled());
2440 queryElement.setAttribute("useStubbornReduction", "" + query.isStubbornReductionEnabled());
2441 queryElement.setAttribute("useTarOption", "" + query.isTarOptionEnabled());
2442-
2443- return queryElement;
2444+ queryElement.setAttribute("useTarjan", "" + query.isTarjan());
2445+
2446+ return queryElement;
2447 }
2448+
2449+ private Element createLTLQueryElement(TAPNQuery query, Document document) {
2450+ Require.that(query != null, "Error: query was null");
2451+ Require.that(document != null, "Error: document was null");
2452+
2453+ Element queryElement = document.createElement("query");
2454+
2455+ Node queryFormula = XMLQueryStringToElement(new LTLQueryVisitor().getXMLQueryFor(query.getProperty(), query.getName()));
2456+ queryElement.appendChild(document.importNode(queryFormula, true));
2457+
2458+ queryElement.setAttribute("name", query.getName());
2459+ queryElement.setAttribute("type", query.getCategory().toString());
2460+ queryElement.setAttribute("capacity", "" + query.getCapacity());
2461+ queryElement.setAttribute("traceOption", "" + query.getTraceOption());
2462+ queryElement.setAttribute("searchOption", "" + query.getSearchOption());
2463+ queryElement.setAttribute("hashTableSize", "" + query.getHashTableSize());
2464+ queryElement.setAttribute("extrapolationOption", "" + query.getExtrapolationOption());
2465+ queryElement.setAttribute("reductionOption", "" + query.getReductionOption());
2466+ queryElement.setAttribute("symmetry", "" + query.useSymmetry());
2467+ queryElement.setAttribute("gcd", "" + query.useGCD());
2468+ queryElement.setAttribute("timeDarts", "" + query.useTimeDarts());
2469+ queryElement.setAttribute("pTrie", "" + query.usePTrie());
2470+ queryElement.setAttribute("discreteInclusion", String.valueOf(query.discreteInclusion()));
2471+ queryElement.setAttribute("active", "" + query.isActive());
2472+ queryElement.setAttribute("inclusionPlaces", getInclusionPlacesString(query));
2473+ queryElement.setAttribute("overApproximation", "" + query.useOverApproximation());
2474+ queryElement.setAttribute("reduction", "" + query.useReduction());
2475+ queryElement.setAttribute("enableOverApproximation", "" + query.isOverApproximationEnabled());
2476+ queryElement.setAttribute("enableUnderApproximation", "" + query.isUnderApproximationEnabled());
2477+ queryElement.setAttribute("approximationDenominator", "" + query.approximationDenominator());
2478+ queryElement.setAttribute("algorithmOption", "" + query.getAlgorithmOption());
2479+ queryElement.setAttribute("useSiphonTrapAnalysis", "" + query.isSiphontrapEnabled());
2480+ queryElement.setAttribute("useQueryReduction", "" + query.isQueryReductionEnabled());
2481+ queryElement.setAttribute("useStubbornReduction", "" + query.isStubbornReductionEnabled());
2482+ queryElement.setAttribute("useTarOption", "" + query.isTarOptionEnabled());
2483+ queryElement.setAttribute("useTarjan", "" + query.isTarjan());
2484+
2485+ return queryElement;
2486+ }
2487
2488 private Node XMLQueryStringToElement(String formulaString){
2489
2490
2491=== modified file 'src/dk/aau/cs/io/queries/QueryLoader.java'
2492--- src/dk/aau/cs/io/queries/QueryLoader.java 2020-10-30 12:00:55 +0000
2493+++ src/dk/aau/cs/io/queries/QueryLoader.java 2021-10-17 18:45:24 +0000
2494@@ -37,6 +37,7 @@
2495
2496 public LoadedQueries parseQueries() {
2497 ArrayList<TAPNQuery> queries = getQueries();
2498+ if (queries == null) return null;
2499
2500 ArrayList<Tuple<String, String>> templatePlaceNames = getPlaceNames(network);
2501 ArrayList<Tuple<String, String>> templateTransitionNames = getTransitionNames(network);
2502
2503=== modified file 'src/dk/aau/cs/io/queries/TAPNQueryLoader.java'
2504--- src/dk/aau/cs/io/queries/TAPNQueryLoader.java 2021-03-02 16:05:51 +0000
2505+++ src/dk/aau/cs/io/queries/TAPNQueryLoader.java 2021-10-17 18:45:24 +0000
2506@@ -1,12 +1,10 @@
2507 package dk.aau.cs.io.queries;
2508
2509-import java.awt.*;
2510 import java.util.ArrayList;
2511 import java.util.List;
2512
2513-import javax.swing.JOptionPane;
2514-
2515-import dk.aau.cs.debug.Logger;
2516+import dk.aau.cs.TCTL.*;
2517+import dk.aau.cs.TCTL.XMLParsing.XMLLTLQueryParser;
2518 import org.w3c.dom.Document;
2519 import org.w3c.dom.Element;
2520 import org.w3c.dom.Node;
2521@@ -19,22 +17,9 @@
2522 import pipe.dataLayer.TAPNQuery.QueryCategory;
2523 import pipe.dataLayer.TAPNQuery.SearchOption;
2524 import pipe.dataLayer.TAPNQuery.TraceOption;
2525-import pipe.gui.CreateGui;
2526-import pipe.gui.MessengerImpl;
2527 import pipe.gui.widgets.InclusionPlaces;
2528 import pipe.gui.widgets.InclusionPlaces.InclusionPlacesOption;
2529-import dk.aau.cs.TCTL.StringPosition;
2530-import dk.aau.cs.TCTL.TCTLAUNode;
2531-import dk.aau.cs.TCTL.TCTLAXNode;
2532-import dk.aau.cs.TCTL.TCTLAbstractProperty;
2533-import dk.aau.cs.TCTL.TCTLAbstractStateProperty;
2534-import dk.aau.cs.TCTL.TCTLEUNode;
2535-import dk.aau.cs.TCTL.TCTLEXNode;
2536-import dk.aau.cs.TCTL.TCTLPathToStateConverter;
2537-import dk.aau.cs.TCTL.TCTLStateToPathConverter;
2538 import dk.aau.cs.TCTL.Parsing.TAPAALQueryParser;
2539-import dk.aau.cs.TCTL.TCTLPlusListNode;
2540-import dk.aau.cs.TCTL.TCTLTransitionNode;
2541 import dk.aau.cs.TCTL.XMLParsing.XMLCTLQueryParser;
2542 import dk.aau.cs.TCTL.XMLParsing.XMLQueryParseException;
2543 import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
2544@@ -87,14 +72,19 @@
2545 InclusionPlaces inclusionPlaces = getInclusionPlaces(queryElement, network);
2546 boolean reduction = getReductionOption(queryElement, "reduction", true);
2547 String algorithmOption = queryElement.getAttribute("algorithmOption");
2548- boolean isCTL = isCTLQuery(queryElement);
2549+ boolean isCTL = isTypeQuery(queryElement, "CTL");
2550+ boolean isLTL = isTypeQuery(queryElement, "LTL");
2551 boolean siphontrap = getReductionOption(queryElement, "useSiphonTrapAnalysis", false);
2552 boolean queryReduction = getReductionOption(queryElement, "useQueryReduction", true);
2553 boolean stubborn = getReductionOption(queryElement, "useStubbornReduction", true);
2554- boolean useTar = getTarOption(queryElement, "useTarOption", false);
2555+ boolean useTar = getAttributeOption(queryElement, "useTarOption", false);
2556+ boolean useTarjan = getAttributeOption(queryElement, "useTarjan", false);
2557
2558 TCTLAbstractProperty query;
2559- if (queryElement.getElementsByTagName("formula").item(0) != null){
2560+ if (queryElement.hasAttribute("type") && queryElement.getAttribute("type").equals("LTL")) {
2561+ query = parseLTLQueryProperty(queryElement);
2562+ }
2563+ else if (queryElement.getElementsByTagName("formula").item(0) != null){
2564 query = parseCTLQueryProperty(queryElement);
2565 } else {
2566 query = parseQueryProperty(queryElement.getAttribute("query"));
2567@@ -104,11 +94,12 @@
2568 TAPNQuery parsedQuery = new TAPNQuery(comment, capacity, query, traceOption, searchOption, reductionOption, symmetry, gcd, timeDarts, pTrie, overApproximation, reduction, hashTableSize, extrapolationOption, inclusionPlaces, isOverApproximationEnabled, isUnderApproximationEnabled, approximationDenominator);
2569 parsedQuery.setActive(active);
2570 parsedQuery.setDiscreteInclusion(discreteInclusion);
2571- parsedQuery.setCategory(detectCategory(query, isCTL));
2572+ parsedQuery.setCategory(detectCategory(query, isCTL, isLTL));
2573 parsedQuery.setUseSiphontrap(siphontrap);
2574 parsedQuery.setUseQueryReduction(queryReduction);
2575 parsedQuery.setUseStubbornReduction(stubborn);
2576- parsedQuery.setUseTarOption(useTar);
2577+ parsedQuery.setUseTarOption(useTar);
2578+ parsedQuery.setUseTarjan(useTarjan);
2579 if (parsedQuery.getCategory() == QueryCategory.CTL && algorithmOption != null){
2580 parsedQuery.setAlgorithmOption(AlgorithmOption.valueOf(algorithmOption));
2581 // RenameTemplateVisitor rt = new RenameTemplateVisitor("",
2582@@ -120,45 +111,53 @@
2583 return null;
2584 }
2585
2586- public static TAPNQuery.QueryCategory detectCategory(TCTLAbstractProperty query, boolean isCTL){
2587- if (isCTL) return TAPNQuery.QueryCategory.CTL;
2588-
2589- StringPosition[] children = query.getChildren();
2590-
2591- // If query is root and state property
2592- if(query instanceof TCTLAbstractStateProperty){
2593- if(((TCTLAbstractStateProperty) query).getParent() == null){
2594- return TAPNQuery.QueryCategory.CTL;
2595- }
2596- }
2597-
2598- if(query instanceof TCTLStateToPathConverter ||
2599+ public static TAPNQuery.QueryCategory detectCategory(TCTLAbstractProperty query, boolean isCTL, boolean isLTL){
2600+ if (isCTL) return TAPNQuery.QueryCategory.CTL;
2601+ if (isLTL) return QueryCategory.LTL;
2602+
2603+ StringPosition[] children = query.getChildren();
2604+
2605+ // If query is root and state property
2606+ if(query instanceof TCTLAbstractStateProperty){
2607+ if(((TCTLAbstractStateProperty) query).getParent() == null){
2608+ return TAPNQuery.QueryCategory.CTL;
2609+ }
2610+ }
2611+
2612+ if(query instanceof TCTLStateToPathConverter ||
2613 query instanceof TCTLPathToStateConverter){
2614 return TAPNQuery.QueryCategory.CTL;
2615 }
2616
2617- if(query instanceof TCTLEUNode ||
2618- query instanceof TCTLEXNode ||
2619+ if(query instanceof LTLGNode ||
2620+ query instanceof LTLFNode ||
2621+ query instanceof LTLUNode ||
2622+ query instanceof LTLXNode ||
2623+ query instanceof LTLANode ||
2624+ query instanceof LTLENode){
2625+ return TAPNQuery.QueryCategory.LTL;
2626+ } else if(query instanceof TCTLEUNode ||
2627+ query instanceof TCTLEXNode ||
2628 query instanceof TCTLAUNode ||
2629- query instanceof TCTLAXNode){
2630- return TAPNQuery.QueryCategory.CTL;
2631- }
2632-
2633- // If query is a fireability query
2634- if(query instanceof TCTLTransitionNode) {
2635- return TAPNQuery.QueryCategory.CTL;
2636+ query instanceof TCTLAXNode) {
2637+ return TAPNQuery.QueryCategory.CTL;
2638+ }
2639+
2640+ // If query is a fireability query
2641+ if(query instanceof TCTLTransitionNode) {
2642+ return TAPNQuery.QueryCategory.CTL;
2643+ }
2644+ if(query instanceof TCTLPlusListNode){
2645+ for(TCTLAbstractStateProperty sp : ((TCTLPlusListNode)query).getProperties()) {
2646+ if(TAPNQueryLoader.detectCategory(sp, isCTL, isLTL) == TAPNQuery.QueryCategory.CTL){
2647+ return TAPNQuery.QueryCategory.CTL;
2648+ }
2649 }
2650- if(query instanceof TCTLPlusListNode){
2651- for(TCTLAbstractStateProperty sp : ((TCTLPlusListNode)query).getProperties()) {
2652- if(TAPNQueryLoader.detectCategory(sp, isCTL) == TAPNQuery.QueryCategory.CTL){
2653- return TAPNQuery.QueryCategory.CTL;
2654- }
2655- }
2656 }
2657
2658 // If any property has been converted
2659 for (StringPosition child : children) {
2660- if(TAPNQueryLoader.detectCategory(child.getObject(), isCTL) == TAPNQuery.QueryCategory.CTL){
2661+ if(TAPNQueryLoader.detectCategory(child.getObject(), isCTL, isLTL) == TAPNQuery.QueryCategory.CTL){
2662 return TAPNQuery.QueryCategory.CTL;
2663 }
2664 }
2665@@ -206,13 +205,18 @@
2666 return new InclusionPlaces(InclusionPlacesOption.UserSpecified, places);
2667 }
2668
2669- private boolean isCTLQuery(Element queryElement) {
2670+ private boolean isTypeQuery(Element queryElement, String type) {
2671 if(!queryElement.hasAttribute("type")){
2672- return false;
2673+ if (type.equals("CTL")) {
2674+ return XMLQueryLoader.canBeCTL(queryElement) && !XMLQueryLoader.canBeLTL(queryElement);
2675+ } else if (type.equals("LTL")) {
2676+ return !XMLQueryLoader.canBeCTL(queryElement) && XMLQueryLoader.canBeLTL(queryElement);
2677+ }
2678+ return false;
2679 }
2680 boolean result;
2681 try {
2682- result = queryElement.getAttribute("type").equals("CTL");
2683+ result = queryElement.getAttribute("type").equals(type);
2684 } catch(Exception e) {
2685 result = false;
2686 }
2687@@ -232,7 +236,7 @@
2688 return result;
2689 }
2690
2691- private boolean getTarOption(Element queryElement, String attributeName, boolean defaultValue) {
2692+ private boolean getAttributeOption(Element queryElement, String attributeName, boolean defaultValue) {
2693 if(!queryElement.hasAttribute(attributeName)){
2694 return defaultValue;
2695 }
2696@@ -244,8 +248,8 @@
2697 }
2698 return result;
2699 }
2700-
2701- private int getApproximationValue(Element queryElement, String attributeName, int defaultValue)
2702+
2703+ private int getApproximationValue(Element queryElement, String attributeName, int defaultValue)
2704 {
2705 if(!queryElement.hasAttribute(attributeName)){
2706 return defaultValue;
2707@@ -294,6 +298,17 @@
2708 return query;
2709 }
2710
2711+ private TCTLAbstractProperty parseLTLQueryProperty(Node queryElement){
2712+ TCTLAbstractProperty query = null;
2713+ try {
2714+ query = XMLLTLQueryParser.parse(queryElement);
2715+ } catch (XMLQueryParseException e) {
2716+ messages.add(ERROR_PARSING_QUERY_MESSAGE);
2717+ }
2718+
2719+ return query;
2720+ }
2721+
2722 private TCTLAbstractProperty parseQueryProperty(String queryToParse) {
2723 TCTLAbstractProperty query = null;
2724 try {
2725
2726=== modified file 'src/dk/aau/cs/io/queries/XMLQueryLoader.java'
2727--- src/dk/aau/cs/io/queries/XMLQueryLoader.java 2020-10-09 07:59:49 +0000
2728+++ src/dk/aau/cs/io/queries/XMLQueryLoader.java 2021-10-17 18:45:24 +0000
2729@@ -3,9 +3,9 @@
2730 import java.io.File;
2731 import java.io.IOException;
2732 import java.util.ArrayList;
2733-import java.util.Collection;
2734 import javax.swing.JOptionPane;
2735
2736+import dk.aau.cs.TCTL.XMLParsing.XMLLTLQueryParser;
2737 import dk.aau.cs.io.LoadedQueries;
2738 import pipe.dataLayer.TAPNQuery;
2739 import pipe.dataLayer.TAPNQuery.ExtrapolationOption;
2740@@ -80,6 +80,7 @@
2741
2742 // Get all properties from DOM
2743 NodeList propList = doc.getElementsByTagName("property");
2744+ int choice = -1;
2745
2746 for(int i = 0; i < propList.getLength(); i++){
2747 Node prop = propList.item(i);
2748@@ -88,13 +89,43 @@
2749 // Save query for later use in dialog window
2750 this.faultyQueries.add(queryWrapper);
2751
2752+ boolean canBeCTL = canBeCTL(prop);
2753+ boolean canBeLTL = canBeLTL(prop);
2754+
2755+ if (canBeCTL && canBeLTL && choice == -1) {
2756+ choice = JOptionPane.showOptionDialog(CreateGui.getApp(),
2757+ "There were some queries that can be classified both as LTL and CTL. \nHow do you want to import them?",
2758+ "Choose query category",
2759+ JOptionPane.YES_NO_CANCEL_OPTION,
2760+ JOptionPane.QUESTION_MESSAGE,
2761+ null,
2762+ new Object[]{"Import all as CTL", "Import all as LTL", "Cancel"},
2763+ 0);
2764+ } else if (!canBeCTL && !canBeLTL) {
2765+ JOptionPane.showMessageDialog(CreateGui.getApp(),
2766+ "One or more queries do not have the correct format.");
2767+ }
2768+ if (choice == 2) return null;
2769+
2770+
2771+ boolean isCTL = (canBeCTL && !canBeLTL) || (canBeCTL && canBeLTL && choice == 0);
2772+ boolean isLTL = (!canBeCTL && canBeLTL) || (canBeCTL && canBeLTL && choice == 1 );
2773+
2774+
2775 // Update queryWrapper name and property
2776- if(!XMLCTLQueryParser.parse(prop, queryWrapper)){
2777- queries.add(null);
2778- continue;
2779+ if (isCTL) {
2780+ if (!XMLCTLQueryParser.parse(prop, queryWrapper)) {
2781+ queries.add(null);
2782+ continue;
2783+ }
2784+ } else if (isLTL) {
2785+ if (!XMLLTLQueryParser.parse(prop, queryWrapper)) {
2786+ queries.add(null);
2787+ continue;
2788+ }
2789 }
2790
2791- // The number 9999 is the number of extra tokens allowed,
2792+ // The number 9999 is the number of extra tokens allowed,
2793 // this is set high s.t. we don't have to change it manually
2794 TAPNQuery query = new TAPNQuery(queryWrapper.getName(), 9999,
2795 queryWrapper.getProp(),TraceOption.NONE, SearchOption.HEURISTIC,
2796@@ -103,9 +134,10 @@
2797
2798 RenameTemplateVisitor rt = new RenameTemplateVisitor("",
2799 network.activeTemplates().get(0).name());
2800- query.setCategory(TAPNQueryLoader.detectCategory(queryWrapper.getProp(), false));
2801+
2802+ query.setCategory(TAPNQueryLoader.detectCategory(queryWrapper.getProp(), isCTL, isLTL));
2803
2804- if(query.getCategory() == TAPNQuery.QueryCategory.CTL){
2805+ if(query.getCategory() == TAPNQuery.QueryCategory.CTL || query.getCategory() == TAPNQuery.QueryCategory.LTL){
2806 query.setSearchOption(SearchOption.DFS);
2807 query.setUseReduction(true);
2808 }
2809@@ -118,12 +150,72 @@
2810 return queries;
2811 }
2812
2813+ public static boolean canBeCTL(Node prop) {
2814+ NodeList children = prop.getChildNodes();
2815+ boolean correctQuantifiers = false;
2816+
2817+ for (int i = 0; i < children.getLength(); i++) {
2818+ Node child = children.item(i);
2819+ if (child.getNodeName().equals("formula")) {
2820+ correctQuantifiers = checkQuantifiers(child);
2821+ }
2822+ }
2823+ return correctQuantifiers;
2824+ }
2825+
2826+ private static boolean checkQuantifiers(Node prop) {
2827+ NodeList children = prop.getChildNodes();
2828+
2829+ for (int i = 0; i < children.getLength(); i++) {
2830+ Node child = children.item(i);
2831+ if (child.getNodeName().equals("finally") || child.getNodeName().equals("globally") ||
2832+ child.getNodeName().equals("next") || child.getNodeName().equals("until")) {
2833+ Node parent = child.getParentNode();
2834+ if (parent == null || !(parent.getNodeName().equals("all-paths") || parent.getNodeName().equals("exists-path"))) {
2835+ return false;
2836+ }
2837+ }
2838+ if (!checkQuantifiers(child)) return false;
2839+ }
2840+ return true;
2841+ }
2842+
2843+ public static boolean canBeLTL(Node prop) {
2844+ NodeList children = prop.getChildNodes();
2845+ int allPathsCounter = 0;
2846+
2847+ for (int i = 0; i < children.getLength(); i++) {
2848+ Node child = children.item(i);
2849+ if (child.getNodeName().equals("formula")) {
2850+ allPathsCounter += countAllPaths(child);
2851+ }
2852+ }
2853+ return allPathsCounter == 1;
2854+ }
2855+
2856+ private static int countAllPaths(Node prop) {
2857+ NodeList children = prop.getChildNodes();
2858+ int allPathsCounter = 0;
2859+
2860+ for (int i = 0; i < children.getLength(); i++) {
2861+ Node child = children.item(i);
2862+ if (child.getNodeName().equals("all-paths")) {
2863+ allPathsCounter++;
2864+ } else if (child.getNodeName().equals("exists-path") || child.getNodeName().equals("deadlock")){
2865+ return 100;
2866+ }
2867+ allPathsCounter += countAllPaths(child);
2868+ }
2869+ return allPathsCounter;
2870+ }
2871+
2872 public static void importQueries(File file, TimedArcPetriNetNetwork network){
2873 XMLQueryLoader loader = new XMLQueryLoader(file, network);
2874
2875 // Suppress default error message
2876 loader.showErrorMessage = false;
2877 LoadedQueries loadedQueries = loader.parseQueries();
2878+ if (loadedQueries == null) return;
2879
2880 for(TAPNQuery query : loadedQueries.getQueries()){
2881 CreateGui.getCurrentTab().addQuery(query);
2882
2883=== modified file 'src/dk/aau/cs/verification/ReductionStats.java'
2884--- src/dk/aau/cs/verification/ReductionStats.java 2020-07-13 13:58:47 +0000
2885+++ src/dk/aau/cs/verification/ReductionStats.java 2021-10-17 18:45:24 +0000
2886@@ -29,7 +29,7 @@
2887
2888 }
2889
2890- public int getRemovedTrantitions() {
2891+ public int getRemovedTransitions() {
2892 return removedTrantitions;
2893 }
2894
2895
2896=== modified file 'src/dk/aau/cs/verification/VerificationResult.java'
2897--- src/dk/aau/cs/verification/VerificationResult.java 2020-12-17 21:03:12 +0000
2898+++ src/dk/aau/cs/verification/VerificationResult.java 2021-10-17 18:45:24 +0000
2899@@ -183,7 +183,7 @@
2900
2901 public boolean reductionRulesApplied(){
2902 ReductionStats reductionStats = stats.getReductionStats();
2903- return (reductionStats.getRemovedPlaces() + reductionStats.getRemovedTrantitions()) > 0;
2904+ return (reductionStats.getRemovedPlaces() + reductionStats.getRemovedTransitions()) > 0;
2905 }
2906
2907 public NetworkMarking getCoveredMarking(TimedArcPetriNetNetwork model){
2908
2909=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java'
2910--- src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java 2020-12-17 21:03:12 +0000
2911+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java 2021-10-17 18:45:24 +0000
2912@@ -11,6 +11,7 @@
2913 import java.util.regex.Matcher;
2914 import java.util.regex.Pattern;
2915
2916+import dk.aau.cs.TCTL.*;
2917 import dk.aau.cs.gui.TabContent;
2918 import net.tapaal.Preferences;
2919 import net.tapaal.TAPAAL;
2920@@ -24,8 +25,6 @@
2921 import pipe.gui.widgets.InclusionPlaces;
2922 import pipe.gui.widgets.InclusionPlaces.InclusionPlacesOption;
2923 import dk.aau.cs.Messenger;
2924-import dk.aau.cs.TCTL.TCTLAFNode;
2925-import dk.aau.cs.TCTL.TCTLEGNode;
2926 import dk.aau.cs.model.tapn.LocalTimedPlace;
2927 import dk.aau.cs.model.tapn.TAPNQuery;
2928 import dk.aau.cs.model.tapn.TimedArcPetriNet;
2929@@ -333,7 +332,16 @@
2930 } else {
2931 ctlOutput = queryResult.value1().isCTL;
2932 boolean approximationResult = queryResult.value2().discoveredStates() == 0; // Result is from over-approximation
2933- TimedArcPetriNetTrace tapnTrace = parseTrace(errorOutput, options, model, exportedModel, query, queryResult.value1());
2934+ TimedArcPetriNetTrace tapnTrace;
2935+ if (!errorOutput.contains("Trace") && standardOutput.contains("<trace>")) {
2936+ String trace = "Trace:\n";
2937+ trace += (standardOutput.split("(?=<trace>)")[1]);
2938+ trace = trace.split("(?<=</trace>)")[0];
2939+ tapnTrace = parseTrace(trace, options, model, exportedModel, query, queryResult.value1());
2940+ } else {
2941+ tapnTrace = parseTrace(errorOutput, options, model, exportedModel, query, queryResult.value1());
2942+
2943+ }
2944 return new VerificationResult<TimedArcPetriNetTrace>(queryResult.value1(), tapnTrace, runner.getRunningTime(), queryResult.value2(), approximationResult, standardOutput);
2945 }
2946 }
2947@@ -396,7 +404,7 @@
2948 }
2949
2950 public boolean supportsQuery(TimedArcPetriNet model, TAPNQuery query, VerificationOptions options) {
2951- if(query.getCategory() == QueryCategory.CTL){
2952+ if(query.getCategory() == QueryCategory.CTL || query.getCategory() == QueryCategory.LTL){
2953 return true;
2954 }
2955 if(query.getProperty() instanceof TCTLEGNode || query.getProperty() instanceof TCTLAFNode) {
2956
2957=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOptions.java'
2958--- src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOptions.java 2021-08-24 11:06:31 +0000
2959+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyPNOptions.java 2021-10-17 18:45:24 +0000
2960@@ -21,10 +21,11 @@
2961 private boolean useStubbornReduction = true;
2962 private boolean useTarOption;
2963 private String pathToReducedNet;
2964+ private boolean useTarjan = true;
2965
2966 public VerifyPNOptions(int extraTokens, TraceOption traceOption, SearchOption search, boolean useOverApproximation, ModelReduction modelReduction,
2967 boolean enableOverApproximation, boolean enableUnderApproximation, int approximationDenominator, QueryCategory queryCategory, AlgorithmOption algorithmOption,
2968- boolean siphontrap, QueryReductionTime queryReduction, boolean stubbornReduction, String pathToReducedNet, boolean useTarOption) {
2969+ boolean siphontrap, QueryReductionTime queryReduction, boolean stubbornReduction, String pathToReducedNet, boolean useTarOption, boolean useTarjan) {
2970 super(extraTokens, traceOption, search, true, useOverApproximation, false, new InclusionPlaces(), enableOverApproximation, enableUnderApproximation, approximationDenominator, useTarOption);
2971 this.modelReduction = modelReduction;
2972 this.queryCategory = queryCategory;
2973@@ -34,20 +35,21 @@
2974 this.useStubbornReduction = stubbornReduction;
2975 this.useTarOption = useTarOption;
2976 this.pathToReducedNet = pathToReducedNet;
2977+ this.useTarjan = useTarjan;
2978 }
2979
2980 public VerifyPNOptions(int extraTokens, TraceOption traceOption, SearchOption search, boolean useOverApproximation, boolean useModelReduction,
2981 boolean enableOverApproximation, boolean enableUnderApproximation, int approximationDenominator, QueryCategory queryCategory, AlgorithmOption algorithmOption,
2982 boolean siphontrap, QueryReductionTime queryReduction, boolean stubbornReduction) {
2983 this(extraTokens, traceOption, search, useOverApproximation, useModelReduction? ModelReduction.AGGRESSIVE:ModelReduction.NO_REDUCTION, enableOverApproximation,
2984- enableUnderApproximation, approximationDenominator,queryCategory, algorithmOption, siphontrap, queryReduction, stubbornReduction, null, false);
2985+ enableUnderApproximation, approximationDenominator,queryCategory, algorithmOption, siphontrap, queryReduction, stubbornReduction, null, false, true);
2986 }
2987
2988 public VerifyPNOptions(int extraTokens, TraceOption traceOption, SearchOption search, boolean useOverApproximation, boolean useModelReduction,
2989 boolean enableOverApproximation, boolean enableUnderApproximation, int approximationDenominator, QueryCategory queryCategory, AlgorithmOption algorithmOption,
2990 boolean siphontrap, QueryReductionTime queryReduction, boolean stubbornReduction, boolean useTarOption) {
2991 this(extraTokens, traceOption, search, useOverApproximation, useModelReduction? ModelReduction.AGGRESSIVE:ModelReduction.NO_REDUCTION, enableOverApproximation,
2992- enableUnderApproximation, approximationDenominator,queryCategory, algorithmOption, siphontrap, queryReduction, stubbornReduction, null, useTarOption);
2993+ enableUnderApproximation, approximationDenominator,queryCategory, algorithmOption, siphontrap, queryReduction, stubbornReduction, null, useTarOption, true);
2994 }
2995
2996 @Override
2997@@ -78,7 +80,13 @@
2998 if (this.queryCategory == QueryCategory.CTL){
2999 result.append(" -ctl " + (getAlgorithmOption() == AlgorithmOption.CERTAIN_ZERO ? "czero" : "local"));
3000 result.append(" -x 1");
3001- }
3002+ } else if (this.queryCategory == QueryCategory.LTL) {
3003+ result.append(" -ltl");
3004+ if (!this.useTarjan) {
3005+ result.append(" ndfs");
3006+ }
3007+ result.append(" -x 1");
3008+ }
3009
3010 if (this.useSiphontrap) {
3011 result.append(" -a 10 ");
3012
3013=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java'
3014--- src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java 2021-09-22 15:56:33 +0000
3015+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java 2021-10-17 18:45:24 +0000
3016@@ -7,6 +7,7 @@
3017 import java.util.Collection;
3018 import java.util.List;
3019
3020+import dk.aau.cs.TCTL.visitors.LTLQueryVisitor;
3021 import dk.aau.cs.gui.TabContent;
3022 import dk.aau.cs.verification.NameMapping;
3023 import pipe.dataLayer.DataLayer;
3024@@ -32,7 +33,8 @@
3025 public ExportedVerifyTAPNModel export(TimedArcPetriNet model, TAPNQuery query, TabContent.TAPNLens lens, NameMapping mapping) {
3026 File modelFile = createTempFile(".xml");
3027 File queryFile;
3028- if (query.getCategory() == QueryCategory.CTL){
3029+
3030+ if (query.getCategory() == QueryCategory.CTL || query.getCategory() == QueryCategory.LTL){
3031 queryFile = createTempFile(".xml");
3032 } else {
3033 queryFile = createTempFile(".q");
3034@@ -59,6 +61,9 @@
3035 } else if (query.getCategory() == QueryCategory.CTL) {
3036 CTLQueryVisitor XMLVisitor = new CTLQueryVisitor();
3037 queryStream.append(XMLVisitor.getXMLQueryFor(query.getProperty(), null));
3038+ } else if (query.getCategory() == QueryCategory.LTL) {
3039+ LTLQueryVisitor XMLVisitor = new LTLQueryVisitor();
3040+ queryStream.append(XMLVisitor.getXMLQueryFor(query.getProperty(), null));
3041 } else if (lens != null && lens.isGame()) {
3042 queryStream.append("control: " + query.getProperty().toString());
3043 } else {
3044
3045=== modified file 'src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java'
3046--- src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java 2021-02-06 17:11:07 +0000
3047+++ src/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java 2021-10-17 18:45:24 +0000
3048@@ -16,7 +16,7 @@
3049 protected int tokensInModel;
3050 private final boolean symmetry;
3051 private final boolean discreteInclusion;
3052- private final boolean tarOption;
3053+ private final boolean tarOption;
3054 private InclusionPlaces inclusionPlaces;
3055
3056 //only used for boundedness analysis
3057@@ -44,7 +44,7 @@
3058 this.enabledOverApproximation = enableOverApproximation;
3059 this.enabledUnderApproximation = enableUnderApproximation;
3060 this.approximationDenominator = approximationDenominator;
3061- this.tarOption = tarOption;
3062+ this.tarOption = tarOption;
3063 }
3064
3065 public TraceOption trace() {
3066
3067=== modified file 'src/dk/aau/cs/verification/batchProcessing/BatchProcessingWorker.java'
3068--- src/dk/aau/cs/verification/batchProcessing/BatchProcessingWorker.java 2021-03-02 16:02:35 +0000
3069+++ src/dk/aau/cs/verification/batchProcessing/BatchProcessingWorker.java 2021-10-17 18:45:24 +0000
3070@@ -356,7 +356,8 @@
3071 boolean stubbornReduction = batchProcessingVerificationOptions.stubbornReductionOption() == StubbornReductionOption.KeepQueryOption ? query.isStubbornReductionEnabled() : getStubbornReductionFromBatchProcessingOptions();
3072 boolean overApproximation = query.isOverApproximationEnabled();
3073 boolean underApproximation = query.isUnderApproximationEnabled();
3074- boolean useTar = query.isTarOptionEnabled();
3075+ boolean useTar = query.isTarOptionEnabled();
3076+ boolean useTarjan = query.isTarjan();
3077 int approximationDenominator = query.approximationDenominator();
3078 if (batchProcessingVerificationOptions.approximationMethodOption() == ApproximationMethodOption.None) {
3079 overApproximation = false;
3080@@ -382,7 +383,8 @@
3081 changedQuery.setUseSiphontrap(query.isSiphontrapEnabled());
3082 changedQuery.setUseQueryReduction(query.isQueryReductionEnabled());
3083 changedQuery.setUseStubbornReduction(stubbornReduction);
3084- changedQuery.setUseTarOption(useTar);
3085+ changedQuery.setUseTarOption(useTar);
3086+ changedQuery.setUseTarjan(useTarjan);
3087 return changedQuery;
3088 } else if (batchProcessingVerificationOptions.queryPropertyOption() == QueryPropertyOption.Soundness) {
3089 isSoundnessCheck = true;
3090
3091=== modified file 'src/pipe/dataLayer/TAPNQuery.java'
3092--- src/pipe/dataLayer/TAPNQuery.java 2021-03-02 16:02:35 +0000
3093+++ src/pipe/dataLayer/TAPNQuery.java 2021-10-17 18:45:24 +0000
3094@@ -33,7 +33,7 @@
3095 }
3096
3097 public enum QueryCategory{
3098- Default, CTL
3099+ Default, CTL, LTL
3100 }
3101
3102 public enum AlgorithmOption{
3103@@ -72,7 +72,8 @@
3104 private boolean useSiphontrap = false;
3105 private boolean useQueryReduction = true;
3106 private boolean useStubbornReduction = true;
3107- private boolean useTarOption = false;
3108+ private boolean useTarOption = false;
3109+ private boolean useTarjan = false;
3110
3111 /**
3112 * @param name
3113@@ -117,6 +118,14 @@
3114 this.useTarOption = useTarOption;
3115 }
3116
3117+ public boolean isTarjan() {
3118+ return this.useTarjan;
3119+ }
3120+
3121+ public void setUseTarjan(boolean useTarjan) {
3122+ this.useTarjan = useTarjan;
3123+ }
3124+
3125 public int approximationDenominator() {
3126 return this.denominator;
3127 }
3128
3129=== modified file 'src/pipe/gui/AnimationSettingsDialog.java'
3130--- src/pipe/gui/AnimationSettingsDialog.java 2020-08-17 06:18:11 +0000
3131+++ src/pipe/gui/AnimationSettingsDialog.java 2021-10-17 18:45:24 +0000
3132@@ -29,7 +29,7 @@
3133 if(simControl.randomSimulation()){
3134 simControl.randomMode.setSelected(true);
3135 }
3136- CreateGui.getCurrentTab().getTransitionFireingComponent().updateFireButton();
3137+ CreateGui.getCurrentTab().getTransitionFiringComponent().updateFireButton();
3138 });
3139
3140 content.add(delayEnabled, BorderLayout.NORTH);
3141
3142=== modified file 'src/pipe/gui/Animator.java'
3143--- src/pipe/gui/Animator.java 2020-08-10 09:34:06 +0000
3144+++ src/pipe/gui/Animator.java 2021-10-17 18:45:24 +0000
3145@@ -16,7 +16,7 @@
3146 import pipe.gui.widgets.AnimationTokenSelectDialog;
3147 import pipe.gui.widgets.EscapableDialog;
3148 import dk.aau.cs.gui.TabContent;
3149-import dk.aau.cs.gui.components.TransitionFireingComponent;
3150+import dk.aau.cs.gui.components.TransitionFiringComponent;
3151 import dk.aau.cs.model.tapn.NetworkMarking;
3152 import dk.aau.cs.model.tapn.TimeInterval;
3153 import dk.aau.cs.model.tapn.TimedInputArc;
3154@@ -69,19 +69,26 @@
3155 public void setTrace(TAPNNetworkTrace trace) {
3156 CreateGui.getCurrentTab().setAnimationMode(true);
3157
3158- if (trace.isConcreteTrace()) {
3159- this.trace = trace;
3160- setTimedTrace(trace);
3161- } else {
3162- setUntimedTrace(trace);
3163- isDisplayingUntimedTrace = true;
3164+ try {
3165+ if (trace.isConcreteTrace()) {
3166+ this.trace = trace;
3167+ setTimedTrace(trace);
3168+ } else {
3169+ setUntimedTrace(trace);
3170+ isDisplayingUntimedTrace = true;
3171+ }
3172+ currentAction = -1;
3173+ currentMarkingIndex = 0;
3174+ tab.network().setMarking(markings.get(currentMarkingIndex));
3175+ tab.getAnimationHistorySidePanel().setSelectedIndex(0);
3176+ updateAnimationButtonsEnabled();
3177+ updateFireableTransitions();
3178+ } catch (RequireException e) {
3179+ unhighlightDisabledTransitions();
3180+ CreateGui.getCurrentTab().toggleAnimationMode();
3181+ JOptionPane.showMessageDialog(CreateGui.getApp(), "There was an error in the trace. Reason: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
3182+ return;
3183 }
3184- currentAction = -1;
3185- currentMarkingIndex = 0;
3186- tab.network().setMarking(markings.get(currentMarkingIndex));
3187- tab.getAnimationHistorySidePanel().setSelectedIndex(0);
3188- updateAnimationButtonsEnabled();
3189- updateFireableTransitions();
3190 }
3191
3192 private void setUntimedTrace(TAPNNetworkTrace trace) {
3193@@ -111,7 +118,7 @@
3194 for (TAPNNetworkTraceStep step : trace) {
3195 addMarking(step, step.performStepFrom(currentMarking()));
3196 }
3197- if(getTrace().getTraceType() != TraceType.NOT_EG){ //If the trace was not explicitly set, maybe we have calculated it is deadlock.
3198+ if (getTrace().getTraceType() != TraceType.NOT_EG) { //If the trace was not explicitly set, maybe we have calculated it is deadlock.
3199 tab.getAnimationHistorySidePanel().setLastShown(getTrace().getTraceType());
3200 }
3201 }
3202@@ -141,7 +148,7 @@
3203 }
3204
3205 public void updateFireableTransitions(){
3206- TransitionFireingComponent transFireComponent = tab.getTransitionFireingComponent();
3207+ TransitionFiringComponent transFireComponent = tab.getTransitionFiringComponent();
3208 transFireComponent.startReInit();
3209 isUrgentTransitionEnabled = false;
3210
3211@@ -180,7 +187,7 @@
3212 for(Template template : tab.allTemplates())
3213 {
3214 for (Transition tempTransition : template.guiModel().transitions()) {
3215- tempTransition.disableHightligh();
3216+ tempTransition.disableHightlight();
3217
3218 tempTransition.repaint();
3219 }
3220
3221=== modified file 'src/pipe/gui/Export.java'
3222--- src/pipe/gui/Export.java 2020-12-17 21:03:12 +0000
3223+++ src/pipe/gui/Export.java 2021-10-17 18:45:24 +0000
3224@@ -7,6 +7,7 @@
3225 package pipe.gui;
3226
3227 import dk.aau.cs.TCTL.CTLParsing.TAPAALCTLQueryParser;
3228+import dk.aau.cs.TCTL.LTLParsing.TAPAALLTLQueryParser;
3229 import dk.aau.cs.TCTL.TCTLAbstractProperty;
3230 import dk.aau.cs.TCTL.TCTLPathPlaceHolder;
3231 import java.awt.image.BufferedImage;
3232@@ -34,6 +35,7 @@
3233 import javax.xml.transform.TransformerConfigurationException;
3234 import javax.xml.transform.TransformerException;
3235
3236+import dk.aau.cs.TCTL.visitors.*;
3237 import dk.aau.cs.model.tapn.TimedArcPetriNet;
3238 import dk.aau.cs.util.Tuple;
3239 import dk.aau.cs.verification.VerifyTAPN.ExportedVerifyTAPNModel;
3240@@ -43,9 +45,6 @@
3241 import org.jetbrains.annotations.NotNull;
3242 import org.w3c.dom.DOMException;
3243
3244-import dk.aau.cs.TCTL.visitors.CTLQueryVisitor;
3245-import dk.aau.cs.TCTL.visitors.RenameAllPlacesVisitor;
3246-import dk.aau.cs.TCTL.visitors.RenameAllTransitionsVisitor;
3247 import dk.aau.cs.gui.TabContent;
3248 import dk.aau.cs.io.PNMLWriter;
3249 import dk.aau.cs.model.tapn.NetworkMarking;
3250@@ -107,23 +106,35 @@
3251 NameMapping mapping = composer.transformModel(network).value2();
3252 Iterator<TAPNQuery> queryIterator = queries.iterator();
3253 PrintStream queryStream = new PrintStream(filename);
3254- CTLQueryVisitor XMLVisitor = new CTLQueryVisitor();
3255+ LTLQueryVisitor LTLXMLVisitor = new LTLQueryVisitor();
3256+ CTLQueryVisitor CTLXMLVisitor = new CTLQueryVisitor();
3257
3258 while (queryIterator.hasNext()) {
3259+ boolean isCTL = false;
3260 TAPNQuery clonedQuery = queryIterator.next().copy();
3261
3262 // Attempt to parse and possibly transform the string query using the manual edit parser
3263 TCTLAbstractProperty newProperty;
3264 try {
3265- newProperty = TAPAALCTLQueryParser.parse(clonedQuery.getProperty().toString());
3266+ if (clonedQuery.getCategory().equals(TAPNQuery.QueryCategory.LTL)) {
3267+ newProperty = TAPAALLTLQueryParser.parse(clonedQuery.getProperty().toString());
3268+ } else {
3269+ newProperty = TAPAALCTLQueryParser.parse(clonedQuery.getProperty().toString());
3270+ isCTL = true;
3271+ }
3272 } catch (Throwable ex) {
3273 newProperty = clonedQuery == null ? new TCTLPathPlaceHolder() : clonedQuery.getProperty();
3274 }
3275 newProperty.accept(new RenameAllPlacesVisitor(mapping), null);
3276 newProperty.accept(new RenameAllTransitionsVisitor(mapping), null);
3277- XMLVisitor.buildXMLQuery(newProperty, clonedQuery.getName());
3278+
3279+ if (!isCTL) {
3280+ LTLXMLVisitor.buildXMLQuery(newProperty, clonedQuery.getName());
3281+ } else {
3282+ CTLXMLVisitor.buildXMLQuery(newProperty, clonedQuery.getName());
3283+ }
3284 }
3285- queryStream.print(XMLVisitor.getFormatted());
3286+ queryStream.append(LTLXMLVisitor.getFormatted(CTLXMLVisitor.getXMLQuery()));
3287
3288 queryStream.close();
3289 } catch (FileNotFoundException e) {
3290
3291=== modified file 'src/pipe/gui/KBoundAnalyzer.java'
3292--- src/pipe/gui/KBoundAnalyzer.java 2021-10-02 12:05:32 +0000
3293+++ src/pipe/gui/KBoundAnalyzer.java 2021-10-17 18:45:24 +0000
3294@@ -67,7 +67,7 @@
3295
3296 protected VerifyTAPNOptions verificationOptions() {
3297 if(modelChecker instanceof VerifyPN){
3298- return new VerifyPNOptions(k, TraceOption.NONE, SearchOption.BFS, false, ModelReduction.BOUNDPRESERVING, false, false, 1, QueryCategory.Default, AlgorithmOption.CERTAIN_ZERO, false, pipe.dataLayer.TAPNQuery.QueryReductionTime.UnlimitedTime, false, null, false);
3299+ return new VerifyPNOptions(k, TraceOption.NONE, SearchOption.BFS, false, ModelReduction.BOUNDPRESERVING, false, false, 1, QueryCategory.Default, AlgorithmOption.CERTAIN_ZERO, false, pipe.dataLayer.TAPNQuery.QueryReductionTime.UnlimitedTime, false, null, false, true);
3300 } else if(modelChecker instanceof VerifyTAPN){
3301 return new VerifyTAPNOptions(k, TraceOption.NONE, SearchOption.BFS, true, false, true, false, false, 1);
3302 } else if(modelChecker instanceof VerifyTAPNDiscreteVerification){
3303
3304=== modified file 'src/pipe/gui/RunVerification.java'
3305--- src/pipe/gui/RunVerification.java 2021-08-25 10:11:18 +0000
3306+++ src/pipe/gui/RunVerification.java 2021-10-17 18:45:24 +0000
3307@@ -46,7 +46,18 @@
3308
3309 @Override
3310 protected boolean showResult(VerificationResult<TAPNNetworkTrace> result) {
3311- if (result != null && !result.error()) {
3312+ if (reduceNetOnly) {
3313+ //If the engine is only called to produce a reduced net, it will fail, but no error message should be shown
3314+ if (result != null && result.stats().transitionsCount() == 0 && result.stats().placeBoundCount() == 0) {
3315+ JOptionPane.showMessageDialog(
3316+ CreateGui.getApp(),
3317+ createMessagePanel(result),
3318+ "Verification Result",
3319+ JOptionPane.INFORMATION_MESSAGE,
3320+ iconSelector.getIconFor(result)
3321+ );
3322+ }
3323+ } else if (result != null && !result.error()) {
3324 if(callback != null){
3325 callback.run(result);
3326 }else{
3327@@ -63,9 +74,7 @@
3328 }
3329 }
3330
3331- } else if(reduceNetOnly) {
3332- //If the engine is only called to produce a reduced net, it will fail, but no error message should be shown
3333- }else{
3334+ } else {
3335
3336 //Check if the is something like
3337 //verifyta: relocation_error:
3338
3339=== modified file 'src/pipe/gui/RunVerificationBase.java'
3340--- src/pipe/gui/RunVerificationBase.java 2021-09-23 11:36:16 +0000
3341+++ src/pipe/gui/RunVerificationBase.java 2021-10-17 18:45:24 +0000
3342@@ -128,7 +128,8 @@
3343 dataLayerQuery.isQueryReductionEnabled()? pipe.dataLayer.TAPNQuery.QueryReductionTime.UnlimitedTime: pipe.dataLayer.TAPNQuery.QueryReductionTime.NoTime,
3344 dataLayerQuery.isStubbornReductionEnabled(),
3345 reducedNetFilePath,
3346- dataLayerQuery.isTarOptionEnabled()
3347+ dataLayerQuery.isTarOptionEnabled(),
3348+ dataLayerQuery.isTarjan()
3349 ),
3350 transformedModel,
3351 clonedQuery
3352@@ -150,7 +151,8 @@
3353 pipe.dataLayer.TAPNQuery.QueryReductionTime.UnlimitedTime,
3354 false,
3355 reducedNetFilePath,
3356- false
3357+ false,
3358+ true
3359 ),
3360 transformedModel,
3361 clonedQuery
3362@@ -219,7 +221,7 @@
3363 firePropertyChange("state", StateValue.PENDING, StateValue.DONE);
3364
3365 if (showResult(result) && spinner != null) {
3366- options = new VerifyPNOptions(options.extraTokens(), pipe.dataLayer.TAPNQuery.TraceOption.NONE, SearchOption.BFS, false, ModelReduction.BOUNDPRESERVING, false, false, 1, pipe.dataLayer.TAPNQuery.QueryCategory.Default, pipe.dataLayer.TAPNQuery.AlgorithmOption.CERTAIN_ZERO, false, pipe.dataLayer.TAPNQuery.QueryReductionTime.NoTime, false, null, false);
3367+ options = new VerifyPNOptions(options.extraTokens(), pipe.dataLayer.TAPNQuery.TraceOption.NONE, SearchOption.BFS, false, ModelReduction.BOUNDPRESERVING, false, false, 1, pipe.dataLayer.TAPNQuery.QueryCategory.Default, pipe.dataLayer.TAPNQuery.AlgorithmOption.CERTAIN_ZERO, false, pipe.dataLayer.TAPNQuery.QueryReductionTime.NoTime, false, null, false, false);
3368 KBoundAnalyzer optimizer = new KBoundAnalyzer(model, options.extraTokens(), modelChecker, new MessengerImpl(), spinner);
3369 optimizer.analyze((VerifyTAPNOptions) options, true);
3370 }
3371
3372=== modified file 'src/pipe/gui/SimulationControl.java'
3373--- src/pipe/gui/SimulationControl.java 2020-08-17 06:18:11 +0000
3374+++ src/pipe/gui/SimulationControl.java 2021-10-17 18:45:24 +0000
3375@@ -23,7 +23,7 @@
3376 final JSlider simulationSpeed = new JSlider();
3377 final JCheckBox randomSimulation = new JCheckBox("Enable automatic random simulation");
3378 final JCheckBox randomMode = new JCheckBox("Choose next transition randomly");
3379- final Timer timer = new Timer(simulationSpeed.getValue()*20, e -> CreateGui.getCurrentTab().getTransitionFireingComponent().fireSelectedTransition());
3380+ final Timer timer = new Timer(simulationSpeed.getValue()*20, e -> CreateGui.getCurrentTab().getTransitionFiringComponent().fireSelectedTransition());
3381 private static boolean defaultIsRandomTrasition;
3382 private static SimulationControl instance;
3383
3384@@ -114,12 +114,12 @@
3385
3386 public void start(){
3387 timer.start();
3388- CreateGui.getCurrentTab().getTransitionFireingComponent().updateFireButton();
3389+ CreateGui.getCurrentTab().getTransitionFiringComponent().updateFireButton();
3390 }
3391
3392 public void stop(){
3393 timer.stop();
3394- CreateGui.getCurrentTab().getTransitionFireingComponent().updateFireButton();
3395+ CreateGui.getCurrentTab().getTransitionFiringComponent().updateFireButton();
3396 }
3397
3398 public boolean isRunning(){
3399
3400=== modified file 'src/pipe/gui/Verifier.java'
3401--- src/pipe/gui/Verifier.java 2021-02-07 11:09:51 +0000
3402+++ src/pipe/gui/Verifier.java 2021-10-17 18:45:24 +0000
3403@@ -185,44 +185,24 @@
3404 return;
3405 }
3406
3407- if (onlyCreateReducedNet) {
3408- //These options should disable the verification and only produce the net after applying reduction rules
3409- verifytapnOptions = new VerifyPNOptions(
3410- bound,
3411- query.getTraceOption(),
3412- TAPNQuery.SearchOption.OVERAPPROXIMATE,
3413- query.useOverApproximation(),
3414- query.useReduction()? ModelReduction.AGGRESSIVE:ModelReduction.NO_REDUCTION,
3415- query.isOverApproximationEnabled(),
3416- query.isUnderApproximationEnabled(),
3417- query.approximationDenominator(),
3418- query.getCategory(),
3419- query.getAlgorithmOption(),
3420- query.isSiphontrapEnabled(),
3421- TAPNQuery.QueryReductionTime.NoTime,
3422- query.isStubbornReductionEnabled(),
3423- reducedNetTempFile.getAbsolutePath(),
3424- query.isTarOptionEnabled()
3425- );
3426- } else {
3427- verifytapnOptions = new VerifyPNOptions(
3428- bound,
3429- query.getTraceOption(),
3430- query.getSearchOption(),
3431- query.useOverApproximation(),
3432- query.useReduction()? ModelReduction.AGGRESSIVE:ModelReduction.NO_REDUCTION,
3433- query.isOverApproximationEnabled(),
3434- query.isUnderApproximationEnabled(),
3435- query.approximationDenominator(),
3436- query.getCategory(),
3437- query.getAlgorithmOption(),
3438- query.isSiphontrapEnabled(),
3439- query.isQueryReductionEnabled()? TAPNQuery.QueryReductionTime.UnlimitedTime: TAPNQuery.QueryReductionTime.NoTime,
3440- query.isStubbornReductionEnabled(),
3441- reducedNetTempFile.getAbsolutePath(),
3442- query.isTarOptionEnabled()
3443- );
3444- }
3445+ verifytapnOptions = new VerifyPNOptions(
3446+ bound,
3447+ query.getTraceOption(),
3448+ query.getSearchOption(),
3449+ query.useOverApproximation(),
3450+ query.useReduction()? ModelReduction.AGGRESSIVE:ModelReduction.NO_REDUCTION,
3451+ query.isOverApproximationEnabled(),
3452+ query.isUnderApproximationEnabled(),
3453+ query.approximationDenominator(),
3454+ query.getCategory(),
3455+ query.getAlgorithmOption(),
3456+ query.isSiphontrapEnabled(),
3457+ query.isQueryReductionEnabled()? TAPNQuery.QueryReductionTime.UnlimitedTime: TAPNQuery.QueryReductionTime.NoTime,
3458+ query.isStubbornReductionEnabled(),
3459+ reducedNetTempFile.getAbsolutePath(),
3460+ query.isTarOptionEnabled(),
3461+ query.isTarjan()
3462+ );
3463 } else {
3464 verifytapnOptions = new VerifyTAPNOptions(
3465 bound,
3466
3467=== modified file 'src/pipe/gui/graphicElements/Transition.java'
3468--- src/pipe/gui/graphicElements/Transition.java 2020-10-30 12:10:06 +0000
3469+++ src/pipe/gui/graphicElements/Transition.java 2021-10-17 18:45:24 +0000
3470@@ -156,7 +156,7 @@
3471 public abstract TimeInterval getDInterval();
3472
3473 /* Called at the end of animation to reset Transitions to false */
3474- public void disableHightligh() {
3475+ public void disableHightlight() {
3476 highlightedEnabled = false;
3477 highlightedDelayEnabled = false;
3478 }
3479
3480=== modified file 'src/pipe/gui/widgets/QueryDialog.java'
3481--- src/pipe/gui/widgets/QueryDialog.java 2021-10-04 17:31:24 +0000
3482+++ src/pipe/gui/widgets/QueryDialog.java 2021-10-17 18:45:24 +0000
3483@@ -31,6 +31,7 @@
3484
3485 import dk.aau.cs.TCTL.*;
3486 import dk.aau.cs.TCTL.CTLParsing.TAPAALCTLQueryParser;
3487+import dk.aau.cs.TCTL.LTLParsing.TAPAALLTLQueryParser;
3488 import dk.aau.cs.TCTL.visitors.*;
3489 import dk.aau.cs.gui.TabContent;
3490 import dk.aau.cs.model.tapn.*;
3491@@ -86,6 +87,7 @@
3492
3493 // Query Name Panel;
3494 private JPanel namePanel;
3495+ private JComboBox queryType;
3496 private JButton advancedButton;
3497
3498 // Boundedness check panel
3499@@ -106,6 +108,12 @@
3500 private JButton forAllBox;
3501 private JButton forAllNext;
3502 private JButton forAllUntil;
3503+ private JButton globallyButton;
3504+ private JButton finallyButton;
3505+ private JButton nextButton;
3506+ private JButton untilButton;
3507+ private JButton aButton;
3508+ private JButton eButton;
3509
3510 private JTextPane queryField;
3511
3512@@ -166,7 +174,8 @@
3513 private JCheckBox useQueryReduction;
3514 private JCheckBox useReduction;
3515 private JCheckBox useStubbornReduction;
3516- private JCheckBox useTraceRefinement;
3517+ private JCheckBox useTraceRefinement;
3518+ private JCheckBox useTarjan;
3519
3520 // Approximation options panel
3521 private JPanel overApproximationOptionsPanel;
3522@@ -230,11 +239,13 @@
3523 private static boolean hasForcedDisabledStubbornReduction = false;
3524 private static boolean hasForcedDisabledGCD = false;
3525 private static boolean disableSymmetryUpdate = false;
3526+ private boolean wasCTLType = true;
3527
3528 //Strings for tool tips
3529 //Tool tips for top panel
3530 private static final String TOOL_TIP_QUERYNAME = "Enter the name of the query.";
3531- private static final String TOOL_TIP_INFO_BUTTON = "Get help on the different verification options.";
3532+ private static final String TOOL_TIP_INFO_BUTTON = "Get help on the different verification options.";
3533+ private static final String TOOL_TIP_QUERY_TYPE = "Choose the type of query.";
3534 private static final String TOOL_TIP_ADVANCED_VIEW_BUTTON = "Switch to the advanced view.";
3535 private static final String TOOL_TIP_SIMPLE_VIEW_BUTTON = "Switch to the simple view.";
3536
3537@@ -253,6 +264,13 @@
3538 private static final String TOOL_TIP_FORALL_UNTIL = "On every computation the first formula holds until the second one holds";
3539 private static final String TOOL_TIP_FORALL_NEXT = "After any transition firing the reached marking satisfies the given property.";
3540
3541+ private static final String TOOL_TIP_G = "Globally";
3542+ private static final String TOOL_TIP_F = "Eventually";
3543+ private static final String TOOL_TIP_U = "Until";
3544+ private static final String TOOL_TIP_X = "Next";
3545+ private static final String TOOL_TIP_E = "Switch to check if there exists a computation where the formula holds.";
3546+ private static final String TOOL_TIP_A = "Switch to check if the formula holds for every computation.";
3547+
3548 //Tool tips for logic panel
3549 private static final String TOOL_TIP_CONJUNCTIONBUTTON = "Expand the currently selected part of the query with a conjunction.";
3550 private static final String TOOL_TIP_DISJUNCTIONBUTTON = "Expand the currently selected part of the query with a disjunction.";
3551@@ -296,6 +314,7 @@
3552 private final static String TOOL_TIP_USE_SIPHONTRAP = "For a deadlock query, attempt to prove deadlock-freedom by using siphon-trap analysis via linear programming.";
3553 private final static String TOOL_TIP_USE_QUERY_REDUCTION = "Use query rewriting rules and linear programming (state equations) to reduce the size of the query.";
3554 private final static String TOOL_TIP_USE_TRACE_REFINEMENT = "Enables Trace Abstraction Refinement for reachability properties";
3555+ private final static String TOOL_TIP_USE_TARJAN= "Uses the Tarjan algorithm when verifying. If not selected it will verify using the nested DFS algorithm.";
3556
3557 //Tool tips for search options panel
3558 private final static String TOOL_TIP_HEURISTIC_SEARCH = "<html>Uses a heuristic method in state space exploration.<br />" +
3559@@ -441,11 +460,16 @@
3560 /* enableUnderApproximation */false,
3561 0
3562 );
3563- query.setCategory(TAPNQuery.QueryCategory.CTL);
3564+ if (queryType.getSelectedIndex() == 1) {
3565+ query.setCategory(TAPNQuery.QueryCategory.LTL);
3566+ } else {
3567+ query.setCategory(TAPNQuery.QueryCategory.CTL);
3568+ }
3569 query.setUseSiphontrap(useSiphonTrap.isSelected());
3570 query.setUseQueryReduction(useQueryReduction.isSelected());
3571 query.setUseStubbornReduction(useStubbornReduction.isSelected());
3572 query.setUseTarOption(useTraceRefinement.isSelected());
3573+ query.setUseTarjan(useTarjan.isSelected());
3574 return query;
3575 }
3576
3577@@ -527,7 +551,7 @@
3578 !(newProperty instanceof TCTLEGNode || newProperty instanceof TCTLAFNode));
3579 someTraceRadioButton.setEnabled(true);
3580 noTraceRadioButton.setEnabled(true);
3581- } else if (queryIsReachability()) {
3582+ } else if (queryIsReachability() || queryType.getSelectedIndex() == 1) {
3583 fastestTraceRadioButton.setEnabled(false);
3584 someTraceRadioButton.setEnabled(true);
3585 noTraceRadioButton.setEnabled(true);
3586@@ -713,6 +737,12 @@
3587 if (!lens.isTimed() && !lens.isGame()) {
3588 setEnablednessOfOperatorAndMarkingBoxes();
3589 }
3590+ if (current instanceof LTLANode || current instanceof LTLENode ||
3591+ (queryType.getSelectedIndex() == 1 && current instanceof TCTLPathPlaceHolder)) {
3592+ negationButton.setEnabled(false);
3593+ } else {
3594+ negationButton.setEnabled(true);
3595+ }
3596 }
3597
3598 private void updateTimedQueryButtons(TCTLAtomicPropositionNode node) {
3599@@ -779,22 +809,21 @@
3600 private void deleteSelection() {
3601 if (currentSelection != null) {
3602 TCTLAbstractProperty replacement = null;
3603- if (currentSelection.getObject() instanceof TCTLAbstractStateProperty) {
3604+ TCTLAbstractProperty selection = currentSelection.getObject();
3605+
3606+ if (selection instanceof TCTLAbstractStateProperty) {
3607 replacement = new TCTLStatePlaceHolder();
3608- } else if (currentSelection.getObject() instanceof TCTLAbstractPathProperty) {
3609+ } else if (selection instanceof TCTLAbstractPathProperty) {
3610 replacement = new TCTLPathPlaceHolder();
3611 }
3612 if (replacement != null) {
3613-
3614- UndoableEdit edit = new QueryConstructionEdit(currentSelection.getObject(), replacement);
3615-
3616- newProperty = newProperty.replace(currentSelection.getObject(), replacement);
3617-
3618- if (currentSelection.getObject() instanceof TCTLAbstractPathProperty)
3619+ UndoableEdit edit = new QueryConstructionEdit(selection, replacement);
3620+ newProperty = newProperty.replace(selection, replacement);
3621+
3622+ if (selection instanceof TCTLAbstractPathProperty)
3623 resetQuantifierSelectionButtons();
3624
3625 updateSelection(replacement);
3626-
3627 undoSupport.postEdit(edit);
3628 queryChanged();
3629 }
3630@@ -940,13 +969,25 @@
3631 currentselected = randomSearch;
3632 }
3633
3634- if(fastestTraceRadioButton.isSelected()){
3635+ if (fastestTraceRadioButton.isSelected()) {
3636 breadthFirstSearch.setEnabled(false);
3637 depthFirstSearch.setEnabled(false);
3638 heuristicSearch.setEnabled(false);
3639 randomSearch.setEnabled(false);
3640 return;
3641- }else{
3642+ } else if (queryType.getSelectedIndex() == 1) {
3643+ breadthFirstSearch.setEnabled(false);
3644+ heuristicSearch.setEnabled(true);
3645+ depthFirstSearch.setEnabled(true);
3646+ randomSearch.setEnabled(true);
3647+
3648+ if (!useTarjan.isSelected()) {
3649+ heuristicSearch.setEnabled(false);
3650+ if (someTraceRadioButton.isSelected()) {
3651+ randomSearch.setEnabled(false);
3652+ }
3653+ }
3654+ } else {
3655 breadthFirstSearch.setEnabled(true);
3656 depthFirstSearch.setEnabled(true);
3657 heuristicSearch.setEnabled(true);
3658@@ -981,6 +1022,12 @@
3659 existsNext.setEnabled(false);
3660 forAllUntil.setEnabled(false);
3661 forAllNext.setEnabled(false);
3662+ globallyButton.setEnabled(false);
3663+ finallyButton.setEnabled(false);
3664+ nextButton.setEnabled(false);
3665+ untilButton.setEnabled(false);
3666+ aButton.setEnabled(false);
3667+ eButton.setEnabled(false);
3668
3669 conjunctionButton.setEnabled(false);
3670 disjunctionButton.setEnabled(false);
3671@@ -995,6 +1042,26 @@
3672 deadLockPredicateButton.setEnabled(false);
3673 }
3674
3675+ private void disableAllLTLButtons() {
3676+ globallyButton.setEnabled(false);
3677+ finallyButton.setEnabled(false);
3678+ nextButton.setEnabled(false);
3679+ untilButton.setEnabled(false);
3680+ aButton.setEnabled(false);
3681+ eButton.setEnabled(false);
3682+
3683+ conjunctionButton.setEnabled(false);
3684+ disjunctionButton.setEnabled(false);
3685+ negationButton.setEnabled(false);
3686+ templateBox.setEnabled(false);
3687+ placeTransitionBox.setEnabled(false);
3688+ relationalOperatorBox.setEnabled(false);
3689+ placeMarking.setEnabled(false);
3690+ addPredicateButton.setEnabled(false);
3691+ truePredicateButton.setEnabled(false);
3692+ falsePredicateButton.setEnabled(false);
3693+ }
3694+
3695 private void enableOnlyPathButtons() {
3696 existsBox.setEnabled(true);
3697 existsDiamond.setEnabled(true);
3698@@ -1063,6 +1130,11 @@
3699 truePredicateButton.setEnabled(true);
3700 falsePredicateButton.setEnabled(true);
3701 deadLockPredicateButton.setEnabled(true);
3702+
3703+ if (queryType.getSelectedIndex() == 1) {
3704+ updateLTLButtons();
3705+ }
3706+
3707 setEnablednessOfAddPredicateButton();
3708 }
3709
3710@@ -1092,7 +1164,8 @@
3711 }
3712
3713 private void setEnablednessOfAddPredicateButton() {
3714- if (placeTransitionBox.getSelectedItem() == null)
3715+ if (placeTransitionBox.getSelectedItem() == null ||
3716+ (queryType.getSelectedIndex() == 1 && currentSelection.getObject() == newProperty))
3717 addPredicateButton.setEnabled(false);
3718 else
3719 addPredicateButton.setEnabled(true);
3720@@ -1211,10 +1284,13 @@
3721 setupQuantificationFromQuery(queryToCreateFrom);
3722 setupApproximationOptionsFromQuery(queryToCreateFrom);
3723 }
3724+
3725+ setupQueryCategoryFromQuery(queryToCreateFrom);
3726 setupSearchOptionsFromQuery(queryToCreateFrom);
3727 setupReductionOptionsFromQuery(queryToCreateFrom);
3728 setupTraceOptionsFromQuery(queryToCreateFrom);
3729 setupTarOptionsFromQuery(queryToCreateFrom);
3730+ setupTarjanOptionsFromQuery(queryToCreateFrom);
3731 }
3732
3733 private void setupTarOptionsFromQuery(TAPNQuery queryToCreateFrom) {
3734@@ -1223,6 +1299,10 @@
3735 }
3736 }
3737
3738+ private void setupTarjanOptionsFromQuery(TAPNQuery queryToCreateFrom) {
3739+ useTarjan.setSelected(queryToCreateFrom.isTarjan());
3740+ }
3741+
3742 private void setupApproximationOptionsFromQuery(TAPNQuery queryToCreateFrom) {
3743 if (queryToCreateFrom.isOverApproximationEnabled())
3744 overApproximationEnable.setSelected(true);
3745@@ -1295,6 +1375,7 @@
3746 useStubbornReduction.setSelected(queryToCreateFrom.isStubbornReductionEnabled());
3747 useReduction.setSelected(queryToCreateFrom.useReduction());
3748 useTraceRefinement.setSelected(queryToCreateFrom.isTarOptionEnabled());
3749+ useTarjan.setSelected(queryToCreateFrom.isTarjan());
3750 }
3751
3752 private void setupTraceOptionsFromQuery(TAPNQuery queryToCreateFrom) {
3753@@ -1335,6 +1416,17 @@
3754 }
3755 }
3756
3757+ private void setupQueryCategoryFromQuery(TAPNQuery queryToCreateFrom) {
3758+ if (!lens.isTimed() && !lens.isGame()) {
3759+ TAPNQuery.QueryCategory category = queryToCreateFrom.getCategory();
3760+ if (category.equals(TAPNQuery.QueryCategory.CTL)) {
3761+ queryType.setSelectedIndex(0);
3762+ } else if (category.equals(TAPNQuery.QueryCategory.LTL)) {
3763+ queryType.setSelectedIndex(1);
3764+ }
3765+ }
3766+ }
3767+
3768 private void initQueryNamePanel() {
3769
3770 JPanel splitter = new JPanel(new BorderLayout());
3771@@ -1365,6 +1457,10 @@
3772
3773 }
3774 });
3775+ queryType = new JComboBox(new String[]{"CTL/Reachability", "LTL"});
3776+ queryType.setToolTipText(TOOL_TIP_QUERY_TYPE);
3777+ queryType.addActionListener(arg0 -> toggleDialogType());
3778+
3779 advancedButton = new JButton("Advanced view");
3780 advancedButton.setToolTipText(TOOL_TIP_ADVANCED_VIEW_BUTTON);
3781 advancedButton.addActionListener(arg0 -> toggleAdvancedSimpleView(true));
3782@@ -1432,6 +1528,7 @@
3783 });
3784 JPanel topButtonPanel = new JPanel(new FlowLayout());
3785 topButtonPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
3786+ if (!lens.isTimed() && !lens.isGame()) topButtonPanel.add(queryType);
3787 topButtonPanel.add(advancedButton);
3788 topButtonPanel.add(infoButton);
3789
3790@@ -1486,6 +1583,309 @@
3791 guiDialog.setLocation(location);
3792 }
3793
3794+ private void toggleDialogType() {
3795+ if (queryType.getSelectedIndex() == 1 && wasCTLType) {
3796+ String ltlType = checkLTLType();
3797+ boolean isA = ltlType.equals("A");
3798+ if (convertPropertyType(false, newProperty, true, isA) == null &&
3799+ !(newProperty instanceof TCTLStatePlaceHolder)) {
3800+ if (showWarningMessage(false) == JOptionPane.YES_OPTION) {
3801+ deleteProperty();
3802+ } else {
3803+ queryType.setSelectedIndex(0);
3804+ return;
3805+ }
3806+ } else if (isA) {
3807+ addAllPathsToProperty(newProperty, null);
3808+ } else if (ltlType.equals("E")) {
3809+ addExistsPathsToProperty(newProperty, null);
3810+ }
3811+ showLTLButtons(true);
3812+ updateShiphonTrap(true);
3813+ queryChanged();
3814+ wasCTLType = false;
3815+ } else if (queryType.getSelectedIndex() == 0 && !wasCTLType) {
3816+ if (convertPropertyType(true, newProperty, true, newProperty instanceof LTLANode) == null &&
3817+ !(newProperty instanceof TCTLStatePlaceHolder)) {
3818+ if (showWarningMessage(true) == JOptionPane.YES_OPTION) {
3819+ deleteProperty();
3820+ newProperty = removeExistsAllPathsFromProperty(newProperty);
3821+ } else {
3822+ queryType.setSelectedIndex(1);
3823+ return;
3824+ }
3825+ }
3826+ showLTLButtons(false);
3827+ updateShiphonTrap(false);
3828+ wasCTLType = true;
3829+ }
3830+ if (undoManager != null) undoManager.discardAllEdits();
3831+ if (undoButton != null) undoButton.setEnabled(false);
3832+ if (redoButton != null) redoButton.setEnabled(false);
3833+ setEnabledOptionsAccordingToCurrentReduction();
3834+ }
3835+
3836+ private String checkLTLType() {
3837+ if (newProperty.toString().equals("<*>"))
3838+ return "placeholder";
3839+ if (newProperty.toString().startsWith("A"))
3840+ return "A";
3841+ if (newProperty.toString().startsWith("E"))
3842+ return "E";
3843+ if (newProperty.toString().startsWith("A", 2))
3844+ return "A";
3845+ if (newProperty.toString().startsWith("E", 2))
3846+ return "E";
3847+ if (newProperty.toString().startsWith("A", 3))
3848+ return "A";
3849+ if (newProperty.toString().startsWith("E", 3))
3850+ return "E";
3851+ return "placeholder";
3852+ }
3853+
3854+ private TCTLAbstractProperty convertPropertyType(boolean toCTL, TCTLAbstractProperty property, boolean isFirst, boolean isA) {
3855+ if (property != null) {
3856+ property = removeExistsAllPathsFromProperty(removeConverter(property));
3857+
3858+ if (!toCTL && (property instanceof TCTLDeadlockNode || !canBeConverted(property, isA))) {
3859+ return null;
3860+ } else if (property.isSimpleProperty() && !(property instanceof TCTLNotNode)) {
3861+ if (!isFirst) {
3862+ return property;
3863+ } else if (property instanceof TCTLTrueNode || property instanceof TCTLFalseNode ||
3864+ property instanceof TCTLAtomicPropositionNode || property instanceof TCTLTransitionNode) {
3865+ property = ConvertToPathProperty((TCTLAbstractStateProperty) property);
3866+ return replaceProperty(property);
3867+ }
3868+ }
3869+
3870+ TCTLAbstractProperty replacement = getReplacement(toCTL, property, isA);
3871+
3872+ if (!isFirst) {
3873+ return replacement;
3874+ }
3875+ return replaceProperty(replacement);
3876+ }
3877+ return null;
3878+ }
3879+
3880+ private boolean canBeConverted(TCTLAbstractProperty property, boolean isA) {
3881+ if (isA && property.toString().startsWith("E")) {
3882+ return false;
3883+ } else if (!isA && property.toString().startsWith("A")) {
3884+ return false;
3885+ }
3886+ return true;
3887+ }
3888+
3889+ private TCTLAbstractProperty removeConverter(TCTLAbstractProperty property) {
3890+ while (property instanceof TCTLPathToStateConverter || property instanceof TCTLStateToPathConverter) {
3891+ if (property instanceof TCTLStateToPathConverter) {
3892+ property = ConvertToStateProperty((TCTLStateToPathConverter) property);
3893+ } else {
3894+ property = ConvertToPathProperty((TCTLPathToStateConverter) property);
3895+ }
3896+ }
3897+ return property;
3898+ }
3899+
3900+ private TCTLAbstractProperty getReplacement(boolean toCTL, TCTLAbstractProperty property, boolean isA) {
3901+ TCTLAbstractProperty replacement = null;
3902+ TCTLAbstractStateProperty firstChild = getChild(toCTL, property, 1, isA);
3903+ TCTLAbstractStateProperty secondChild = getChild(toCTL, property, 2, isA);
3904+ property = removeConverter(property);
3905+
3906+ if (firstChild == null || secondChild == null)
3907+ return null;
3908+ if (toCTL) {
3909+ if (property instanceof LTLGNode) {
3910+ replacement = isA? new TCTLAGNode(firstChild) : new TCTLEGNode(firstChild);
3911+ } else if (property instanceof LTLFNode) {
3912+ replacement = isA ? new TCTLAFNode(firstChild) : new TCTLEFNode(firstChild);
3913+ } else if (property instanceof LTLXNode) {
3914+ replacement = isA ? new TCTLAXNode(firstChild) : new TCTLEXNode(firstChild);
3915+ } else if (property instanceof LTLUNode) {
3916+ replacement = isA ? new TCTLAUNode(firstChild, secondChild): new TCTLEUNode(firstChild, secondChild);
3917+ }
3918+ } else {
3919+ if (property instanceof TCTLAGNode || property instanceof TCTLEGNode) {
3920+ replacement = new LTLGNode(firstChild);
3921+ } else if (property instanceof TCTLAFNode || property instanceof TCTLEFNode) {
3922+ replacement = new LTLFNode(firstChild);
3923+ } else if (property instanceof TCTLAXNode || property instanceof TCTLEXNode) {
3924+ replacement = new LTLXNode(firstChild);
3925+ } else if (property instanceof TCTLAUNode || property instanceof TCTLEUNode) {
3926+ replacement = new LTLUNode(firstChild, secondChild);
3927+ }
3928+ }
3929+
3930+ if (replacement == null) {
3931+ if (property instanceof TCTLStatePlaceHolder || property instanceof TCTLPathPlaceHolder) {
3932+ return property;
3933+ } else if (property instanceof TCTLNotNode) {
3934+ return new TCTLNotNode(firstChild);
3935+ } else if (property instanceof TCTLAndListNode) {
3936+ return new TCTLAndListNode(firstChild, secondChild);
3937+ } else if (property instanceof TCTLOrListNode) {
3938+ return new TCTLOrListNode(firstChild, secondChild);
3939+ } else {
3940+ replacement = property;
3941+ }
3942+ }
3943+ return replacement;
3944+ }
3945+
3946+ private TCTLAbstractStateProperty getChild(boolean toCTL, TCTLAbstractProperty property, int childNumber, boolean isA) {
3947+ property = removeConverter(property);
3948+ TCTLAbstractProperty child = getSpecificChildOfProperty(childNumber, property);
3949+ child = removeConverter(child);
3950+
3951+ if (!(child instanceof TCTLStatePlaceHolder || child instanceof TCTLPathPlaceHolder)) {
3952+ if (!child.isSimpleProperty() || child instanceof TCTLNotNode) {
3953+ TCTLAbstractProperty replacement = convertPropertyType(toCTL, child, false, isA);
3954+ if (replacement == null) {
3955+ return null;
3956+ }
3957+ replacement = removeConverter(replacement);
3958+ child = child.replace(child, replacement);
3959+ } else if (child instanceof TCTLDeadlockNode) {
3960+ return null;
3961+ }
3962+ }
3963+ if (child instanceof TCTLAbstractPathProperty) {
3964+ return ConvertToStateProperty((TCTLAbstractPathProperty)child);
3965+ }
3966+
3967+ return (TCTLAbstractStateProperty) child;
3968+ }
3969+
3970+ private TCTLAbstractProperty replaceProperty(TCTLAbstractProperty replacement) {
3971+ if (replacement != null) {
3972+ newProperty = removeConverter(newProperty);
3973+ if ((newProperty instanceof LTLANode || newProperty instanceof LTLENode)
3974+ && !(replacement instanceof TCTLAbstractPathProperty)) {
3975+ replacement = ConvertToPathProperty((TCTLAbstractStateProperty)replacement);
3976+ }
3977+ newProperty = newProperty.replace(newProperty, replacement);
3978+ replacement = removeConverter(replacement);
3979+
3980+ if (newProperty instanceof TCTLAbstractPathProperty) resetQuantifierSelectionButtons();
3981+
3982+ updateSelection(replacement);
3983+ queryChanged();
3984+
3985+ return newProperty;
3986+ }
3987+ return null;
3988+ }
3989+
3990+ private void deleteProperty() {
3991+ if (newProperty != null) {
3992+ TCTLAbstractProperty replacement = null;
3993+ newProperty = removeConverter(newProperty);
3994+ if (newProperty instanceof TCTLAbstractStateProperty) {
3995+ replacement = new TCTLStatePlaceHolder();
3996+ } else if (newProperty instanceof TCTLAbstractPathProperty) {
3997+ replacement = new TCTLPathPlaceHolder();
3998+ }
3999+ replaceProperty(replacement);
4000+ }
4001+ }
4002+
4003+ private int showWarningMessage(boolean toCTL) {
4004+ String category = toCTL ? "CTL" : "LTL";
4005+ String message = "The query property will be deleted, because it is not compatible with "+category+"-queries.\n" +
4006+ "Are you sure you want to change query category?";
4007+ String title = "Incompatible query";
4008+
4009+ return JOptionPane.showConfirmDialog(
4010+ CreateGui.getApp(),
4011+ message,
4012+ title,
4013+ JOptionPane.YES_NO_OPTION,
4014+ JOptionPane.WARNING_MESSAGE);
4015+ }
4016+
4017+ private void addAllPathsToProperty(TCTLAbstractProperty oldProperty, TCTLAbstractProperty selection) {
4018+ TCTLAbstractProperty property = null;
4019+
4020+ if (oldProperty instanceof LTLANode) {
4021+ property = oldProperty;
4022+ } else if (oldProperty instanceof TCTLPathPlaceHolder) {
4023+ property = new LTLANode();
4024+ } else if (oldProperty instanceof TCTLAbstractPathProperty) {
4025+ property = new LTLANode(ConvertToStateProperty((TCTLAbstractPathProperty) oldProperty));
4026+ } else if (oldProperty instanceof TCTLNotNode) {
4027+ property = new LTLANode((TCTLNotNode) oldProperty);
4028+ property = ConvertToStateProperty((TCTLAbstractPathProperty) property);
4029+ } else if (oldProperty instanceof TCTLAbstractStateProperty && (selection == null || selection instanceof LTLANode)) {
4030+ property = new LTLANode((TCTLAbstractStateProperty) oldProperty);
4031+ if (!(newProperty instanceof TCTLAbstractPathProperty)) newProperty = ConvertToPathProperty((TCTLAbstractStateProperty) newProperty);
4032+ }
4033+
4034+ if (property != null && selection != null) {
4035+ UndoableEdit edit = new QueryConstructionEdit(selection, property);
4036+ newProperty = newProperty.replace(newProperty, property);
4037+ updateSelection(property);
4038+ undoSupport.postEdit(edit);
4039+ queryChanged();
4040+ } else if (property != null) {
4041+ newProperty = newProperty.replace(newProperty, property);
4042+ updateSelection(property);
4043+ queryChanged();
4044+ }
4045+ }
4046+
4047+ private void addExistsPathsToProperty(TCTLAbstractProperty oldProperty, TCTLAbstractProperty selection) {
4048+ TCTLAbstractProperty property = null;
4049+
4050+ if (oldProperty instanceof LTLENode) {
4051+ property = oldProperty;
4052+ } else if (oldProperty instanceof TCTLPathPlaceHolder) {
4053+ property = new LTLENode();
4054+ } else if (oldProperty instanceof TCTLAbstractPathProperty) {
4055+ property = new LTLENode(ConvertToStateProperty((TCTLAbstractPathProperty) oldProperty));
4056+ } else if (oldProperty instanceof TCTLNotNode) {
4057+ property = new LTLENode((TCTLNotNode) oldProperty);
4058+ property = ConvertToStateProperty((TCTLAbstractPathProperty) property);
4059+ } else if (oldProperty instanceof TCTLAbstractStateProperty && (selection == null || selection instanceof LTLENode)) {
4060+ property = new LTLENode((TCTLAbstractStateProperty) oldProperty);
4061+ if (!(newProperty instanceof TCTLAbstractPathProperty)) newProperty = ConvertToPathProperty((TCTLAbstractStateProperty) newProperty);
4062+ }
4063+
4064+ if (property != null && selection != null) {
4065+ UndoableEdit edit = new QueryConstructionEdit(selection, property);
4066+ newProperty = newProperty.replace(newProperty, property);
4067+ updateSelection(property);
4068+ undoSupport.postEdit(edit);
4069+ queryChanged();
4070+ } else if (property != null) {
4071+ newProperty = newProperty.replace(newProperty, property);
4072+ updateSelection(property);
4073+ queryChanged();
4074+ }
4075+ }
4076+
4077+ private TCTLAbstractProperty removeExistsAllPathsFromProperty(TCTLAbstractProperty oldProperty) {
4078+ TCTLAbstractProperty property = oldProperty;
4079+ TCTLAbstractStateProperty firstChild = getSpecificChildOfProperty(1, oldProperty);
4080+
4081+ if (oldProperty instanceof TCTLPathToStateConverter) {
4082+ oldProperty = ((TCTLPathToStateConverter) oldProperty).getProperty();
4083+ firstChild = getSpecificChildOfProperty(1, oldProperty);
4084+ }
4085+ if (oldProperty instanceof LTLANode) {
4086+ TCTLAbstractPathProperty child = ConvertToPathProperty(firstChild);
4087+ property = oldProperty.replace(oldProperty, child);
4088+ }
4089+ if (oldProperty instanceof LTLENode) {
4090+ TCTLAbstractPathProperty child = ConvertToPathProperty(firstChild);
4091+ property = oldProperty.replace(oldProperty, child);
4092+ }
4093+
4094+ return property;
4095+ }
4096+
4097 private void initBoundednessCheckPanel() {
4098
4099 // Number of extra tokens field
4100@@ -1644,6 +2044,12 @@
4101 existsNext = new JButton("EX");
4102 forAllUntil = new JButton("AU");
4103 forAllNext = new JButton("AX");
4104+ globallyButton = new JButton("G");
4105+ finallyButton = new JButton("F");
4106+ nextButton = new JButton("X");
4107+ untilButton = new JButton("U");
4108+ aButton = new JButton("A");
4109+ eButton = new JButton("E");
4110
4111 // Add tool-tips
4112 existsDiamond.setToolTipText(TOOL_TIP_EXISTS_DIAMOND);
4113@@ -1654,6 +2060,12 @@
4114 existsNext.setToolTipText(TOOL_TIP_EXISTS_NEXT);
4115 forAllUntil.setToolTipText(TOOL_TIP_FORALL_UNTIL);
4116 forAllNext.setToolTipText(TOOL_TIP_FORALL_NEXT);
4117+ globallyButton.setToolTipText(TOOL_TIP_G);
4118+ finallyButton.setToolTipText(TOOL_TIP_F);
4119+ nextButton.setToolTipText(TOOL_TIP_X);
4120+ untilButton.setToolTipText(TOOL_TIP_U);
4121+ aButton.setToolTipText(TOOL_TIP_A);
4122+ eButton.setToolTipText(TOOL_TIP_E);
4123
4124 // Add buttons to panel
4125 quantificationButtonGroup.add(existsDiamond);
4126@@ -1664,6 +2076,12 @@
4127 quantificationButtonGroup.add(existsNext);
4128 quantificationButtonGroup.add(forAllUntil);
4129 quantificationButtonGroup.add(forAllNext);
4130+ quantificationButtonGroup.add(globallyButton);
4131+ quantificationButtonGroup.add(finallyButton);
4132+ quantificationButtonGroup.add(nextButton);
4133+ quantificationButtonGroup.add(untilButton);
4134+ quantificationButtonGroup.add(aButton);
4135+ quantificationButtonGroup.add(eButton);
4136
4137 // Place buttons in GUI
4138 GridBagConstraints gbc = new GridBagConstraints();
4139@@ -1674,24 +2092,32 @@
4140 gbc.gridy = 0;
4141 gbc.insets = new Insets(0, 0, 5, 0);
4142 quantificationPanel.add(existsDiamond, gbc);
4143+ quantificationPanel.add(globallyButton, gbc);
4144 gbc.gridy = 1;
4145 quantificationPanel.add(existsBox, gbc);
4146+ quantificationPanel.add(finallyButton, gbc);
4147 gbc.gridy = 2;
4148 quantificationPanel.add(existsUntil, gbc);
4149 gbc.gridy = 3;
4150 quantificationPanel.add(existsNext, gbc);
4151+ gbc.gridy = 4;
4152+ quantificationPanel.add(aButton, gbc);
4153
4154 // Second column of buttons
4155 gbc.gridx = 2;
4156 gbc.gridy = 0;
4157 gbc.insets = new Insets(0, 0, 5, 0);
4158 quantificationPanel.add(forAllDiamond, gbc);
4159+ quantificationPanel.add(nextButton, gbc);
4160 gbc.gridy = 1;
4161 quantificationPanel.add(forAllBox, gbc);
4162+ quantificationPanel.add(untilButton, gbc);
4163 gbc.gridy = 2;
4164 quantificationPanel.add(forAllUntil, gbc);
4165 gbc.gridy = 3;
4166 quantificationPanel.add(forAllNext, gbc);
4167+ gbc.gridy = 4;
4168+ quantificationPanel.add(eButton, gbc);
4169
4170 // Add quantification panel to query panel
4171 gbc = new GridBagConstraints();
4172@@ -1703,8 +2129,10 @@
4173
4174 if (lens.isTimed()|| lens.isGame()) {
4175 addTimedQuantificationListeners();
4176+ showLTLButtons(false);
4177 } else {
4178 addUntimedQuantificationListeners();
4179+ showLTLButtons(false);
4180 }
4181 }
4182
4183@@ -1775,6 +2203,18 @@
4184 }
4185 });
4186
4187+ globallyButton.addActionListener(e -> {
4188+ LTLGNode property = new LTLGNode(getSpecificChildOfProperty(1, currentSelection.getObject()));
4189+ addPropertyToQuery(property);
4190+ unselectButtons();
4191+ });
4192+
4193+ finallyButton.addActionListener(e -> {
4194+ LTLFNode property = new LTLFNode(getSpecificChildOfProperty(1, currentSelection.getObject()));
4195+ addPropertyToQuery(property);
4196+ unselectButtons();
4197+ });
4198+
4199 forAllNext.addActionListener(new ActionListener() {
4200 public void actionPerformed(ActionEvent e) {
4201 TCTLAbstractPathProperty property;
4202@@ -1800,16 +2240,104 @@
4203 addPropertyToQuery(property);
4204 }
4205 });
4206+
4207+ nextButton.addActionListener(new ActionListener() {
4208+ public void actionPerformed(ActionEvent e) {
4209+ TCTLAbstractPathProperty property;
4210+ if (currentSelection.getObject() instanceof TCTLAbstractStateProperty) {
4211+ property = new LTLXNode((TCTLAbstractStateProperty) currentSelection.getObject());
4212+ } else {
4213+ property = new LTLXNode(getSpecificChildOfProperty(1, currentSelection.getObject()));
4214+ }
4215+ addPropertyToQuery(property);
4216+ }
4217+ });
4218+
4219+ untilButton.addActionListener(new ActionListener() {
4220+ public void actionPerformed(ActionEvent e) {
4221+ TCTLAbstractPathProperty property;
4222+ if (currentSelection.getObject() instanceof TCTLAbstractStateProperty) {
4223+ property = new LTLUNode((TCTLAbstractStateProperty) currentSelection.getObject(),
4224+ new TCTLStatePlaceHolder());
4225+ } else {
4226+ property = new LTLUNode(getSpecificChildOfProperty(1, currentSelection.getObject()),
4227+ getSpecificChildOfProperty(2, currentSelection.getObject()));
4228+ }
4229+ addPropertyToQuery(property);
4230+ }
4231+ });
4232+
4233+ aButton.addActionListener(new ActionListener() {
4234+ public void actionPerformed(ActionEvent e) {
4235+ TCTLAbstractProperty oldProperty = newProperty;
4236+
4237+ newProperty = removeExistsAllPathsFromProperty(newProperty);
4238+ addAllPathsToProperty(newProperty, null);
4239+ UndoableEdit edit = new QueryConstructionEdit(oldProperty, newProperty);
4240+ undoSupport.postEdit(edit);
4241+
4242+ queryChanged();
4243+ }
4244+ });
4245+
4246+ eButton.addActionListener(new ActionListener() {
4247+ public void actionPerformed(ActionEvent e) {
4248+ TCTLAbstractProperty oldProperty = newProperty;
4249+
4250+ newProperty = removeExistsAllPathsFromProperty(newProperty);
4251+ addExistsPathsToProperty(newProperty, null);
4252+ UndoableEdit edit = new QueryConstructionEdit(oldProperty, newProperty);
4253+ undoSupport.postEdit(edit);
4254+
4255+ queryChanged();
4256+ }
4257+ });
4258+ }
4259+
4260+ private void showLTLButtons(boolean isVisible) {
4261+ globallyButton.setVisible(isVisible);
4262+ finallyButton.setVisible(isVisible);
4263+ nextButton.setVisible(isVisible);
4264+ untilButton.setVisible(isVisible);
4265+ aButton.setVisible(isVisible);
4266+ eButton.setVisible(isVisible);
4267+ if (deadLockPredicateButton != null) deadLockPredicateButton.setVisible(!isVisible);
4268+ showCTLButtons(!isVisible);
4269+ }
4270+
4271+ private void showCTLButtons(boolean isVisible) {
4272+ forAllBox.setVisible(isVisible);
4273+ forAllDiamond.setVisible(isVisible);
4274+ forAllNext.setVisible(isVisible);
4275+ forAllUntil.setVisible(isVisible);
4276+ existsBox.setVisible(isVisible);
4277+ existsDiamond.setVisible(isVisible);
4278+ existsNext.setVisible(isVisible);
4279+ existsUntil.setVisible(isVisible);
4280+ }
4281+ private void updateShiphonTrap(boolean isLTL) {
4282+ useSiphonTrap.setEnabled(!isLTL);
4283 }
4284
4285 private void addPropertyToQuery(TCTLAbstractPathProperty property) {
4286- if (currentSelection.getObject() instanceof TCTLAbstractStateProperty) {
4287+ TCTLAbstractProperty selection = currentSelection.getObject();
4288+ if (selection instanceof TCTLAbstractStateProperty) {
4289 addPropertyToQuery(ConvertToStateProperty(property));
4290 return;
4291 }
4292
4293- UndoableEdit edit = new QueryConstructionEdit(currentSelection.getObject(), property);
4294- newProperty = newProperty.replace(currentSelection.getObject(), property);
4295+ if (selection instanceof LTLANode) {
4296+ newProperty = newProperty.replace(selection, property);
4297+ addAllPathsToProperty(newProperty, selection);
4298+ return;
4299+ } else if (selection instanceof LTLENode) {
4300+ newProperty = newProperty.replace(selection, property);
4301+ addExistsPathsToProperty(newProperty, selection);
4302+ return;
4303+ }
4304+
4305+ UndoableEdit edit = new QueryConstructionEdit(selection, property);
4306+ newProperty = newProperty.replace(selection, property);
4307 updateSelection(property);
4308 undoSupport.postEdit(edit);
4309 queryChanged();
4310@@ -1979,8 +2507,11 @@
4311 addPropertyToQuery(property);
4312 } else if (currentSelection.getObject() instanceof TCTLAbstractPathProperty) {
4313 TCTLStatePlaceHolder ph = new TCTLStatePlaceHolder();
4314+
4315+ TCTLAbstractProperty oldProperty = removeExistsAllPathsFromProperty(currentSelection.getObject());
4316+
4317 andListNode = new TCTLAndListNode(getStateProperty(
4318- new TCTLPathToStateConverter((TCTLAbstractPathProperty) currentSelection.getObject())), ph);
4319+ new TCTLPathToStateConverter((TCTLAbstractPathProperty) oldProperty)), ph);
4320
4321 TCTLAbstractPathProperty property = new TCTLStateToPathConverter(andListNode);
4322 addPropertyToQuery(property);
4323@@ -2007,8 +2538,10 @@
4324 addPropertyToQuery(property);
4325 } else if (currentSelection.getObject() instanceof TCTLAbstractPathProperty) {
4326 TCTLStatePlaceHolder ph = new TCTLStatePlaceHolder();
4327+ TCTLAbstractProperty oldProperty = removeExistsAllPathsFromProperty(currentSelection.getObject());
4328+
4329 orListNode = new TCTLOrListNode(getStateProperty(
4330- new TCTLPathToStateConverter((TCTLAbstractPathProperty) currentSelection.getObject())), ph);
4331+ new TCTLPathToStateConverter((TCTLAbstractPathProperty) oldProperty)), ph);
4332
4333 TCTLAbstractPathProperty property = new TCTLStateToPathConverter(orListNode);
4334 addPropertyToQuery(property);
4335@@ -2307,8 +2840,12 @@
4336 return;
4337 } else if (lens.isTimed()) {
4338 newQuery = TAPAALQueryParser.parse(queryField.getText());
4339- } else {
4340+ } else if (queryType.getSelectedIndex() == 0) {
4341 newQuery = TAPAALCTLQueryParser.parse(queryField.getText());
4342+ } else if (queryType.getSelectedIndex() == 1) {
4343+ newQuery = TAPAALLTLQueryParser.parse(queryField.getText());
4344+ } else {
4345+ throw new Exception();
4346 }
4347 } catch (Throwable ex) {
4348 String message = ex.getMessage() == null ? "TAPAAL encountered an error while trying to parse the specified query\n" :
4349@@ -2374,6 +2911,13 @@
4350 } else { // we are not in edit mode so the button should reset
4351 // the query
4352
4353+ if (queryType.getSelectedIndex() == 1) {
4354+ TCTLAbstractProperty oldProperty = newProperty;
4355+ addAllPathsToProperty(new TCTLPathPlaceHolder(), oldProperty);
4356+ resetQuantifierSelectionButtons();
4357+ return;
4358+ }
4359+
4360 TCTLPathPlaceHolder ph = new TCTLPathPlaceHolder();
4361 UndoableEdit edit = new QueryConstructionEdit(newProperty, ph);
4362 newProperty = ph;
4363@@ -2695,6 +3239,7 @@
4364 usePTrie = new JCheckBox("Use PTrie");
4365 useOverApproximation = new JCheckBox("Use untimed state-equations check");
4366 useTraceRefinement = new JCheckBox("Use trace abstraction refinement");
4367+ useTarjan = new JCheckBox("Use Tarjan");
4368
4369 useReduction.setSelected(true);
4370 useSiphonTrap.setSelected(false);
4371@@ -2708,6 +3253,7 @@
4372 usePTrie.setSelected(true);
4373 useOverApproximation.setSelected(true);
4374 useTraceRefinement.setSelected(false);
4375+ useTarjan.setSelected(true);
4376
4377 useReduction.setToolTipText(TOOL_TIP_USE_STRUCTURALREDUCTION);
4378 useSiphonTrap.setToolTipText(TOOL_TIP_USE_SIPHONTRAP);
4379@@ -2721,6 +3267,9 @@
4380 usePTrie.setToolTipText(TOOL_TIP_PTRIE);
4381 useOverApproximation.setToolTipText(TOOL_TIP_OVERAPPROX);
4382 useTraceRefinement.setToolTipText(TOOL_TIP_USE_TRACE_REFINEMENT);
4383+ useTarjan.setToolTipText(TOOL_TIP_USE_TARJAN);
4384+
4385+ useTarjan.addActionListener(e -> updateSearchStrategies());
4386
4387 if (lens.isTimed() || lens.isGame()) {
4388 initTimedReductionOptions();
4389@@ -2809,6 +3358,9 @@
4390 gbc.gridx = 3;
4391 gbc.gridy = 0;
4392 reductionOptionsPanel.add(useTraceRefinement, gbc);
4393+ gbc.gridx = 3;
4394+ gbc.gridy = 1;
4395+ reductionOptionsPanel.add(useTarjan, gbc);
4396 }
4397
4398 protected void setEnabledOptionsAccordingToCurrentReduction() {
4399@@ -2822,6 +3374,7 @@
4400 refreshOverApproximationOption();
4401 } else if (!lens.isTimed()) {
4402 refreshTraceRefinement();
4403+ refreshTarjan();
4404 }
4405 updateSearchStrategies();
4406 refreshExportButtonText();
4407@@ -2831,13 +3384,21 @@
4408 ReductionOption reduction = getReductionOption();
4409 useTraceRefinement.setEnabled(false);
4410
4411- if (reduction != null && reduction.equals(ReductionOption.VerifyPN) && !hasInhibitorArcs &&
4412+ if (queryType.getSelectedIndex() != 1 && reduction != null && reduction.equals(ReductionOption.VerifyPN) &&
4413 (newProperty.toString().startsWith("AG") || newProperty.toString().startsWith("EF")) &&
4414- !newProperty.hasNestedPathQuantifiers()) {
4415+ !hasInhibitorArcs && !newProperty.hasNestedPathQuantifiers()) {
4416 useTraceRefinement.setEnabled(true);
4417 }
4418 }
4419
4420+ private void refreshTarjan() {
4421+ if (queryType.getSelectedIndex() == 1) {
4422+ useTarjan.setVisible(true);
4423+ } else {
4424+ useTarjan.setVisible(false);
4425+ }
4426+ }
4427+
4428 private void refreshDiscreteInclusion() {
4429 ReductionOption reduction = getReductionOption();
4430 if(reduction == null){
4431@@ -3014,13 +3575,37 @@
4432 }
4433 }
4434
4435+ private void updateLTLButtons() {
4436+ if (currentSelection.getObject() == newProperty) {
4437+ String ltlType = checkLTLType();
4438+ disableAllLTLButtons();
4439+ if (ltlType.equals("placeholder")) {
4440+ aButton.setEnabled(true);
4441+ eButton.setEnabled(true);
4442+ } else if (ltlType.equals("A")) {
4443+ eButton.setEnabled(true);
4444+ } else {
4445+ aButton.setEnabled(true);
4446+ }
4447+ } else {
4448+ aButton.setEnabled(false);
4449+ eButton.setEnabled(false);
4450+ globallyButton.setEnabled(true);
4451+ finallyButton.setEnabled(true);
4452+ nextButton.setEnabled(true);
4453+ untilButton.setEnabled(true);
4454+ }
4455+ }
4456+
4457
4458 private void queryChanged(){
4459- setEnabledReductionOptions();
4460+ setEnabledReductionOptions();
4461 if (lens.isTimed()) refreshOverApproximationOption();
4462+ if (queryType.getSelectedIndex() == 1) {
4463+ updateLTLButtons();
4464+ }
4465 }
4466
4467-
4468 private void initButtonPanel(QueryDialogueOption option) {
4469 buttonPanel = new JPanel(new BorderLayout());
4470 if (option == QueryDialogueOption.Save) {
4471
4472=== removed directory 'src/resources/SUMOParser'
4473=== removed directory 'src/resources/TCTLParser'

Subscribers

People subscribed via source and target branches